[Tutor] client server apps

2007-08-26 Thread paulino1
Hi!


What's the point in having a server app between the user frontend and  
a database backend? (As is the case of TinyERP wich is writen in  
python-GTK)

Can't simillar functionality be achieved without that server? What are  
the main pro's and con's?


Thank you!

Paulino
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] exec sintax error or bug?

2007-09-27 Thread paulino1
Hello!

Why doesn't the second code snipet, work like the first?

>>> for i in range(5):
...if i == 3 : continue
...print i,
...
0 1 2 4

>>> exp = "if i == 3 : continue"
>>> for i in range(5):
...exec( exp )
...print i,
...
Traceback (most recent call last):
   File "", line 2, in 
   File "", line 1
SyntaxError: 'continue' not properly in loop (, line 1)


I have other examples os exp = "if  : do this" that  
work as expected when called by exec(exp)

So i think the problem is not about "continue" but about "exec".

>>> exp2 = 'if i == 2 : print 2**2'
>>> for i in range(5):
...exec( exp2 )
...print i,
...
0 1 4
2 3 4
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] exec sintax error or bug?

2007-09-27 Thread paulino1


  Citando Ian Witham <[EMAIL PROTECTED]>: 

> What version of Python arre you running Paulino? 
> 
> When I run your second snippet on 2.5 I get an error: 
> 
> >>> exp = "if i == 3 : continue" 
> >>> for i in range(5): 
> exec(exp) 
> print i, 
> 
> Traceback (most recent call last): 
>   File "", line 2, in  
> exec(exp) 
>   File "", line 1 
> SyntaxError: 'continue' not properly in loop (, line 1)
> 
> On 9/28/07, KENT JOHNSON <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] wrote: 
> > Hello! 
> > 
> > Why doesn't the second code snipet, work like the first? 
> > 
>  for i in range(5): 
> > ...if i == 3 : continue
> > ...print i, 
> > ... 
> > 0 1 2 4 
> > 
>  exp = "if i == 3 : continue" 
>  for i in range(5): 
> > ...exec( exp ) 
> > ...print i, 
> > ...
> > Traceback (most recent call last): 
> >File "", line 2, in  
> >File "", line 1 
> > SyntaxError: 'continue' not properly in loop (, line 1)
> 
> I think the code you pass to exec must be syntactically correct on its 
> own. It is parsed as if it were in a file by itself, then executed in 
> the local scope. 
> 
> Kent 
> ___
> Tutor maillist  -  [EMAIL PROTECTED] 
> http://mail.python.org/mailman/listinfo/tutor[4]

  That's my question, the second snippet returns an error... 

  I have 2.5.1 also.  

  

Ligações:
-
[1] mailto:[EMAIL PROTECTED]
[2] mailto:[EMAIL PROTECTED]
[3] mailto:Tutor@python.org
[4] http://mail.python.org/mailman/listinfo/tutor___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] python intall error

2006-09-21 Thread paulino1
When trying to install python in windows I get this error message:
"The installer encoutered an unexpected error, installing this package. This may
indicate a problem with this package. The error code is 2356"

I've found this error both with python-2.4.3.msi and python-2.5.msi in diferent
machines with and without administrator privileges.


Is it a bug?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Exception and sys.exit() in a cgi script

2006-10-24 Thread paulino1
I was wrong!

Now it works fine! Thank you!

I have another similar script where the print HTTP headers statement is in a
previous line... In this one it is not the case. Sorry for my inconvenience!


Paulino


Citando wesley chun <[EMAIL PROTECTED]>:

> > > >>
>
> paulino,
>
> mike and michael are correct. (...)
>
> -- wesley
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> "Core Python Programming", Prentice Hall, (c)2007,2001
> http://corepython.com
>
> wesley.j.chun :: wescpy-at-gmail.com
> python training and technical consulting
> cyberweb.consulting : silicon valley, ca
> http://cyberwebconsulting.com
>

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to programming and Python (Jorge Azedo)

2006-10-26 Thread paulino1
Parece que ja temos elementos para estabelecer uma comunidade portuguesa de
Python ;-)

Jorge,

Sugiro os tutoriais do site www.devshed.com. são simples e explicam bem o
significado do codigo!

Tb sou novo na programação, tenho ai 6 meses de Python.

A Caixa Magica promove cursos de Python em Lisboa, este ano houve ja 2 de 3
dias, penso que em Fevereiro e Junho.

Força, isto no inicio parece confuso, mas breve faz-se luz!

Paulino


Citando [EMAIL PROTECTED]:

>>2. New to programming and Python (Jorge Azedo)
>7. Re: New to programming and Python (rolando)
>
>
> Date: Thu, 26 Oct 2006 09:44:41 +0100
> From: rolando <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] New to programming and Python
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Jorge Azedo escreveu:
> > Hi guys ( and gals )
> >
> > I'm totally new to the whole programming scene (I decided to enter it
> > for many reasons, one of which is the fact that I *want* to know how to
> > program my computer) and I decided to start out with Python. I'm reading
> > lots of tutorials on it, trying to understand how to work with it, but
> > for some reason or another, it all seems a great mess to me. Am I doing
> > something wrong? Also, can anyone give me any pointers on how to start
> > working with Python?
> >
> > Thanks in advance for any help you can give me
> > - Jorge
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
> >
> Well, I?m also kind of new to the scene, so I still don?t know much.
>
> But you can try this book that I?ve been reading:
> Dive Into Python:
> http://www.diveintopython.org/ (you can download the PDF from there,
> which I belive has already a group of exemples to see when using the book).
>
> Also I?ve been reading the Python Wikibook that you can download from here:
> http://en.wikibooks.org/wiki/Python (it still has a few parts missing
> but it can give you a few pointers).
>
>
> (The part below problaby won?t make sense except if you are portuguese)
>
> I don?t know what type of Netcabo you have, if you want I can upload the
> pdf to a national host to count national traffic :)
>
>
> --
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
> End of Tutor Digest, Vol 32, Issue 110
> **
>


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] cgi form field and popup window

2006-10-26 Thread paulino1
I would like to have a popup window to show the possible options to a form field
(supplier ID) and that by clicking on the desired item, the field is
automatically filled. The options are a database field values.

I wonder if this is possible to do with python (point me some resources please),
or have I to deal with javascript ?

Many thanks,

Paulino

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Please comment my script

2006-11-13 Thread paulino1
This is a script I have at work, it is running fine (gives the output I want).
Any comments are very welcome.

It queries a database and gives out a reportlab pdf file with a balance sheet of
costs per department.

In the first version there were neither functions nor classes, it worked as
well, but with no reusability.

A second version I defined the functions very close to the ones found here, but
had lots of problems because the variables were all local to each function. So
I changed direction to this final version.

Maybe the matter here is not best suited for OOP. The class definition sounds
more like action than object...

I think the Query method is the peace of code that is more in need of
improvement...

Paulino

:
# -*- coding: latin-1 -*-
# Balancete por departamento

import sys, re

# Importa modulo MS SQL
import pymssql
con=pymssql.connect(host='gi-clsql', database='baandb',user='baan',
password='baan' )
cur=con.cursor()


# Importa os modulos ReportLab
from reportlab.platypus import *
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.platypus.flowables import Flowable


def FormCGI() :
"""Cathes the values 'ano', 'mes' and 'dept' from an HTML form """
import cgi
import cgitb; cgitb.enable()
form=cgi.FieldStorage()
try :
ano=form["ano"].value
mes=form["mes"].value
dept=form["custo"].value
return ano, mes, dept

except KeyError :
print "Content-type: text/html\n\n"
print """
Balancete por centro de custo
É necessário preencher todos os campos

Centro de custo: 
Exercicio: 
Periodo até: 

 """
sys.exit(0)



class BalanceteCusto:
""" Performs a query in a MS SQL database and returns a pdf file containing
a report of costs per department """

def __init__(self, ano, mes, dept):
self.ano = ano
self.mes = mes
self.dept = dept
self.ppistyle = ParagraphStyle('normal', fontName='helvetica',
fontSize=8 )
self.pag=( 21*cm, 29.7*cm)
self.PL=self.pag[0]
self.PA=self.pag[1]   # Largura, altura

self.meses={1:'Janeiro', 2:'Fevereiro', 3:'Marco', 4:'Abril', 5:'Maio',
6:'Junho', 7:'Julho',
8:'Agosto', 9:'Setembro', 10:'Outubro', 11:'Novembro',
12:'Dezembro', 13:'Regularizacoes'}
self.titulo="BALANCETE POR CENTRO DE CUSTO"
self.pdf = 'Balancetecc%s.pdf' %(self.dept)

 Definição dos formatos da tabela
self.st=[('ALIGN', (2, 0), (-1,-1), 'RIGHT') ,
('FONT', (0,1), (-1,-1), 'Helvetica', 8),
('FONT', (0,0), (-1, 0), 'Helvetica', 9),
('FONT', (0,-1), (-1, -1), 'Helvetica', 9),
('LINEBELOW', (0,0), (-1,0), 1, colors.blue),
('TOPPADDING', (0,1), (-1,-1), 1),
('BOTTOMPADDING', (0,1), (-1,-1), 1) ]
self.Query()
self.CriaPDF()


def Formata(self,num):
"""Formats numbers as the local settings"""
import locale
locale.setlocale(locale.LC_ALL, '')
if num == 0.0 : return ''
else : return locale.format("%.*f", (2, num), True)




def Pagina(self, canvas, doc) :
"""Sets the fixed content of the pages (reportlab)"""
# Cabeçalho
canvas.setFont('Helvetica', 13)
# Titulo centrado no papel
canvas.drawCentredString( self.PL / 2.0, self.PA - 2*cm, self.titulo)
canvas.setFont('Helvetica', 10)
#canvas.drawRightString(PL-2.3*cm, PA-3.1*cm, 'De '+dini+' a '+dfim)
canvas.drawString( 3.5*cm, self.PA - 2.6*cm, self.subtit1)
canvas.drawString( 3.5*cm, self.PA - 3.1*cm, self.subtit2)

# Rodape - lado direito
canvas.setFont('Helvetica', 8)
canvas.drawRightString( self.PL-60, 0.8*cm, 'Pagina %d' %(doc.page) )
canvas.line( 60, 30, self.PL-60, 30)


def Acumula(self, item, ctpai) :
"""Calculates grand-total and subtotals for the itermediate accounts"""
tdeb = self.acum[ctpai][1] + item[1]
tcred = self.acum[ctpai][2] + item[2]
self.acum[ctpai] = [ self.contas[ctpai], tdeb, tcred ]

def Desc(self, texto) :
"""Encodes text as required by reportlab"""
#return Paragraph( unicode( re.sub('&', '&', texto) , 'latin-1'),
style=ppistyle )
return unicode( texto, 'latin-1')



def Query( self ) :

cur.execute( """SELECT A.t_leac, SUM(A.t_fdam), SUM(A.t_fcam)
FROM ( SELECT c.t_leac, c.t_fdam, c.t_fcam
FROM ttfgld202100 c
WHERE c.t_cono=100 AND c.t_ptyp=1 AND c.t_year=%s AND c.t_prno<%d
AND c.t_dtyp=5 AND c.t_dimx='%s'
AND c.t_leac BETWEEN '6' AND '7') A
GROUP BY A.t_leac """ % (self.ano, eval(self.mes)+1, self.dept ) )
valores=cur.fetchall()

# Obtem descritivo das contas e centro de custo
cur.execute("SELECT

[Tutor] sleep command in python?

2006-11-14 Thread paulino1
Is there a "sleep" command in python like the bash's sleep?
___

O SAPO já está livre de vírus com a Panda Software, fique você também!
Clique em: http://antivirus.sapo.pt

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] CGI script: get the client user

2007-01-10 Thread paulino1
I have some python CGI scripts running in an intranet.

I would like to get the user of the client browser to use it as an input in the
script, so it can show the the data related to that user.

There is the function getpass.getuser() that would return the user logged in the
server.

Is it possible to get the user in the client side with Python or I do I have to
use javascript for that purpose?


Thank you,

Paulino
___

O SAPO já está livre de vírus com a Panda Software, fique você também!
Clique em: http://antivirus.sapo.pt

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] howto filter access to a cgi script

2007-02-28 Thread paulino1
Hi!

I have some python CGI scripts in an intranet, in a windows network, I  
would like to restrict the access to some of those scripts to a list  
of computers in the domain.

How?

Thanks, Paulino
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor