django-native-tags
django-native-tags copied to clipboard
decorators.function kills tag library when used as an @ decorator
http://justquick.github.com/django-native-tags/decorators.html shows that this should work:
@decorators.function(takes_context=1, name='item_status_indicator')
def item_status_indicator(context, item):
return "FOO"
It actually causes some sort of failure which silently prevents native tags from loading anything in the same file.
The non-@ syntax works as expected:
def item_status_indicator(context, item):
return "FOO"
item_status_indicator = decorators.function(item_status_indicator, takes_context=True)
Don't forget you can also just set function attributes. Im leaning towards using this approach as I've been doing it a lot.
def item_status_indicator(context, item):
return "FOO"
item_status_indicator.function = 1
item_status_indicator.takes_context = 1
the decorator syntax is going to be deprecated in favor of function attributes for version 0.6. forget importing decorators.
On Sat, May 7, 2011 at 3:34 AM, justquick [email protected] wrote:
the decorator syntax is going to be deprecated in favor of function attributes for version 0.6. forget importing decorators.
Okay, thanks for the heads up. That makes more sense for testing and should keep a couple of those lines from getting so long.
Chris
Bummer, I like the decorator syntax much better.
BTW, it might be a good idea to change the documentation to tell people that the current decorators don't work. I spent a couple of hours today trying to figure out what was wrong before I found this issue.