Hi there,

I've just downloaded the 1.2 alpha and started testing it with one of
my projects. For the most part it works well, however I've hit a bit
of a snag due to the changes to the user_passes_test decorator in
django.contrib.auth.decorators.

I have a some code which follows the paradigm of:

    class Site(object):
        ...
        def get_urls(self):
            ...
            return urlpatterns

so that I can deploy multiple instances (I'm actually extending
django.contrib.admin.sites.AdminSite) of an app and use namespaced
urls.

Now, with 1.1 I had an index view method which was decorated with
login_required:

    class Site(object):
        ...
        @login_required
        def index(self, request):
            return HttpResponse('')

In a template tag I've been determining which instance of my Site I've
been using with code like this:

    func, args, kwargs = resolve('/path/')
    instance = func.view_func.im_self

However in 1.2, this fails because there is no 'im_self' attribute.
I've been poking around and discovered that (in the shell) I can get
the site instance with:

    func, args, kwargs = resolve('/path/')
    instance = func.func_closure[0].cell_contents

However when I replace my 1.1 version of the code with this recipe
above and try to access that view with the development server running
1.2 I get:

    Original Traceback (most recent call last):
      File "/path/to/my/templatetag.py", line XX, in
determine_instance_for_path
        instance = func.func_closure[0].cell_contents
    TypeError: 'NoneType' object is unsubscriptable

I must confess I don't know what a 'cell' is, haven't heard that
python terminology before, so I will continue to look this up.

However I thought I'd drop a line here since this isn't in the
backwards incompatible changes listed for 1.2 (I guess I'm possibly
already playing with voodoo, view_func isn't really documented so it's
my own fault I guess).

On the other hand, if this is a bug, I'd be willing to work with
someone to find a solution.

Regards,
Gary
-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.


Reply via email to