Always use length to indicate the field 'string' length. requires= is just 
for forms.

Field('brand', length=32)

On Friday, February 22, 2013 7:27:40 AM UTC+1, 黄祥 wrote:
>
> hi,
>
> i found strange things in db populate:
>
> e.g. 
> *#will generate strings more than 32 characters using populate*
> *models/db.py*
> db.define_table('brand',
>     Field('*brand*'),
>     format='%(*brand*)s')
>
> db.brand.brand.requires=[IS_LENGTH(32), IS_NOT_IN_DB(db, 'brand.*brand*')]
>
> *models/db_populate.py*
> from gluon.contrib.populate import populate
> if db(db.auth_user).isempty():
>     populate(db.brand, 30)
> *
> #will generate strings under 32 characters using populate*
> *models/db.py*
> db.define_table('brand',
>     Field('*brand_name*'),
>     format='%(*brand_name*)s')
>
> db.brand.brand.requires=[IS_LENGTH(32), IS_NOT_IN_DB(db, 'brand.*
> brand_name*')]
>
> *models/db_populate.py*
> from gluon.contrib.populate import populate
> if db(db.auth_user).isempty():
>     populate(db.brand, 30)
>
> my question is why only the field name different can affect the different 
> output?
> for summarize :
> expected output < 32 characters : field name must contain _name : for 
> example : brand_name
> unexpected output > 32 characters : field name doesn't contain _name : for 
> example : brand
> i've already test with diferent name for example for field : 
> product&product_name, company&company_name, category&category_name, etc
>

-- 

--- 
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.


Reply via email to