<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: WebOb decorator</title>
	<atom:link href="http://blog.ianbicking.org/2009/05/22/webob-decorator/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ianbicking.org/2009/05/22/webob-decorator/</link>
	<description></description>
	<pubDate>Thu, 11 Mar 2010 04:56:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: louis vuitton</title>
		<link>http://blog.ianbicking.org/2009/05/22/webob-decorator/comment-page-1/#comment-112487</link>
		<dc:creator>louis vuitton</dc:creator>
		<pubDate>Tue, 16 Jun 2009 08:02:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ianbicking.org/?p=122#comment-112487</guid>
		<description>i think is right,instead it adds an attribute .wsgi_app which is WSGI application associated with the function,Are there more cases to justify extra parameter passing to wrapped methods? For this one having a separate method looks like the correct solution.</description>
		<content:encoded><![CDATA[<p>i think is right,instead it adds an attribute .wsgi_app which is WSGI application associated with the function,Are there more cases to justify extra parameter passing to wrapped methods? For this one having a separate method looks like the correct solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Bicking</title>
		<link>http://blog.ianbicking.org/2009/05/22/webob-decorator/comment-page-1/#comment-109908</link>
		<dc:creator>Ian Bicking</dc:creator>
		<pubDate>Mon, 01 Jun 2009 17:45:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ianbicking.org/?p=122#comment-109908</guid>
		<description>It occurs to me with WSGI 2 that it will be relatively easy to stuff both WSGI and the request/response calling convention into `__call__`.  And maybe it's worth doing that even for WSGI 1... it's just a simple type check, really, and an optional `start_response` argument in WSGI 1 (gone from WSGI 2)</description>
		<content:encoded><![CDATA[<p>It occurs to me with WSGI 2 that it will be relatively easy to stuff both WSGI and the request/response calling convention into <code>__call__</code>.  And maybe it&#8217;s worth doing that even for WSGI 1&#8230; it&#8217;s just a simple type check, really, and an optional <code>start_response</code> argument in WSGI 1 (gone from WSGI 2)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Bicking</title>
		<link>http://blog.ianbicking.org/2009/05/22/webob-decorator/comment-page-1/#comment-109367</link>
		<dc:creator>Ian Bicking</dc:creator>
		<pubDate>Thu, 28 May 2009 22:07:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ianbicking.org/?p=122#comment-109367</guid>
		<description>Also you could [pretend you are Django](http://svn.pythonpaste.org/Paste/WebOb/branches/ianb-decorator-experiment/webob/django.py)</description>
		<content:encoded><![CDATA[<p>Also you could <a href="http://svn.pythonpaste.org/Paste/WebOb/branches/ianb-decorator-experiment/webob/django.py">pretend you are Django</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Bicking</title>
		<link>http://blog.ianbicking.org/2009/05/22/webob-decorator/comment-page-1/#comment-109360</link>
		<dc:creator>Ian Bicking</dc:creator>
		<pubDate>Thu, 28 May 2009 21:00:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ianbicking.org/?p=122#comment-109360</guid>
		<description>Well, here's an example of a few minor things: http://bitbucket.org/ianb/pickywiki/src/tip/pickywiki/reqobj.py

There's several class variables on Request and Response that are intended for customization, and any WSGI extension could potentially be represented with a method on the request.</description>
		<content:encoded><![CDATA[<p>Well, here&#8217;s an example of a few minor things: <a href="http://bitbucket.org/ianb/pickywiki/src/tip/pickywiki/reqobj.py" rel="nofollow">http://bitbucket.org/ianb/pickywiki/src/tip/pickywiki/reqobj.py</a></p>

<p>There&#8217;s several class variables on Request and Response that are intended for customization, and any WSGI extension could potentially be represented with a method on the request.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sergey Schetinin</title>
		<link>http://blog.ianbicking.org/2009/05/22/webob-decorator/comment-page-1/#comment-109359</link>
		<dc:creator>Sergey Schetinin</dc:creator>
		<pubDate>Thu, 28 May 2009 20:55:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ianbicking.org/?p=122#comment-109359</guid>
		<description>I wonder how do you customize the Request subclasses? I mean what do you put there that wouldn't fit in webob itself -- I can't remember if I ever needed something like that.</description>
		<content:encoded><![CDATA[<p>I wonder how do you customize the Request subclasses? I mean what do you put there that wouldn&#8217;t fit in webob itself &#8212; I can&#8217;t remember if I ever needed something like that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Bicking</title>
		<link>http://blog.ianbicking.org/2009/05/22/webob-decorator/comment-page-1/#comment-109357</link>
		<dc:creator>Ian Bicking</dc:creator>
		<pubDate>Thu, 28 May 2009 20:33:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ianbicking.org/?p=122#comment-109357</guid>
		<description>Metaclasses just scare the heck out of me for something like this.

Another detail that has made some things harder is that I like custom Request/Response subclasses, and I want the decorator to be at least somewhat orthogonal to those classes, so you have to have some way to add parameters to these things.

One thing that I may have over-thought is whether something like `.wsgi_app` should just be a very straight class method for this case.</description>
		<content:encoded><![CDATA[<p>Metaclasses just scare the heck out of me for something like this.</p>

<p>Another detail that has made some things harder is that I like custom Request/Response subclasses, and I want the decorator to be at least somewhat orthogonal to those classes, so you have to have some way to add parameters to these things.</p>

<p>One thing that I may have over-thought is whether something like <code>.wsgi_app</code> should just be a very straight class method for this case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sergey Schetinin</title>
		<link>http://blog.ianbicking.org/2009/05/22/webob-decorator/comment-page-1/#comment-109353</link>
		<dc:creator>Sergey Schetinin</dc:creator>
		<pubDate>Thu, 28 May 2009 19:44:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ianbicking.org/?p=122#comment-109353</guid>
		<description>Or, one could make the *class object itself* a WSGI app via baseclass:

    from pasteob import *

    class PerRequest(object):
        class __metaclass__(type):
            @webob_wrap
            def __call__(cls, req):
                return type.__call__(cls, req)()

        def __init__(self, req):
            self.req = req

    #### 

    class MyClass(PerRequest):
        def __call__(self):
            return Response('whatever')

    print Request.blank('/').get_response(MyClass)

This can't get any more concise and this wasn't even a design consideration for webob_wrap. 

[Sorry for stalking your webob.dec effort, I hope this feedback is not entirely unwanted.]</description>
		<content:encoded><![CDATA[<p>Or, one could make the <em>class object itself</em> a WSGI app via baseclass:</p>

<pre><code>from pasteob import *

class PerRequest(object):
    class __metaclass__(type):
        @webob_wrap
        def __call__(cls, req):
            return type.__call__(cls, req)()

    def __init__(self, req):
        self.req = req

#### 

class MyClass(PerRequest):
    def __call__(self):
        return Response('whatever')

print Request.blank('/').get_response(MyClass)
</code></pre>

<p>This can&#8217;t get any more concise and this wasn&#8217;t even a design consideration for webob_wrap. </p>

<p>[Sorry for stalking your webob.dec effort, I hope this feedback is not entirely unwanted.]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Bicking</title>
		<link>http://blog.ianbicking.org/2009/05/22/webob-decorator/comment-page-1/#comment-109344</link>
		<dc:creator>Ian Bicking</dc:creator>
		<pubDate>Thu, 28 May 2009 17:16:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ianbicking.org/?p=122#comment-109344</guid>
		<description>I've added another feature, `wsgify.instantiate` which can be used to create controller-like classes, something like:

    class MyClass(object):
        def __init__(self, req):
            self.req = req
        def __call__(self):
            return Response('whatever')
        wsgi_app = wsgify.instantiator()

Then `MyClass.wsgi_app` is a WSGI application that will instantiate the class for every call.  You could then create a web.py-style class like this:

    class ByMethod(object):
        def __init__(self, req):
            self.req = req
        def __call__(self):
            method = getattr(self, self.req.method, None)
            if method is None:
                raise exc.HTTPMethodNotAllowed()
            return method()
        wsgi_app = wsgify.instantiator()
    
    class Whatever(ByMethod):
        def GET(self): ...
        def POST(self): ...</description>
		<content:encoded><![CDATA[<p>I&#8217;ve added another feature, <code>wsgify.instantiate</code> which can be used to create controller-like classes, something like:</p>

<pre><code>class MyClass(object):
    def __init__(self, req):
        self.req = req
    def __call__(self):
        return Response('whatever')
    wsgi_app = wsgify.instantiator()
</code></pre>

<p>Then <code>MyClass.wsgi_app</code> is a WSGI application that will instantiate the class for every call.  You could then create a web.py-style class like this:</p>

<pre><code>class ByMethod(object):
    def __init__(self, req):
        self.req = req
    def __call__(self):
        method = getattr(self, self.req.method, None)
        if method is None:
            raise exc.HTTPMethodNotAllowed()
        return method()
    wsgi_app = wsgify.instantiator()

class Whatever(ByMethod):
    def GET(self): ...
    def POST(self): ...
</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Bicking</title>
		<link>http://blog.ianbicking.org/2009/05/22/webob-decorator/comment-page-1/#comment-108958</link>
		<dc:creator>Ian Bicking</dc:creator>
		<pubDate>Tue, 26 May 2009 17:36:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ianbicking.org/?p=122#comment-108958</guid>
		<description>Why was exception handling a mistake?  I've never found the `HTTP*` exceptions to be particularly problematic (at least on this scale -- raising them across WSGI boundaries is bad).</description>
		<content:encoded><![CDATA[<p>Why was exception handling a mistake?  I&#8217;ve never found the <code>HTTP*</code> exceptions to be particularly problematic (at least on this scale &#8212; raising them across WSGI boundaries is bad).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Armin Ronacher</title>
		<link>http://blog.ianbicking.org/2009/05/22/webob-decorator/comment-page-1/#comment-108874</link>
		<dc:creator>Armin Ronacher</dc:creator>
		<pubDate>Tue, 26 May 2009 06:08:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ianbicking.org/?p=122#comment-108874</guid>
		<description>Hi Ian.

Just quickly had a look at the implementation and it seems overly complex to me.  I've had exception handling in an early version of the "Request.application" decorator in Werkzeug as well and it turned out to be a mistake.  It's easier to write a simple try/except than configuring a decorator to handle some exceptions (like 404 not found).

Right now the full implementation is a two liner and works: [Request.application](http://dev.pocoo.org/projects/werkzeug/browser/werkzeug/wrappers.py?rev=788%3A901b6c157194#L162)

I think you're slightly over-engineering your decorator here.</description>
		<content:encoded><![CDATA[<p>Hi Ian.</p>

<p>Just quickly had a look at the implementation and it seems overly complex to me.  I&#8217;ve had exception handling in an early version of the &#8220;Request.application&#8221; decorator in Werkzeug as well and it turned out to be a mistake.  It&#8217;s easier to write a simple try/except than configuring a decorator to handle some exceptions (like 404 not found).</p>

<p>Right now the full implementation is a two liner and works: <a href="http://dev.pocoo.org/projects/werkzeug/browser/werkzeug/wrappers.py?rev=788%3A901b6c157194#L162">Request.application</a></p>

<p>I think you&#8217;re slightly over-engineering your decorator here.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.834 seconds -->
