On Saturday, January 4, 2014 7:15:58 PM UTC+7, Massimo Di Pierro wrote:
>
> 2) Tables are only archived if they have a Field('modified_on','datetime') 
> such as created by the signature.
> Without it you do not know when changes are made and versioning is useless.
>

it's make sense and make me clear about signature and record versioning, 
thank you so much for your detail explaination, massimo
 

>
> 1) Does this work?
>
> # on_define_bank
> def on_define_bank(table): 
> pass
>
> # create table : bank
> db.define_table('bank', 
> Field('bank',notnull=True), 
> auth.signature,
> on_define = on_define_bank, 
> format = '%(bank)s')
>
> Whats is  on_define_bank supposed to do?
>

i usually put the lazy table in on_define, i've seen in this forum that the 
lazy can be achieved using on_define. is it recommended or not for using 
on_define to put the lazy table? of course your code to put the lazy in the 
field constructor is also work, but sometime, if application getting big or 
complex, it's make my head spinning so i manage the lazy on the on_define.
e.g. 1. lazy in on_define
# on_define_bank
def on_define_bank(table): 
# label
table.bank.label = T('Bank')
table.ebanking.label = T('eBanking')
# notnull
table.bank.notnull = True
# represent
table.ebanking.represent = lambda ebanking, field: \
A(ebanking, _title=T("eBanking"), _target="_blank", _href="%s" % ebanking)
# required
table.bank.required = True
# requires
table.bank.requires = IS_NOT_IN_DB(db, table.bank)
# unique
table.bank.unique = True

# create table : bank
db.define_table('bank', 
Field('bank'), 
Field('ebanking'), 
auth.signature, 
on_define = on_define_bank, 
format = '%(bank)s')

e.g. 2. lazy in the field constructor that make my head spinning
# create table : bank
db.define_table('bank', 
Field('bank', label = T('Bank'), notnull = True, required = True, requires 
= IS_NOT_IN_DB(db, 'bank.bank'), unique = True), 
Field('ebanking', label = T('eBanking'), represent = lambda ebanking, 
field: A(ebanking, _title=T("eBanking"), _target="_blank", _href="%s" % 
ebanking) ), 
auth.signature, 
format = '%(bank)s')

another way around, of course i can put it the field constructor outside of 
the define table and not using the on_define function, but sometime when 
the application getting bigger and more complex i need the same field type 
and name so that i can copas (copy paste) without replacing the table name.
e.g. 3. lazy table outside the define table without on define.
# create table : bank
db.define_table('bank', 
Field('bank'), 
Field('ebanking'), 
auth.signature, 
format = '%(bank)s')

# label
db.bank.bank.label = T('Bank')
db.bank.ebanking.label = T('eBanking')
# notnull
db.bank.bank.notnull = True
# represent
db.bank.ebanking.represent = lambda ebanking, field: \
A(ebanking, _title=T("eBanking"), _target="_blank", _href="%s" % ebanking)
# required
db.bank.bank.required = True
# requires
db.bank.bank.requires = IS_NOT_IN_DB(db, 'bank.bank')
# unique
db.bank.bank.unique = True

don't know which is the recommended way (between the 3 examples above) in 
term of make the lazy table in web2py. any suggestion or explaination about 
this?

thanks so much and best regards,
stifan

-- 
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/groups/opt_out.

Reply via email to