Yes one of the tricks I usually employ is A_settings.py - global settings, etc B_web2py.py - dal definition, auth, crud, services, etc (web2py related things) C_model2.py - model definitions D_model3.py - query definitions plugin_etc.py plugin_etc2.py Z_compress_output.py
-Thadeus On Wed, Feb 24, 2010 at 4:23 PM, Christopher Steel <chris.st...@gmail.com> wrote: > For those interested I needed to rename the model file so that it got > loaded after the definition of the auth tables.. I chose > z_initializer.py which loaded it after db.py and my other tables. In > addition I dropped the "extra" stuff and ended up with the following: > > # Description: > # Automatically adds a user to the database called "automated > initializer". > > fname='automated' > lname='initializer' > > ##################################################################################### > # START db.auth_user insertion > # auth_user.first_name > # auth_user.last_name > fnames_found='None' > rows=db(db.auth_user.first_name == fname).select(db.auth_user.ALL) > for row in rows: > fnames_found = row.first_name > if fnames_found == 'None': > automated_user_id = > db.auth_user.insert(first_name=fname,last_name=lname) > > ... > > On Feb 24, 5:16 pm, Christopher Steel <chris.st...@gmail.com> wrote: >> Sure enough, the name I gave it put it before auth tables where >> defined. Working fine now. >> >> Thanks >> >> On Feb 24, 2:16 pm, Tiago Almeida <tiago.b.alme...@gmail.com> wrote: >> >> > Where do you have that code? in a model file? >> > Your problem is that the variable with name db is not defined in the scope >> > that code runs. >> >> > make sure you set it before, usually with >> >> > db = DAL <http://web2py.com/book/default/docstring/DAL>(...) >> > * >> > *this variable should be visible in a controller or a model. >> > You have to pass it if you're doing it for instance in a module. >> >> > Regards, Tiago >> >> > --- >> >> > On Wed, Feb 24, 2010 at 7:08 PM, Christopher Steel >> > <chris.st...@gmail.com>wrote:> I am trying to have my app create a default >> > user that will be used to >> > > track administrative tasks. >> >> > > Right now I have the following in the model section but auto inserting >> > > to the auth_user table does not seem to work. Does this have to be >> > > done manually or can I automatically create a user, group and group >> > > membership for a site administrative user? >> >> > > Right now I get the error: >> >> > > NameError: name 'db' is not defined >> >> > > Thanks, >> >> > > Chris >> >> > > Here is my code, it seems to worksfine for any other table but auth >> > > table(s) >> >> > > initializer_first_name = 'Database' >> > > initializer_last_name = 'Initializer' >> > > initializer_email = 'ad...@server.com' >> > > initializer_password = 'random' >> >> > > dbvalue='None' >> > > rows=db(db.auth_user.first_name=='Database').select(db.application.ALL) >> > > for row in rows: >> > > dbvalue = row.name >> >> > > if dbvalue == 'None': >> >> > > db.application.insert(first_name=initializer_first_name,last_name=initializer_last_name,email=initializer_email,initializer_password=initializer_password) >> >> > > -- >> > > You received this message because you are subscribed to the Google Groups >> > > "web2py-users" group. >> > > To post to this group, send email to web...@googlegroups.com. >> > > To unsubscribe from this group, send email to >> > > web2py+unsubscr...@googlegroups.com<web2py%2bunsubscr...@googlegroups.com> >> > > . >> > > For more options, visit this group at >> > >http://groups.google.com/group/web2py?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To post to this group, send email to web...@googlegroups.com. > To unsubscribe from this group, send email to > web2py+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/web2py?hl=en. > > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.