On 2/11/10 8:39 AM, Andrey Popp wrote:
> Can't sign up in repoze.bfg trac due to invisible captcha, so will
> report bug here for now.
>
> I am using repoze.bfg 1.2 and started with bfg_starter template. Then
> in configure.zcml I've changed traversal dispatching to URL mapping:
>
>    <route
>      name="main"
>      path="/"
>      view=".views.my_view"
>      renderer="templates/mytemplate.pt"
>      />
>
> And redefine my_view in terms of callable class:
>
> class my_view(object):
>
>      def __init__(self, request, context):
>          pass
>
>      def __call__(self):
>          return {'project':'test'}
>
> or function:
>
> def my_view(request, context):
>      return {'project':'test'}
>
> That actions give long traceback on application start, i have attached
> it to this email. This is because inspect.getargspec call inside
> repoze.bfg.configuration.requestonly function returns default=None, so
> we can't check it length. If I make __init__(self, request,
> context=None) all becomes good, but documentation suggests me I may
> not to use context arg as keyword arg. So this is either bug in docs
> or in requestonly, isn't it?

I think you just have the order of arguments reversed for both the class and 
the function.  It should be:

def my_view(context, request):
     ...

   or

class my_view(object):
     def __init__(self, context, request):
         ....

     def __call__(self):
         ....

This is documented at 
http://docs.repoze.org/bfg/1.2/narr/views.html#request-and-context-view-callable-definitions

Your intuition is right though.  If I had it to do all over again, I would 
probably reverse those two arguments.

- C

-- 
Chris McDonough
Agendaless Consulting, Fredericksburg VA
The repoze.bfg Web Application Framework Book: http://bfg.repoze.org/book
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to