I am using turbogears2 (tg.devtools 2.0rc1). But whenever I am
submitting this form, the validation is not working. Needing help.
The sample code is given below:
class MyForm(TableForm):
show_message = True
fields = [
TextField('field1', label_text='Field1', size=6,
validator=NotEmpty),
TextField('field1', label_text='Field1',
validator=NotEmpty)]
submit_text = 'submit'
my_form = MyForm("my_form", action='save')
class UserController(BaseController):
@expose('openads.templates.form')
def test(self, **params):
tmpl_context.form = my_form
return {}
@expose()
@validate(my_form, error_handler=test)
def save(self, **params):
flash("successfully saved...")
redirect("/")
form template:
<p py:replace="tmpl_context.form()"></p>
Regards,
Ranjan
--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbo...@googlegroups.com.
To unsubscribe from this group, send email to turbogears+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.
class MyForm(TableForm):
show_message = True
hover_help = True
fields = [
TextField('field1', label_text='Field1', size=6,
validator=NotEmpty,
help_text='Please enter a value'),
TextField('field2', label_text='Field2')]
submit_text = 'submit'
Now, when I am not giving any value in field1 and clicking 'submit'
button, I get error like:
TypeError: pylons_formencode_gettext() got an unexpected keyword
argument 'domain'
Regards,
Ranjan
> > turbogears+...@googlegroups.com<turbogears%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/turbogears?hl=en.
>
> --
> Michael J. Pedersen
> My IM IDs: Jabber/peder...@icelus.tzo.com, ICQ/103345809, AIM/pedermj022171
> Yahoo/pedermj2002, MSN/pedermj022...@hotmail.com
Thanks
jitesh
From anybody any hints please
Regards,
Ranjan
I would probably help if you posted the *full* exception tarceback.
Chris
The above code is perfectly working in turbogears2 (tg.devtools
2.0.2).
But the very same code is not working in turbogears2 (tg.devtools
2.0rc1) by returning the following traceback
WebError Traceback:
⇝ TypeError: pylons_formencode_gettext() got an unexpected keyword
argument 'domain'
View as: Interactive (full) | Text (full) | XML (full)
clear this
URL: http://localhost:8080/user/save
Module weberror.evalexception:431 in respond view
<< try:
__traceback_supplement__ =
errormiddleware.Supplement, self, environ
app_iter = self.application(environ,
detect_start_response)
# Don't create a list from a paste.fileapp object
>> app_iter = self.application(environ, detect_start_response)
Module tg.configuration:643 in wrapper view
<< log.debug("Making request body seekable")
Request(environ).make_body_seekable()
return app(environ, start_response)
return wrapper
>> return app(environ, start_response)
Module tg.configuration:543 in remover view
<< def remover(environ, start_response):
try:
return app(environ, start_response)
finally:
log.debug("Removing DBSession from current
thread")
>> return app(environ, start_response)
Module repoze.tm:19 in __call__ view
<< return start_response(status, headers, exc_info)
try:
result = self.application(environ,
save_status_and_headers)
except:
self.abort()
>> result = self.application(environ, save_status_and_headers)
Module repoze.who.middleware:107 in __call__ view
<< wrapper = StartResponseWrapper(start_response)
app_iter = app(environ, wrapper.wrap_start_response)
if self.challenge_decider(environ, wrapper.status,
wrapper.headers):
>> app_iter = app(environ, wrapper.wrap_start_response)
Module tw.core.middleware:36 in __call__ view
<< def __call__(self, environ, start_response):
return self.wsgi_app(environ, start_response)
def wsgi_app(self, environ, start_response):
>> return self.wsgi_app(environ, start_response)
Module tw.core.middleware:59 in wsgi_app view
<< else:
# Pass request downstream
resp = req.get_response(self.application)
return resp(environ, start_response)
finally:
>> resp = req.get_response(self.application)
Module webob:1325 in get_response view
Module webob:1293 in call_application view
Module tw.core.resource_injector:67 in _injector view
<< def _injector(environ, start_response):
req = Request(environ)
resp = req.get_response(app)
content_type = resp.headers.get('Content-Type','text/
plain').lower()
if 'html' in content_type:
>> resp = req.get_response(app)
Module webob:1325 in get_response view
Module webob:1293 in call_application view
Module beaker.middleware:81 in __call__ view
<<
self.cache_manager)
environ[self.environ_key] = self.cache_manager
return self.app(environ, start_response)
>> return self.app(environ, start_response)
Module beaker.middleware:160 in __call__ view
<< headers.append(('Set-cookie', cookie))
return start_response(status, headers, exc_info)
return self.wrap_app(environ, session_start_response)
def _get_session(self):
>> return self.wrap_app(environ, session_start_response)
Module routes.middleware:130 in __call__ view
<< environ['SCRIPT_NAME'] = environ['SCRIPT_NAME']
[:-1]
response = self.app(environ, start_response)
# Wrapped in try as in rare cases the attribute will be
gone already
>> response = self.app(environ, start_response)
Module pylons.wsgiapp:125 in __call__ view
<<
controller = self.resolve(environ, start_response)
response = self.dispatch(controller, environ,
start_response)
if 'paste.testing_variables' in environ and hasattr
(response,
>> response = self.dispatch(controller, environ, start_response)
Module pylons.wsgiapp:324 in dispatch view
<< if log_debug:
log.debug("Calling controller class with WSGI
interface")
return controller(environ, start_response)
def load_test_env(self, environ):
>> return controller(environ, start_response)
Module openads.lib.base:32 in __call__ view
<< request.identity = request.environ.get
('repoze.who.identity')
tmpl_context.identity = request.identity
return TGController.__call__(self, environ,
start_response)
>> return TGController.__call__(self, environ, start_response)
Module pylons.controllers.core:221 in __call__ view
<< return response(environ, self.start_response)
response = self._dispatch_call()
if not start_response_called:
self.start_response = start_response
>> response = self._dispatch_call()
Module pylons.controllers.core:172 in _dispatch_call view
<< req.environ['pylons.action_method'] = func
response = self._inspect_call(func)
else:
if log_debug:
>> response = self._inspect_call(func)
Module pylons.controllers.core:107 in _inspect_call view
<< func.__name__, args)
try:
result = self._perform_call(func, args)
except HTTPException, httpe:
if log_debug:
>> result = self._perform_call(func, args)
Module tg.controllers:776 in _perform_call view
<< return
result = DecoratedController._perform_call(
self, controller, params, remainder=remainder)
except HTTPException, httpe:
>> self, controller, params, remainder=remainder)
Module tg.controllers:136 in _perform_call view
<<
# Validate user input
params = self._perform_validate(controller, params)
pylons.c.form_values = params
>> params = self._perform_validate(controller, params)
Module tg.controllers:239 in _perform_validate view
<< elif hasattr(validation.validators, 'validate'):
# An object with a "validate" method - call it with
the parameters
new_params = validation.validators.validate(params,
state)
# Theoretically this should not happen...
>> new_params = validation.validators.validate(params, state)
Module tw.forms.core:130 in validate view
<< if self.validator:
try:
value = self.validator.to_python(value, state)
except Invalid, error:
if use_request_local:
>> value = self.validator.to_python(value, state)
Module formencode.api:413 in to_python view
<< tp = self._to_python
if tp:
value = tp(value, state)
vp = self.validate_python
if vp and vp is not self._validate_noop:
>> value = tp(value, state)
Module formencode.schema:153 in _to_python view
<< try:
new[name] = validator.to_python(value,
state)
except Invalid, e:
errors[name] = e
>> new[name] = validator.to_python(value, state)
Module formencode.api:402 in to_python view
<< if self.is_empty(value):
if self.not_empty:
raise Invalid(self.message('empty', state),
value, state)
else:
if self.if_empty is not NoDefault:
>> raise Invalid(self.message('empty', state), value, state)
Module formencode.api:234 in message view
<< msg = self._messages[msgName]
msg = trans(msg, **self.gettextargs)
try:
return msg % kw
>> msg = trans(msg, **self.gettextargs)
TypeError: pylons_formencode_gettext() got an unexpected keyword
argument 'domain'
Is that a bug in turbogears2 (tg.devtools 2.0rc1) ?
Regards,
Ranjan
Any reason why you insist on using a release-candidate instead of a
released version - especially, if the latter works? Or am I missing
something here?
Diez
Are you sure this is due to the TG version, or maybe you have newer
versions of other packages as well? I just noticed that the recent
releases of webhelpers and webob (and maybe weberror?) do not work
properly with TG 2 any more. I'll try to fix this after the winter
holidays if nobody else does.
-- Christoph