I have a form which generates some selects using certain data. This is done
using wtforms with python, webapp2, gae on the server and passed as a kwarg
to the client. The site is multilingual using Babel translations. When I
change the language on the production server the form gets called but the
data doesn't change language. This works fine on the development server,
but not in production.
Code:
This is attached to a handler class and does what it is supposed to
def form(self):
from product.product_data.forms import ProductForm
return ProductForm(self)
In my BaseHandler I have the following:
if hasattr(self, 'form'):
kwargs['form'] = self.form()
logging.info('get form')
logging.info(kwargs['form'].product_type())
Now the second log logging.info(kwargs['form'].
product_type()) shows the correct language on the dev server but not on the
production server
The form is thus:
class ProductForm(BaseForm):
"""
One big product form
"""
# ----------------PRODUCT-------------------
# Set the product types - alphabetically as either Radio buttons or
selectmultiple
# which is interpreted as checkbox on client
p = realestate_product()
for k, v in p.iteritems():
try:
if v['set']:
set = get_set(v)
# Use locals() here to append product with content of k and
make form variable
locals()['product_' + k] = fields.SelectField(v['label'],
choices=set)
except:
if v['exclusive']:
locals()['product_' + k] = fields.SelectField(v['label'],
choices=sorted(v['choices'], key=lambda tup: tup[1][1:]))
else:
locals()['product_' + k] =
fields.SelectMultipleField(v['label'], choices=sorted(v['choices'], key=lambda
tup: tup[1][1:]))
pass
At first I was using a webapp2.cached_property on the form method, but have
since removed it as even when I called the form from a non cached method on
change of language, it still didn't work.
Appreciate any feedback
Thanks
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/e7a8d809-c28b-4b75-b48a-20cac0a42eb5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.