Changes between Version 22 and Version 23 of DeveloperGuidelinesS3Framework


Ignore:
Timestamp:
05/20/09 20:56:58 (13 years ago)
Author:
Fran Boon
Comment:

Python style

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelinesS3Framework

    v22 v23  
    5353List output are made more functional by this .represent 'widget':
    5454{{{
    55 def shn_list_item(table,resource,action,display='table.name',extra=None):
     55def shn_list_item(table, resource, action, display='table.name', extra=None):
    5656    if extra:
    57         items=DIV(TR(TD(A(eval(display),_href=t2.action(resource,[action,table.id]))),TD(eval(extra))))
     57        items = DIV(TR(TD(A(eval(display), _href=t2.action(resource, [action, table.id]))), TD(eval(extra))))
    5858    else:
    59         items=DIV(A(eval(display),_href=t2.action(resource,[action,table.id])))
     59        items = DIV(A(eval(display), _href=t2.action(resource, [action, table.id])))
    6060    return DIV(*items)
    6161}}}
    6262This is called in {{{models/__db.py}}} in the RESTlike Controller:
    6363{{{
    64 db.person.represent=lambda table:shn_list_item(table,resource='person',action='display',display='table.full_name')
     64db.person.represent = lambda table:shn_list_item(table, resource='person', action='display', display='table.full_name')
    6565}}}
    6666
    6767Form labels can be set in a translatable manner using:
    68    {{{db.table.field.label=T("label")}}}
     68   {{{db.table.field.label = T("label")}}}
    6969
    7070Form field can be made to use a TEXTAREA by marking the field as being type 'text':
    71    {{{db.Field('field','text'),}}}
     71   {{{db.Field('field', 'text'),}}}
    7272
    7373Form field can be made to use a SELECT dropdown by setting the field as a lookup to another table...linked to the 'id' field to allow [wiki:DeveloperGuidelinesDatabaseSynchronization Database Synchronization], but displaying a more user-friendly field (such as 'name'):
    7474{{{
    75 db.Field('field',db.othertable),
     75db.Field('field', db.othertable),
    7676
    77 db.table.field.requires=IS_NULL_OR(IS_IN_DB(db,'othertable.id','othertable.name'))
     77db.table.field.requires = IS_NULL_OR(IS_IN_DB(db, 'othertable.id', 'othertable.name'))
    7878}}}
    7979
    8080Form field being required can be marked using:
    81    {{{db.table.field.comment=SPAN("*",_class="req")}}}
     81   {{{db.table.field.comment = SPAN("*", _class="req")}}}
    8282
    8383Help for a form field can be set using:
    84    {{{A(SPAN("[Help]"),_class="tooltip",_title=T("Help Title|This is what this <a href='http://wikipedia.org/Field' target=_blank>field</a> is for."))}}}
     84   {{{A(SPAN("[Help]"), _class="tooltip", _title=T("Help Title|This is what this <a href='http://wikipedia.org/Field' target=_blank>field</a> is for."))}}}
    8585
    8686Different Flash styles can be set via:
    8787{{{
    88 session.error=T("Unsupported format!")
    89 redirect(URL(r=request,f=resource))
     88session.error = T("Unsupported format!")
     89redirect(URL(r=request, f=resource))
    9090}}}
    9191or (in a Multiple Table form.accepts):
    9292{{{
    93 response.error=T("Form invalid!")
     93response.error = T("Form invalid!")
    9494}}}
    9595Supported styles are:
     
    105105
    106106If these settings are required by all Views then can patch the session to see them in {{{models/_db.py}}}'s {{{shn_sessions()}}}.[[BR]]
    107 e.g. session.s3.debug & session.s3.self_registration are made available to the default {{{layout.html}}} this way.
     107e.g. session.s3.debug is made available to the default {{{layout.html}}} this way.
    108108
    109109If you wish to clean out all settings to import afresh, then close down Web2Py & delete all files from {{{/databases}}})