-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I'm migrating a Pylons 1.0(+) app from tw* to tw2.* and I have a
couple of questions:
1. I used to be able to provide a db entity to display() to populate
the "edit" form but that arg now seems to be ignored. Perhaps the
approach is not appropriate for tw2 but there isn't anything in the
docs about binding to passed-through dbentities, just the fetch_data
function - is that now the only way that binding can take place?
2. (In case it's unrelated) I'd be grateful for a tw->tw2 translation
of this tw.forms idiom. AIUI under tw2, the form definition can be
left undisturbed. WidgetBunch is no longer necessary in the
controller, one can now just bind the instantiated form. The template
just needs trivially refactoring to remove the 'w'. Is my
understanding correct?
app/forms/myform.py
===================
<imports, etc>
class ThingForm(twf.ListForm):
rest_method = twf.HiddenField(
default = "PUT",
name = "_method"
)
name = TextField(
validator = UnicodeString(not_empty=True),
css_class = 'required',
help_text = "A thing", label_text = "Thing",
maxlength = 255, size = 88
)
start_date = CalendarDatePicker(
css_class = 'required',
help_text = "Start of the thing.",
label_text="Start date",
date_format = "%A, %d %B %Y"
)
end_date = CalendarDatePicker(
css_class = 'required',
help_text = "End of the thing.",
label_text="End date",
date_format = "%A, %d %B %Y"
)
include_dynamic_js_calls = True
submit_text = "Edit"
submit_text__doc = ("Editing thing")
legend = "Edit Thing"
css = [css]
css_classes = ['cmxform']
javascript = [jquery,jqueryui,functions]
validator = Schema(chained_validators = [])
location = "headbottom"
app/controllers/mycontroller
============================
thing_form = ThingForm('thing_form', location="headbottom")
def edit(self, id):
thing = get_object_or_404(model.Thing, id=id)
c.w = WidgetBunch()
c.w.form = thing_form
c.value = thing
c.action = url('save_thing', id=id)
return render('mytemplate.mak')
app/templates/mytemplate.mak
============================
${c.w.form.display(c.value, action=c.action)|n}
The thing is, the HiddenForm is unfailingly rendered as:
<input type="hidden" name="_method" id="survey_form:rest_method">
i.e. the default "POST" value is not being included. I'm beginning to
wonder whether my difficulties with trying to pass db objects is
somehow related.
I can stuff the values into form.child.children[0].name (for example)
It doesn't make any difference whether I use release or dev versions.
However, I do get an error when using the PyPi tw2.devtools.browser
and the PyPi tw2.forms (but not if I use the repos
tw2.devtools.browser and the PyPi tw2.forms).
TIA
- --
Cheers,
Graham
http://www.linkedin.com/in/ghiggins
-----BEGIN PGP SIGNATURE-----
iEYEARECAAYFAkyvHqUACgkQOsmLt1NhivxDegCg9gdCeVVKIIBuQA7gqTiRySpc
AQ8AoP4D1d4EDG9XdJcMIPwtJb2Ef63niQCVAgUBTK8epVnrWVZ7aXD1AQKXcgP/
QBy2AkzJCMcISxUM+ktZao9/MDS60YFo5eDa36SjQMbJV8WNhqrFQoGlllRgqHLW
DGeEVbKRyBE4SUnSQiN/9Eb+777GMC40r9cTX2ae7YVEcEGTAguf8V1r2Iqnhitj
lqITKNgaakUBG450rGsYy76+TgXSlTXMGWmk/KFVgnI=
=HHD7
-----END PGP SIGNATURE-----
--
You received this message because you are subscribed to the Google Groups
"ToscaWidgets-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/toscawidgets-discuss?hl=en.