I see it now. Thanks man! I have a different problem now, now i don't get
any errors immediately but when i go on users/create i get an error saying:
<type 'exceptions.AttributeError'> 'DAL' object has no attribute 'companies'
obviously companies model is not loaded, i am thinking on switching to
SQLform.factory, would this be a better solution? In models i define my
tables and then in my controller i make a form, then insert and updated
goes manually, but this is not so problematic.
On Monday, April 8, 2013 9:52:24 AM UTC+2, Niphlod wrote:
>
> too many db.....
>
> requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s'))
>
> needs to be
>
> requires=IS_IN_DB(db, 'companies.id', '%(name)s')
>
>
>
> On Monday, April 8, 2013 9:39:15 AM UTC+2, Domagoj Kovač wrote:
>>
>> Hi,
>>
>> i tried moving companies outside of db.py.
>>
>> In db.py i have:
>>
>> auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean',
>> default=False),
>> Field('company_id', 'reference
>> companies', requires=IS_IN_DB(db, (db, 'companies.id', '%(name)s')))]
>>
>> Error i am receiving now is:
>> <type 'exceptions.ValueError'> too many values to unpack
>> What is wrong now?
>>
>> On Friday, April 5, 2013 7:09:28 PM UTC+2, Anthony wrote:
>>>
>>> Note, simply doing (db, 'companies.id', ...) may not completely resolve
>>> the problem. Even doing that, the db.companies table is only getting
>>> defined conditionally when the "companies" controller is called, but the
>>> db.auth_user table is defined on every request, and it could be used by
>>> other controllers. If the auth_user table links to another table, it may be
>>> a good idea to make sure that other table is defined whenever the auth_user
>>> table is defined (i.e., maybe move the db.companies table definition into
>>> db.py or some other model that isn't conditionally executed).
>>>
>>> Anthony
>>>
>>> On Friday, April 5, 2013 11:30:38 AM UTC-4, Niphlod wrote:
>>>>
>>>> Nope.
>>>> when "auth" definition is encountered, if you want to use
>>>> db.companies.id written as it is, db.define_table('companies') should
>>>> have been executead already.
>>>> You need to change your IS_IN_DB call to (db, 'companies.id',
>>>> '%(name)s') ... notice the ticks around companies.id, it's a string....
>>>> When you do it that way, the db.companies table will be called not at
>>>> "models definition" time, but at the time the page is rendered (so,
>>>> allowing all the models to be executed before --> having at your
>>>> disposition the companies table)
>>>>
>>>> On Friday, April 5, 2013 5:11:32 PM UTC+2, Domagoj Kovač wrote:
>>>>>
>>>>> Thanks guys,
>>>>>
>>>>> right now my db.py looks like this:
>>>>>
>>>>> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
>>>>> auth = Auth(db)
>>>>> crud, service, plugins = Crud(db), Service(), PluginManager()
>>>>>
>>>>> db.define_table('companies',
>>>>> Field('name', 'string',
>>>>> required=True,
>>>>> requires=IS_NOT_EMPTY(),
>>>>> label=LABEL(T("Naziv"), _for="companies_name")),
>>>>> Field('url_sufix', 'string',
>>>>> required=True,
>>>>> requires=IS_NOT_EMPTY(),
>>>>> unique=True,
>>>>> label=LABEL(T("Url-sufix"),
>>>>> _for="companies_url_sufix")),
>>>>> Field('logo', 'upload',
>>>>> label=LABEL(T("Logo"), _for="companies_logo")),
>>>>> Field('deleted', 'boolean'))
>>>>>
>>>>>
>>>>> auth.settings.extra_fields['auth_user'] = [Field('deleted', 'boolean',
>>>>> default=False),
>>>>> Field('company_id',
>>>>> 'reference companies', requires=IS_IN_DB(db, db.companies.id,
>>>>> '%(name)s'))]
>>>>>
>>>>> ## create all tables needed by auth if not custom tables
>>>>> auth.define_tables(username=False, signature=False)
>>>>>
>>>>> Is there any way i could have my companies definition in
>>>>> /companies/companies.py but still do this.
>>>>>
>>>>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.