which web2py version?

On Tue, Aug 21, 2012 at 7:41 PM, Daniel Gonzalez <[email protected]> wrote:

> Hi,
>
> I have defined so my authorization table (db.py):
>
> # Use the authorization table for agents
> agent_table = auth.settings.table_user_name
> db.define_table(
>     agent_table,
>     Field('email',                unique=True),
>     Field('agent_doc_id',         length=128, compute=create_new_agent),
>     Field('password', 'password', length=512, 
> compute=automatic_password,readable
> =False, label='Password'),
>     format = '%(email)s %(agent_doc_id)s %(password)s')
>
>
> # Add contstraints to the agent table
> agent = db[agent_table]
> agent.email.requires = [IS_EMAIL(error_message=auth.messages.invalid_email
> ), IS_NOT_IN_DB(db, '%s.email' % (agent_table))]
>
> In one of my controllers I want to access the agents, which are in the
> auth_user table. I do the following:
>
>     form = SQLFORM(db[agent_table])
>
> I have verified my database (sqlite), and the table is indeed there. But I
> get the following error:
>
> <type 'exceptions.KeyError'> 'auth_user'
>
> The errror is happening when accessing db[agent_table] in the controller.
> Meanwhile, doing the same access in the model file (db.py), works fine.
> What is going on?
>
> Thanks,
> Daniel
>
> --
>
>
>
>

-- 



Reply via email to