added _mixins to the classes to indicate which all attributes/methods/properties are being mixed in.

This commit is contained in:
Abhinav Sarkar 2009-03-31 15:44:18 +00:00
parent 0a285dd6bf
commit 26e5da0e7b
5 changed files with 23 additions and 1 deletions

View File

@ -424,9 +424,14 @@ def chartable(chart_types):
cls.weekly_chart_list = weekly_chart_list
cls.monthly_chart_list = monthly_chart_list
if not hasattr(cls, '_default_params'):
cls._default_params = _default_params
if not hasattr(cls, '_mixins'):
cls._mixins = []
cls._mixins.extend(['weekly_chart_list', 'monthly_chart_list'])
method_names = [
'get_weekly_%s_chart', 'recent_weekly_%s_chart', 'weekly_%s_chart_list',
'get_monthly_%s_chart', 'recent_monthly_%s_chart', 'monthly_%s_chart_list',
@ -437,7 +442,8 @@ def chartable(chart_types):
for chart_type in chart_types:
for method_name in method_names:
setattr(cls, method_name % chart_type, locals()[method_name % chart_type])
cls._mixins.append(method_name % chart_type)
return cls
return wrapper

View File

@ -46,4 +46,8 @@ def searchable(cls):
if not hasattr(cls, '_search_yield_func'):
cls._search_yield_func = _search_yield_func
if not hasattr(cls, '_mixins'):
cls._mixins = []
cls._mixins.append('search')
return cls

View File

@ -31,4 +31,8 @@ def sharable(cls):
if not hasattr(cls, '_default_params'):
cls._default_params = _default_params
if not hasattr(cls, '_mixins'):
cls._mixins = []
cls._mixins.append('share')
return cls

View File

@ -40,6 +40,10 @@ def shoutable(cls):
cls.recent_shout = recent_shout
if not hasattr(cls, '_default_params'):
cls._default_params = _default_params
if not hasattr(cls, '_mixins'):
cls._mixins = []
cls._mixins.extend(['shouts', 'recent_shout'])
return cls

View File

@ -73,5 +73,9 @@ def taggable(cls):
cls.remove_tag = remove_tag
if not hasattr(cls, '_default_params'):
cls._default_params = _default_params
if not hasattr(cls, '_mixins'):
cls._mixins = []
cls._mixins.extend(['tags', 'add_tags', 'remove_tag'])
return cls