django-native-tags icon indicating copy to clipboard operation
django-native-tags copied to clipboard

decorators.function kills tag library when used as an @ decorator

Open acdha opened this issue 13 years ago • 4 comments

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)

acdha avatar Apr 28 '11 22:04 acdha

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

justquick avatar May 03 '11 03:05 justquick

the decorator syntax is going to be deprecated in favor of function attributes for version 0.6. forget importing decorators.

justquick avatar May 07 '11 07:05 justquick

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

acdha avatar May 07 '11 12:05 acdha

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.

timmfin avatar Jul 27 '11 14:07 timmfin