Ticket #1718: template_params_1_0.patch
| File template_params_1_0.patch, 2.6 kB (added by chrisz, 5 months ago) |
|---|
-
meta.py
old new 5 5 from new import instancemethod 6 6 from itertools import ifilter, count 7 7 from turbogears import validators 8 from turbogears.util import setlike 8 9 from formencode.schema import Schema 9 10 10 11 try: 11 12 set 12 except NameError: 13 except NameError: # Python 2.3 13 14 from sets import Set as set 14 15 15 16 __all__ = ["MetaWidget", "load_kid_template"] … … 28 29 DeprecationWarning, 2) 29 30 # Makes sure we get the union of params and member_widgets 30 31 # from all our bases. 31 params _set = set(dct.get('params', []))32 params = setlike(dct.get('params', [])) 32 33 # template_vars has been deprecated 33 34 if 'template_vars' in dct: 34 params _set.update(dct['template_vars'])35 params.add_all(dct['template_vars']) 35 36 warnings.warn( 36 37 "Use of template_vars inside a widget is deprecated, " 37 38 "use params instead. " 38 39 "Note: this warning will be removed once 1.0 is " 39 40 "released and your actual code will stop working.", 40 41 DeprecationWarning, 2) 41 member_widgets _set = set(dct.get('member_widgets', []))42 member_widgets = setlike(dct.get('member_widgets', [])) 42 43 compound = False 43 44 for base in bases: 44 params _set.update(getattr(base, 'params', []))45 params.add_all(getattr(base, 'params', [])) 45 46 if getattr(base, 'compound', False): 46 member_widgets _set.update(getattr(base, 'member_widgets', []))47 member_widgets.add_all(getattr(base, 'member_widgets', [])) 47 48 compound = True 48 for param in params _set:49 for param in params: 49 50 # Swap all params listed at 'params' with a ParamDescriptor 50 51 try: 51 52 dct[param_prefix+param] = dct[param] … … 53 54 except KeyError: 54 55 # declared in a superclass, skip it... 55 56 pass 56 dct['params'] = list(params_set) 57 params = list(params) 58 dct['params'] = params 57 59 #XXX: Remove when deprecation is effective 58 dct['template_vars'] = dct['params']60 dct['template_vars'] = params 59 61 if compound: 60 dct['member_widgets'] = list(member_widgets _set)62 dct['member_widgets'] = list(member_widgets) 61 63 # Pick params_doc from all bases giving priority to the widget's own 62 64 params_doc = {} 63 65 for base in bases: