OK, problem solved, I had typo in local_manager def... Shame on me. ;)

On 16 Sty, 09:54, Jarek Zgoda <[email protected]> wrote:
> I do not have any rules defined statically, I use expose() decorator
> from tutorial:
>
> url_map = Map()
>
> def expose(rule, **kw):
>     def decorate(f):
>         kw['endpoint'] = f.__name__
>         url_map.add(Rule(rule, **kw))
>         return f
>     return decorate
>
> The view code is included in my 1st post, only the @expose('/check/')
> is missing.
>
> This is the relevant part of manage.py:
>
> def make_app():
>     root = os.path.dirname(__file__)
>     from application import Updater
>     return Updater('sqlite:////%s/updater.sqlite' % root)
>
> action_runserver = script.make_runserver(make_app, use_reloader=True)
>
> I already posted the __call__() method, here is complete class for
> application (with ClosingIterator stuff already removed):
>
> class Updater(object):
>
>     def __init__(self, db_uri):
>         local.application = self
>         self.database_engine = create_engine(db_uri,
> convert_unicode=True)
>
>     def __call__(self, environ, start_response):
>         local.application = self
>         request = Request(environ)
>         local.url_adapter = adapter = url_map.bind_to_environ(environ)
>         try:
>             endpoint, values = adapter.match()
>             handler = getattr(views, endpoint)
>             response = handler(request, **values)
>         except HTTPException, e:
>             response = e
>         return response(environ, start_response)
>
>     def init_database(self):
>         metadata.create_all(bind=self.database_engine)
>
> In current state, the application does not use any models although the
> code is present (you don't need database to return "1" form view
> function ;)).
>
> On 16 Sty, 00:22, Khaoz <[email protected]> wrote:
>
> > try to post the entire code of your application and your routing
> > rules.
>
> > On 15 jan, 14:08, Jarek Zgoda <[email protected]> wrote:
>
> > > If I remove the ClosingIterator stuff from __call__, everything seems
> > > to work OK (iow., if I return response(environ, start_response)).
>
> > > On 15 Sty, 16:48, Jarek Zgoda <[email protected]> wrote:
>
> > > > I'm trying to make some werkzeug-based application (following steps
> > > > from tutorial). My view function is:
>
> > > > from werkzeug import Response
> > > > def index(request):
> > > >     return Response(u'1', mimetype='text/plain')
>
> > > > I'm getting following traceback on request for the resource. The
> > > > traceback is printed to terminal, but no value is returned to client
> > > > until I stop the server.
>
> > > > Traceback (most recent call last):
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/wsgiref/handlers.py", line 93, in run
> > > >     self.finish_response()
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/wsgiref/handlers.py", line 136, in finish_response
> > > >     self.close()
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/wsgiref/simple_server.py", line 36, in close
> > > >     SimpleHandler.close(self)
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/wsgiref/handlers.py", line 262, in close
> > > >     self.result.close()
> > > >   File "/opt/local/lib/python2.5/site-packages/
> > > > Werkzeug-0.5dev_20090115-py2.5.egg/werkzeug/utils.py", line 1027, in
> > > > close
> > > >     callback()
> > > >   File "/opt/local/lib/python2.5/site-packages/
> > > > Werkzeug-0.5dev_20090115-py2.5.egg/werkzeug/local.py", line 170, in
> > > > cleanup
> > > >     local.__storage__.pop(ident, None)
> > > > AttributeError: 'member_descriptor' object has no attribute 'pop'
> > > > ----------------------------------------
> > > > Exception happened during processing of request from ('127.0.0.1',
> > > > 49611)
> > > > Traceback (most recent call last):
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/SocketServer.py", line 222, in handle_request
> > > >     self.process_request(request, client_address)
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/SocketServer.py", line 241, in process_request
> > > >     self.finish_request(request, client_address)
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/SocketServer.py", line 254, in finish_request
> > > >     self.RequestHandlerClass(request, client_address, self)
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/SocketServer.py", line 522, in __init__
> > > >     self.handle()
> > > >   File "/opt/local/lib/python2.5/site-packages/
> > > > Werkzeug-0.5dev_20090115-py2.5.egg/werkzeug/serving.py", line 87, in
> > > > handle
> > > >     self.get_handler().run(self.server.get_app())
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/wsgiref/handlers.py", line 96, in run
> > > >     self.handle_error()
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/wsgiref/handlers.py", line 309, in handle_error
> > > >     self.finish_response()
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/wsgiref/handlers.py", line 134, in finish_response
> > > >     self.write(data)
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/wsgiref/handlers.py", line 217, in write
> > > >     self.send_headers()
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/wsgiref/handlers.py", line 272, in send_headers
> > > >     if not self.origin_server or self.client_is_modern():
> > > >   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/
> > > > lib/python2.5/wsgiref/handlers.py", line 285, in client_is_modern
> > > >     return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
> > > > TypeError: 'NoneType' object is unsubscriptable
> > > > ----------------------------------------
>
> > > > The application class is untouched one from tutorial, the __call__()
> > > > looks like:
>
> > > >     def __call__(self, environ, start_response):
> > > >         local.application = self
> > > >         request = Request(environ)
> > > >         local.url_adapter = adapter = url_map.bind_to_environ(environ)
> > > >         try:
> > > >             endpoint, values = adapter.match()
> > > >             handler = getattr(views, endpoint)
> > > >             response = handler(request, **values)
> > > >         except HTTPException, e:
> > > >             response = e
> > > >         return ClosingIterator(response(environ, start_response),
> > > > [session.remove, local_manager.cleanup])
>
> > > > version information:
> > > > changeset:   673:603e80a03f8b
> > > > tag:         tip
> > > > user:        mitsuhiko
> > > > date:        Wed Jan 14 15:25:46 2009 +0100
>
> > > > Any help?
>
> > > > Cheers
> > > > J.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pocoo-libs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to