> Let's imagine a view "pets":
> 
> from webob import Response
> 
> def pets(context, request):
>      return Response ('OK')
> 
> when a URL comes in that is for a paricular pet:
> 
> from webob import Response
> 
> 
> def pets(context, request):
>      if request.subpath:
>         petnum = request.subpath[0]
>         return Response('OK with petnum %s' % petnum)
>      return Response ('OK')
> 
> when a URL comes in with a particular action for a pet:
> 
> from webob import Response
> from repoze.bfg.chameleon_zpt import render_template_to_response
> 
> def pets(context, request):
>      if len(request.subpath) == 1:
>         petnum = request.subpath[0]
>         return Response('OK with petnum %s' % petnum)
>      elif request.subpath == 2:
>         petnum, action = request.subpath
>         return render_request_to_response('%s.html' % action,
>                                           petnum = petnum)
>      return Response ('OK')
> 
> That's at least one way to handle it.  Another way is to register a view for 
> "edit.html" against a "Pet" model.

Thanks Chris, the latter is what I was thinking of. So, another
question, can the *context* object be a *class* instead of an instance?

IE, can the class Pet be the context, such that a class level
__getitem__ returns the actual instance I'm after, and edit becomes the
view ( action ).

Iain

_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to