Understood - thanks for clarifying. Best, S
> No, it's correct. As I said it uses introspection to see what args are
> there. If your function takes 1 arg, it will be the request. If it
> takes 2 or more args the first two will be context and request in that
> order. You need to be aware of this if you try to do (request, *args)
> because the first arg will be context and args[0] will be request.
> On Wed, Oct 31, 2012 at 12:07 PM, Simon <simonya...@me.com> wrote:
>> Thanks Michael
>> Is the example below given in #defining-a-view-callable-as-a-class
>> incorrect?
>> I.e. ``request`` is a context-object because it is the first-position arg.
>> from pyramid.response import Response
>> class MyView(object):
>> def __init__(self, request):
>> self.request = request
>> def __call__(self):
>> return Response('hello')
>> On Wednesday, October 31, 2012 4:07:42 PM UTC, Michael Merickel wrote:
>>> They are called positionally via introspection and not by name. The
>>> calling convention is here:
>>> http://pyramid.readthedocs.org/en/latest/narr/views.html#alternate-vi...
>>> On Wed, Oct 31, 2012 at 11:02 AM, Simon Yarde <simon...@me.com> wrote:
>>>> Docs say you should expect to handle a request argument in a
>>>> view-callable class.
>>>> http://pyramid.readthedocs.org/en/latest/narr/views.html#defining-a-v...
>>>> But I found I was getting a context object for the request arg.
>>>> Does this mean context and request are being passed (in that order) as
>>>> positional args, rather can keywords?
>>>> I know I can just reverse the order so context is first - just asking if
>>>> there is anything wrong with below code that would cause this, or this is
>>>> view-callables are called this way for any reason?
>>>> class SomeView():
>>>> """
>>>> """
>>>> def __init__(self,
>>>> request, # called positionally?
>>>> context, # ..
>>>> *args,
>>>> **kwargs
>>>> ):
>>>> print('"request" is {0}'.format(request.__class__))
>>>> print('"context" is {0}'.format(context.__class__))
>>>> "request" is <class 'pyramid.traversal.DefaultRootFactory'>
>>>> "context" is <class 'pyramid.util.Request'>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "pylons-discuss" group.
>>>> To post to this group, send email to pylons-...@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> pylons-discus...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/pylons-discuss?hl=en.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "pylons-discuss" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/pylons-discuss/-/XfRjxah4XjcJ.
>> To post to this group, send email to pylons-discuss@googlegroups.com.
>> To unsubscribe from this group, send email to
>> pylons-discuss+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/pylons-discuss?hl=en.
> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to pylons-discuss+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.