[web2py] Re: Model file variable scope
I'll try that thanks. Mr.NetAdmin On Aug 17, 5:11 pm, mdipierro wrote: > I am not sure it is a good idea to modify a system library like > gluon.tools.py, anyway > > in class Auth, you should have access to self.environment.request.vars > > On Aug 17, 4:57 pm, NetAdmin wrote: > > > So how can I grab last_name during a register function and save it > > to an already defined table? > > > Thanks > > > On Aug 17, 4:52 pm, mdipierro wrote: > > > > gluon/tools.py is a module and it is imported before your app is > > > executed. The web2py globals variables are not exposed there. > > > > On Aug 17, 4:46 pm, NetAdmin wrote: > > > > > in gluon/tools.py, I'm trying to modify the register() function > > > > to save request.vars.get('last_name', None ) to a table defined in > > > > db.py as > > > > db.define_table('tbextra', > > > > SQLField('lastn', 'string', length = 15 ) > > > > ) > > > > but tools.py does not recognize the db part of db.tbextra.lastn > > > > I thought variables in the model files were global. > > > > > What am I doing wrong? > > > > > Thanks
[web2py] Re: Model file variable scope
I am not sure it is a good idea to modify a system library like gluon.tools.py, anyway in class Auth, you should have access to self.environment.request.vars On Aug 17, 4:57 pm, NetAdmin wrote: > So how can I grab last_name during a register function and save it > to an already defined table? > > Thanks > > On Aug 17, 4:52 pm, mdipierro wrote: > > > gluon/tools.py is a module and it is imported before your app is > > executed. The web2py globals variables are not exposed there. > > > On Aug 17, 4:46 pm, NetAdmin wrote: > > > > in gluon/tools.py, I'm trying to modify the register() function > > > to save request.vars.get('last_name', None ) to a table defined in > > > db.py as > > > db.define_table('tbextra', > > > SQLField('lastn', 'string', length = 15 ) > > > ) > > > but tools.py does not recognize the db part of db.tbextra.lastn > > > I thought variables in the model files were global. > > > > What am I doing wrong? > > > > Thanks
[web2py] Re: Model file variable scope
So how can I grab last_name during a register function and save it to an already defined table? Thanks On Aug 17, 4:52 pm, mdipierro wrote: > gluon/tools.py is a module and it is imported before your app is > executed. The web2py globals variables are not exposed there. > > On Aug 17, 4:46 pm, NetAdmin wrote: > > > in gluon/tools.py, I'm trying to modify the register() function > > to save request.vars.get('last_name', None ) to a table defined in > > db.py as > > db.define_table('tbextra', > > SQLField('lastn', 'string', length = 15 ) > > ) > > but tools.py does not recognize the db part of db.tbextra.lastn > > I thought variables in the model files were global. > > > What am I doing wrong? > > > Thanks
[web2py] Re: Model file variable scope
gluon/tools.py is a module and it is imported before your app is executed. The web2py globals variables are not exposed there. On Aug 17, 4:46 pm, NetAdmin wrote: > in gluon/tools.py, I'm trying to modify the register() function > to save request.vars.get('last_name', None ) to a table defined in > db.py as > db.define_table('tbextra', > SQLField('lastn', 'string', length = 15 ) > ) > but tools.py does not recognize the db part of db.tbextra.lastn > I thought variables in the model files were global. > > What am I doing wrong? > > Thanks