I originally posted this in toscawidgets-discuss, but, in looking a little further, the error occurs in core.py in Pylons, but, I am not quite sure where to start poking.
>From http://toscawidgets.org/documentation/tw.forms/tutorials/index.html and http://toscawidgets.org/documentation/tw.forms/tutorials/validate_pylons.html, I've followed the tutorials, but, am running into an issue. The following controller: from pylons import request, response, session, tmpl_context from tw.mods.pylonshf import validate from cp.lib.base import BaseController, render import tw.forms as twf movie_form = twf.TableForm('movie_form', action='save', children=[ twf.HiddenField('id'), twf.TextField('title'), twf.TextField('year', size=4), twf.CalendarDatePicker('release_date'), twf.SingleSelectField('genera', options=['', 'Action', 'Comedy', 'Other']), #twf.TextArea('description'), twf.TextArea('description', validator=twf.validators.NotEmpty), ]) class TestController(BaseController): def index(self, **kw): tmpl_context.form = movie_form return render('/test_test.mako') @validate(movie_form, error_handler=index) def save(self, **kw): return str(kw) results in: URL: http://test:8080/test/save File '/var/www/pylons/lib/python2.5/site-packages/WebError-0.10.1- py2.5.egg/weberror/evalexception.py', line 431 in respond app_iter = self.application(environ, detect_start_response) File '/var/www/pylons/lib/python2.5/site-packages/ToscaWidgets-0.9.8- py2.5.egg/tw/core/middleware.py', line 43 in __call__ return self.wsgi_app(environ, start_response) File '/var/www/pylons/lib/python2.5/site-packages/ToscaWidgets-0.9.8- py2.5.egg/tw/core/middleware.py', line 68 in wsgi_app resp = req.get_response(self.application) File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1325 in get_response File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1293 in call_application File '/var/www/pylons/lib/python2.5/site-packages/ToscaWidgets-0.9.8- py2.5.egg/tw/core/resource_injector.py', line 68 in _injector resp = req.get_response(app) File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1325 in get_response File 'build/bdist.linux-i686/egg/webob/__init__.py', line 1293 in call_application File '/var/www/pylons/lib/python2.5/site-packages/Beaker-1.4.1- py2.5.egg/beaker/middleware.py', line 73 in __call__ return self.app(environ, start_response) File '/var/www/pylons/lib/python2.5/site-packages/Beaker-1.4.1- py2.5.egg/beaker/middleware.py', line 152 in __call__ return self.wrap_app(environ, session_start_response) File '/var/www/pylons/lib/python2.5/site-packages/Routes-1.10.3- py2.5.egg/routes/middleware.py', line 130 in __call__ response = self.app(environ, start_response) File '/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7- py2.5.egg/pylons/wsgiapp.py', line 125 in __call__ response = self.dispatch(controller, environ, start_response) File '/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7- py2.5.egg/pylons/wsgiapp.py', line 324 in dispatch return controller(environ, start_response) File '/var/www/pylons/twtest/twtest/lib/base.py', line 18 in __call__ return WSGIController.__call__(self, environ, start_response) File '/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7- py2.5.egg/pylons/controllers/core.py', line 223 in __call__ response = self._dispatch_call() File '/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7- py2.5.egg/pylons/controllers/core.py', line 174 in _dispatch_call response = self._inspect_call(func) File '/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7- py2.5.egg/pylons/controllers/core.py', line 107 in _inspect_call result = self._perform_call(func, args) File '/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7- py2.5.egg/pylons/controllers/core.py', line 60 in _perform_call return func(**args) File '<string>', line 2 in save File '/var/www/pylons/lib/python2.5/site-packages/ToscaWidgets-0.9.8- py2.5.egg/tw/mods/pylonshf.py', line 66 in wrapper return self._dispatch_call() File '/var/www/pylons/lib/python2.5/site-packages/Pylons-0.9.7- py2.5.egg/pylons/controllers/core.py', line 160 in _dispatch_call action_method = action.replace('-', '_') AttributeError: 'function' object has no attribute 'replace' If I disable validation, the form is able to post and does return kw on the screen. Using: Pylons 0.9.7 tw.forms-0.9.8 ToscaWidgets-0.9.8 decorator-3.1.2 Mako-0.2.5 python 2.5 The same issue occurred with mako 0.2.4, decorator 3.0.0, tw.forms-0.9.7 and ToscaWidgets-0.9.7. _dispatch_call is called twice and action is a string the first time, and a function index the second time. I put in some debugging. action contains 'save' the first time, and the second time it contains <function index at 0xb6f32614> (which of course has no attribute replace). This is a completely new pylons installation with the 5 lines into middleware.py and used the above controller. When validation is removed, the post method displays the data on the screen as expected. added to middleware.py as stated on: http://toscawidgets.org/documentation/ToscaWidgets/install/pylons_app.html import tw.api as twa app = twa.make_middleware(app, { 'toscawidgets.framework': 'pylons', 'toscawidgets.framework.default_view': 'mako', }) Any thoughts? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
