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.

Reply via email to