Steve, thanks for the guidance.  I'm heading in the right direction
with a better understanding of the concept, but still stymied by the
urls error.  Not seeing the connection between adding a decorator and
having trouble with urls.py.  I'll get there.  Dan

On Aug 4, 11:31 am, Steve Holden <holden...@gmail.com> wrote:
> On 8/4/2010 10:52 AM, Dan Gentry wrote:
>
>
>
>
>
> > When I attempt to use the decorator logic, the view becomes this:
>
> > views.py
> > @institution_required
> > def list_type(request):
>
> >     inst_id=request.session.get('inst_id',None)
>
> >     queryset = RecordType.objects.filter(institution=inst_id)
> >     return object_list(request, queryset, paginate_by = 12)
>
> > I don't make any changes to urls.py, but the error is
> > "TemplateSyntaxError at /index
> > Caught ImproperlyConfigured while rendering: The included urlconf
> > person.urls doesn't have any patterns in it"
> > However, when I take out the decorator, all of the urls work as
> > expected.
>
> > urls.py does import * from views.py
>
> Your decorator takes two arguments - its signature is
>
>   institution_required(fn, redirect_field_name=REDIRECT_FIELD_NAME)
>
> But the decorator mechanism only allows you to specify one argument (the
> decorated function). There is no way to specify anything OTHER than the
> default value for the redirect_field_name argument ...
>
> Therefore if you want to use decorators for this application you will
> have to write something more complex still: a function that takes a
> single redirect_field_name argument and /returns a decorator/ that can
> be applied to views. Then you would call it as
>
> @institution_required("Some_field_name")
> def list_type(request):
>   ...
>
> Your call to institution_required should return a decorator. That takes
> the decorated function as its single argument and returns the decorated
> function. This is getting a little complex for a beginner.
>
> regards
>  Steve
> --
> I'm no expert.
> "ex" == "has-been"; "spurt" == "drip under pressure"
> "expert" == "has-been drip under pressure".

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

Reply via email to