Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 1 and Version 2 of IntroductionToWidgets


Ignore:
Timestamp:
04/22/06 18:47:48 (13 years ago)
Author:
alberto
Comment:

Reminder of a future deprecation. BTW, excellent document! Nice work.

Legend:

Unmodified
Added
Removed
Modified
  • IntroductionToWidgets

    v1 v2  
    280280There's a bit going on here: 
    281281 
    282  * We added a class attribute called {{{template_vars}}}.  When TurboGears renders the template, it looks for this attribute. Any attribute names in this list that exist on the template instance will be added to the variables provided to the template.  So at render time, if the template has a {{{with_team}}} attribute, the template will be able to access it. 
     282 * We added a class attribute called {{{template_vars}}} ('''NOTE''' 0.9a5 will call this same attribute {{{params}}}. It will issue a {{{DeprecationWarning}}} to remind you that you should update your code).  When TurboGears renders the template, it looks for this attribute. Any attribute names in this list that exist on the template instance will be added to the variables provided to the template.  So at render time, if the template has a {{{with_team}}} attribute, the template will be able to access it. 
    283283  
    284284 * We added an {{{__init__}}} method that calls the parent class ({{{Widget}}}, in this case), and stores the {{{with_team}}} argument (if any).  Since we don't want to worry about what the base class is, we use Python's {{{super}}} function, and since we don't want to worry about what arguments might be there, we use {{{*args}}} and {{{**kw}}} to pass along any extra positional or keyword arguments to the base class.