Hi,
I'm trying to use sprox together with cherrypy and mako, but I'm stuck because of the initialization of the underlying ToscaWidgets.
Using sprox, like it is described in the tutorials on
http://sprox.org/, brings always to the following error:
TypeError: No object (name: ToscaWidgets per-request storage) has been registered for this thread
It seems that the tw is not initialized and so it can not be used by sprox. I started reading the tw documentation and found some sample code to get started with tw on cherrypy:
I only used the wrapper function from the sample
def tw_middleware(app):
from tw.api import make_middleware
conf = {'toscawidgets.framework.default_view':'genshi',
'toscawidgets.middleware.inject_resources': 'true'}
return make_middleware(app, conf, stack_registry=True)
adapted it for mako:
def tw_middleware(app):
from tw.api import make_middleware
conf = {'toscawidgets.framework.default_view' : 'mako',
'toscawidgets.middleware.inject_resources': True}
print "tw_middleware called"
return make_middleware(app, conf, stack_registry=True)
and put the following code in my cherrypy configuration:
"toscawidgets.on": True,
'wsgi.pipeline': [('tw', tw_middleware)],
But I always get the same error,...
print registration_form()
File "/usr/local/lib/python2.7/site-packages/sprox/viewbase.py", line 113, in __call__
return self.display(*args, **kw)
File "/usr/local/lib/python2.7/site-packages/sprox/viewbase.py", line 119, in display
return self.__widget__.display(*args, **kw)
File "/usr/local/lib/python2.7/site-packages/sprox/viewbase.py", line 108, in __widget__
self.___widget__ = self.__base_widget_type__(**self.__widget_args__)
File "/usr/local/lib/python2.7/site-packages/sprox/viewbase.py", line 123, in __widget_args__
return self._do_get_widget_args()
File "/usr/local/lib/python2.7/site-packages/sprox/formbase.py", line 236, in _do_get_widget_args
d = super(FormBase, self)._do_get_widget_args()
File "/usr/local/lib/python2.7/site-packages/sprox/viewbase.py", line 126, in _do_get_widget_args
widget_dict = self._do_get_field_widgets(self.__fields__)
File "/usr/local/lib/python2.7/site-packages/sprox/formbase.py", line 285, in _do_get_field_widgets
widgets = super(FormBase, self)._do_get_field_widgets(fields)
File "/usr/local/lib/python2.7/site-packages/sprox/viewbase.py", line 250, in _do_get_field_widgets
widgets[field_name] = field_widget_type(**field_widget_args)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tw/core/util.py", line 161, in wrapper
base.__dict__[post_name](self, *args, **kw)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tw/core/base.py", line 403, in post_init
self._collect_resources()
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tw/core/base.py", line 384, in _collect_resources
oset.add_all(chain(*[c._resources for c in self.javascript]))
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tw/core/util.py", line 311, in add_all
self.add(item)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tw/core/util.py", line 306, in add
if item not in self:
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tw/core/resources.py", line 444, in __eq__
return getattr(other, "link", None) == self.link
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tw/core/resources.py", line 433, in _get_link
return tw.framework.url(url or '')
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tw/mods/base.py", line 114, in url
prefix = self.request_local.environ['toscawidgets.prefix']
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tw/core/registry.py", line 144, in __getattr__
return getattr(self._current_obj(), attr)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tw/core/registry.py", line 201, in _current_obj
'thread' % self.____name__)
TypeError: No object (name: ToscaWidgets per-request storage) has been registered for this thread
--- SNIP ---
Is anybody out there who is already using sprox on top of cherrypy?
Thanks + bye, Holger