Ok, Thanks!!

if possible,
it analyzes my code and it sees if he is correct, the implementation is
best or bad ?

Thanks

=================================================
module: postgres_python.py
=================================================
from pyPgSQL import PgSQL ;
import sys;
from datetime import datetime;

class TModPostgreSQL:
    def __init__(self, ahost = "localhost",
                       auser = "",
                       asenha = "",
                       adb = ""):
        try:
            self.conn = PgSQL.connect (host = ahost,
                                       user = auser,
                                       password = asenha,
                                       database = adb,
                                       client_encoding = "latin-1",
                                       unicode_results=0);
            self.cursor = self.conn.cursor();
        except PgSQL.Error, e:
            print "Error %s " % (e.args[0] )
           # sys.exit (1);
========================END======================


=================================================
controllers.py
=================================================
import turbogears
from postgres_python import TModPostgreSQL
import cherrypy
from turbogears  import controllers

pgpy = TModPostgreSQL(ahost = "cspsolucoes.com.br",
                                                auser = "autocap",
                                                asenha = "toafor32vix",
                                                adb = "CSP");

class Root(controllers.Root):
    @turbogears.expose(html="webcap.templates.login")
    def index(self):
        if cherrypy.session.get('user_loged', 0):
            raise cherrypy.HTTPRedirect(turbogears.url("/afterlogin"))

        return dict(msg="")

    def login(self, **kw):
        user = kw.pop("user")
        password = kw.pop("password")

        i = 0

        for r in pgpy.sqlexpr("Select cdcontr, cdusu, cdcliente, nivel,
maxfoto, nmusu, pass_word, admin, ativo, permissao from usu where
username = '%s' and pass_word = %s",params):
            i = 1
            cherrypy.session['user_loged']   = r['cdusu']     # Codigo
do usuário logado
            cherrypy.session['user_contr']   = r['cdcontr']   #
Contrato do usuário logado
            cherrypy.session['user_cliente'] = r['cdcliente'] # Codigo
do cliente a qual o usuário pertence
            cherrypy.session['user_maxfoto'] = r['maxfoto']   # tamanho
do buffer de imagens do usuário
            cherrypy.session['user_completename'] = r['nmusu']   #
tamanho do buffer de imagens do usuário
            #cherrypy.session['user_admin'] = r['admin']   # tamanho do
buffer de imagens do usuário
            cherrypy.session['user_ativo'] = r['ativo']   # tamanho do
buffer de imagens do usuário
            cherrypy.session['user_perm'] = checkPerm(r['permissao'])

        if i:
            pgpy.sqlexec("update usu set idautentication = '%s' where
cdusu = %s" % (cherrypy.session.get('_id'),

             cherrypy.session.get('user_loged')) )
            pgpy.conn.commit()
            raise cherrypy.HTTPRedirect(turbogears.url("/afterlogin"))
        else:
            return dict(msg = USER_NOT_FOUND)

========================END======================


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to