[web2py] Re: auth.settings.extra_fields problem
if you put define table separtely (into more than 1 file), models file is load base on file name ordered. so let say you have db_wizard_1.py that define table department (generate first) db_wizard_2.py that define table auth_tables in case you put all the define tables into 1 file such as db.py so the define table is order by top down base (the top line 1, is define first). best regards, stifan On Friday, August 14, 2015 at 5:23:52 PM UTC+7, Paolo Amboni wrote: > > It's true!!! > The table is in another model file. > I moved before the declaration and all works!!! > Which is the order web2py use to load models file? > > > Il giorno venerdì 14 agosto 2015 12:12:04 UTC+2, 黄祥 ha scritto: >> >> not sure without seeing the full code, but i guess you are not define >> table department before define auth tables. >> >> best regards, >> stifan >> >> On Friday, August 14, 2015 at 4:46:45 PM UTC+7, Paolo Amboni wrote: >>> >>> This don't work: >>> auth.settings.extra_fields['auth_user']= [ Field('id_dep','reference >>> departement'),] : >>> Cannot resolve reference departement in auth_user definition >>> This work: >>> auth.settings.extra_fields['auth_user']= [ Field('id_dep','integer'),] >>> >>> Why? >>> >>> Is there a way to make it work? >>> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: auth.settings.extra_fields problem
It's true!!! The table is in another model file. I moved before the declaration and all works!!! Which is the order web2py use to load models file? Il giorno venerdì 14 agosto 2015 12:12:04 UTC+2, 黄祥 ha scritto: > > not sure without seeing the full code, but i guess you are not define > table department before define auth tables. > > best regards, > stifan > > On Friday, August 14, 2015 at 4:46:45 PM UTC+7, Paolo Amboni wrote: >> >> This don't work: >> auth.settings.extra_fields['auth_user']= [ Field('id_dep','reference >> departement'),] : >> Cannot resolve reference departement in auth_user definition >> This work: >> auth.settings.extra_fields['auth_user']= [ Field('id_dep','integer'),] >> >> Why? >> >> Is there a way to make it work? >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: auth.settings.extra_fields problem
not sure without seeing the full code, but i guess you are not define table department before define auth tables. best regards, stifan On Friday, August 14, 2015 at 4:46:45 PM UTC+7, Paolo Amboni wrote: > > This don't work: > auth.settings.extra_fields['auth_user']= [ Field('id_dep','reference > departement'),] : > Cannot resolve reference departement in auth_user definition > This work: > auth.settings.extra_fields['auth_user']= [ Field('id_dep','integer'),] > > Why? > > Is there a way to make it work? > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: auth.settings.extra_fields - do not show on registration?
you have to do it checking request.args(0) in the function that provides auth() usually it's the def user() inside default.py something like def user(): if request.args(0) == 'register': db.table.field.writable = db.table.field.readable = False . return dict(form=auth()) should be enough to accomodate your requirements. On Monday, April 22, 2013 7:39:07 PM UTC+2, Dragan Matic wrote: > > Is it possible to add extra fields into auth and not have them shown/asked > on the registration page but only on the user settings page? > -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields
I added companies definition in db.py. It will be ok for now. Thanks. On Monday, April 8, 2013 11:05:22 AM UTC+2, Domagoj Kovač wrote: > > Is there any way to load models manually? > > On Monday, April 8, 2013 10:23:55 AM UTC+2, Niphlod wrote: >> >> uhm. if you want that field to be a reference to the values on the table, >> the table must be defined, so I don't see how a SQLFORM.factory could help >> you with that. >> You simply have a conditional model that for your app logic doesn't need >> to be conditional . >> >> On Monday, April 8, 2013 10:20:56 AM UTC+2, Domagoj Kovač wrote: >>> >>> 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: >>> '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: > 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
[web2py] Re: auth.settings.extra_fields
Is there any way to load models manually? On Monday, April 8, 2013 10:23:55 AM UTC+2, Niphlod wrote: > > uhm. if you want that field to be a reference to the values on the table, > the table must be defined, so I don't see how a SQLFORM.factory could help > you with that. > You simply have a conditional model that for your app logic doesn't need > to be conditional . > > On Monday, April 8, 2013 10:20:56 AM UTC+2, Domagoj Kovač wrote: >> >> 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: >> '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: 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 web2py+unsubscr...@go
[web2py] Re: auth.settings.extra_fields
uhm. if you want that field to be a reference to the values on the table, the table must be defined, so I don't see how a SQLFORM.factory could help you with that. You simply have a conditional model that for your app logic doesn't need to be conditional . On Monday, April 8, 2013 10:20:56 AM UTC+2, Domagoj Kovač wrote: > > 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: > '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: >>> 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields
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: '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: >> 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields
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: > 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields
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: 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.idwritten 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields
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.idwritten 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields
Thanks man! On Friday, April 5, 2013 5:30:38 PM UTC+2, Niphlod wrote: > > Nope. > when "auth" definition is encountered, if you want to use > db.companies.idwritten 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields
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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields
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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields
the point is having that "db.companies.id" evaluated later . you can pass a string to the is_in_db validator, it shouldn't raise the error IS_IN_DB(db, 'companies.id', '%(name)s') *should* work giving you a nice dropdown too. On Friday, April 5, 2013 4:48:33 PM UTC+2, ctrlSoft wrote: > > models are executed in alphabetical order. db.py and after that > companies.py, you make reference to a non defined table. you sould define > companies table before auth.settings.extra_fields['auth_user'] = > auth = Auth(db) > # > # > # > # > 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))] > > in db.py > -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields
models are executed in alphabetical order. db.py and after that companies.py, you make reference to a non define table. you sould define companies table right after auth = Auth(db) and before auth.settings. extra_fields['auth_user'] = auth = Auth(db) # # # # 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))] -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields['auth_user']
Thanks guys, i solved it other way. On Thursday, April 4, 2013 3:17:49 AM UTC+2, 黄祥 wrote: > > please try this in your db.py: > > db.define_table('company', > Field('company_name'), > Field('website'), > format='%(company_name)s') > > auth.settings.extra_fields['auth_user']=[ > Field('gender', 'list:string'), > Field('address', 'text'), > Field('zip'), > Field('city'), > Field('country'), > Field('phone'), > Field('company', 'reference company')] > > auth.define_tables(username=False, signature=True) > -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields['auth_user']
please try this in your db.py: db.define_table('company', Field('company_name'), Field('website'), format='%(company_name)s') auth.settings.extra_fields['auth_user']=[ Field('gender', 'list:string'), Field('address', 'text'), Field('zip'), Field('city'), Field('country'), Field('phone'), Field('company', 'reference company')] auth.define_tables(username=False, signature=True) -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: auth.settings.extra_fields['auth_user']
What error message do you expect? On Wednesday, 3 April 2013 09:44:59 UTC-5, Domagoj Kovač wrote: > > Hi folks, > > i have a problem. I am using form widget i am trying to customize > registration form. I my model i added > > auth.settings.extra_fields['auth_user'] = [Field('company_id', > 'string',required > =True)] > > in my register.html view i have. > > {{form.custom.widget.company_id['_class'] = 'w70'}} > TvrtkaOdaberite tvrtku > {{=form.custom.widget.company_id}} > > > > when i submit the form i am not receiving any error messages. Am i missing > something? > -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.