Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Dev

Who uses request.getPositionalArguments()?

 

 

Zope dev RSS feed   Index | Next | Previous | View Threaded


ws at gocept

Jun 9, 2009, 6:45 AM

Post #1 of 6 (705 views)
Permalink
Who uses request.getPositionalArguments()?

Hello,

I've stumbled over this by accident, but it seems that
getPositionalArguments() in zope.publisher.base.BaseRequest
always returns an empty value (at least, there are no tests in which
it has a non-empty value), and it is also not overridden by any of the
request subclasses in zope.publisher.

I still haven't quite wrapped my head around the whole publishing
machinery, but this strikes me as a little strange, nonetheless.

Could somebody enlighten me why this is so?

Thanks,
Wolfgang
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


srichter at cosmos

Jun 9, 2009, 7:02 AM

Post #2 of 6 (668 views)
Permalink
Re: Who uses request.getPositionalArguments()? [In reply to]

On Tuesday 09 June 2009, Wolfgang Schnerring wrote:
> I've stumbled over this by accident, but it seems that
> getPositionalArguments() in zope.publisher.base.BaseRequest
> always returns an empty value (at least, there are no tests in which
> it has a non-empty value), and it is also not overridden by any of the
> request subclasses in zope.publisher.
>
> I still haven't quite wrapped my head around the whole publishing
> machinery, but this strikes me as a little strange, nonetheless.
>
> Could somebody enlighten me why this is so?

I think this may be a remnant of Zope 2's version of the publisher. The method
should be used in mapply() to provide the correct arguments to the method to
be called at the end of traversal, but these days we usually do not implement
methods that expect any arguments, in fact the common case is this:

class View(BrowserView):

def __call__(self):
return ...

Regards,
Stephan
--
Entrepreneur and Software Geek
Google me. "Zope Stephan Richter"
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


ws at gocept

Jun 9, 2009, 7:12 AM

Post #3 of 6 (669 views)
Permalink
Re: Who uses request.getPositionalArguments()? [In reply to]

* Stephan Richter <srichter [at] cosmos> [2009-06-09 10:02]:
> On Tuesday 09 June 2009, Wolfgang Schnerring wrote:
> > I've stumbled over this by accident, but it seems that
> > getPositionalArguments() in zope.publisher.base.BaseRequest
> > always returns an empty value (at least, there are no tests in which
> > it has a non-empty value), and it is also not overridden by any of the
> > request subclasses in zope.publisher.
>
> I think this may be a remnant of Zope 2's version of the publisher. The method
> should be used in mapply() to provide the correct arguments to the method to
> be called at the end of traversal, but these days we usually do not implement
> methods that expect any arguments, in fact the common case is this:
>
> class View(BrowserView):
>
> def __call__(self):
> return ...

But even the case with arguments
def __call__(self, foo, bar):
is handled directly by mapply() (which does introspection and then
looks in the request for the names it found) -- which made
getPositionalArguments seem all the more superfluous to me...

Wolfgang
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


ct at gocept

Jun 9, 2009, 7:36 AM

Post #4 of 6 (668 views)
Permalink
Re: Who uses request.getPositionalArguments()? [In reply to]

Hi,

On Tue, 2009-06-09 at 10:02 -0400, Stephan Richter wrote:
> On Tuesday 09 June 2009, Wolfgang Schnerring wrote:
> > I've stumbled over this by accident, but it seems that
> > getPositionalArguments() in zope.publisher.base.BaseRequest
> > always returns an empty value (at least, there are no tests in which
> > it has a non-empty value), and it is also not overridden by any of the
> > request subclasses in zope.publisher.
> >
> > I still haven't quite wrapped my head around the whole publishing
> > machinery, but this strikes me as a little strange, nonetheless.
> >
> > Could somebody enlighten me why this is so?
>
> I think this may be a remnant of Zope 2's version of the publisher. The method
> should be used in mapply() to provide the correct arguments to the method to
> be called at the end of traversal, but these days we usually do not implement
> methods that expect any arguments, in fact the common case is this:
>
> class View(BrowserView):
>
> def __call__(self):
> return ...

Actually, I find myself sometimes doing this:

class View(object):

def foo(self, x, y)
return x+y

def bar(self, a, b):
return x*y

<browser:page
name="foo"
class="View"
attribute="foo"
/>

<browser:page
name="bar"
class="View"
attribute="bar"
/>

It's a convenience thing but it pops up here and there.

Christian

--
Christian Theune · ct [at] gocept
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 7 · fax +49 345 1229889 1
Zope and Plone consulting and development
Attachments: signature.asc (0.19 KB)


jim at zope

Jun 9, 2009, 8:29 AM

Post #5 of 6 (669 views)
Permalink
Re: Who uses request.getPositionalArguments()? [In reply to]

On Jun 9, 2009, at 9:45 AM, Wolfgang Schnerring wrote:

> Hello,
>
> I've stumbled over this by accident, but it seems that
> getPositionalArguments() in zope.publisher.base.BaseRequest
> always returns an empty value (at least, there are no tests in which
> it has a non-empty value),

Wrong on both counts, although the relevant tests, of xmlrpc handling,
are spread over multiple packages, so finding relevant tests is rather
hard, especially if you don't know that it's related to xml-rpc. :(

(Our approach to handling xml-rpc turned out to be way to complicated.)

> and it is also not overridden by any of the
> request subclasses in zope.publisher.
>
> I still haven't quite wrapped my head around the whole publishing
> machinery, but this strikes me as a little strange, nonetheless.
>
> Could somebody enlighten me why this is so?

This is needed for xml-rpc, which passes arguments positionally.
getPositionalArguments returns self._args.
XMLRPCRequest's processInputs method sets self._args to the arguments
parsed from an xmlrpc request.

Jim

--
Jim Fulton
Zope Corporation


_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )


ws at gocept

Jun 10, 2009, 3:41 AM

Post #6 of 6 (663 views)
Permalink
Re: Who uses request.getPositionalArguments()? [In reply to]

* Jim Fulton <jim [at] zope> [2009-06-09 11:29]:
> On Jun 9, 2009, at 9:45 AM, Wolfgang Schnerring wrote:
>> I've stumbled over this by accident, but it seems that
>> getPositionalArguments() in zope.publisher.base.BaseRequest
>> always returns an empty value (at least, there are no tests in which
>> it has a non-empty value),
>
> Wrong on both counts, although the relevant tests, of xmlrpc handling, are
> spread over multiple packages, so finding relevant tests is rather hard,
> especially if you don't know that it's related to xml-rpc. :(

Also, the test_xmlrpcrequest in zope.publisher does not use
getPositionalArguments but rather checks _args directly.
(I've just updated that to make it a little more clear)

Thanks for the heads-up,
Wolfgang
_______________________________________________
Zope-Dev maillist - Zope-Dev [at] zope
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Zope dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.