Author: tmckay
Date: 2011-07-22 13:32:02 +0000 (Fri, 22 Jul 2011)
New Revision: 4884
Modified:
trunk/cumin/python/cumin/grid/job.py
Log:
Provide tutorial comments on how field data is processed for the job
ads editor form, as a guide and salve for future adventurers...
Modified: trunk/cumin/python/cumin/grid/job.py
===================================================================
--- trunk/cumin/python/cumin/grid/job.py 2011-07-22 13:06:36 UTC (rev 4883)
+++ trunk/cumin/python/cumin/grid/job.py 2011-07-22 13:32:02 UTC (rev 4884)
@@ -708,7 +708,31 @@
def __init__(self, app, name):
super(JobAdsEditor, self).__init__(app, name)
- # the parameter that will hold all the field values
+ # self.ads will hold all the field values when the edit form
+ # is submitted. How self.ads is created and used is not
+ # immediately apparent, so here is a brief overview
+ # (with lots of details left out).
+
+ # Because this class is derived from JobAdsViewer, it has a
+ # JobAdsGroup as a child. During rendering of the JobAdsGroup,
+ # do_get_items() below is called and each element of the result is
+ # passed to EditablePropertyRenderer.render_value().
+ # (look to JobAdsGroup.render_properties() for these calls)
+
+ # In do_get_items(), item["path"] is set to self.ads.path for each
+ # item. This allows EditablePropertyRenderer to create html elements
+ # with names based on self.ads.path and other elements of each item.
+ # When the form is submitted, the POST request contains name/value pairs
+ # for all the html elements marshaled into a URL.
+
+ # The unmarshaling process results in a dictionary of all the job
+ # attributes on the edit page stored in the session under self.ads.path.
+ # This dictionary is what is processed in process_submit() below.
+
+ # Note that EditablePropertyRenderer creates hidden html elements
+ # for each item which contain original value and type information in
+ # addition to an input element. These extra fields are important
+ # in process_submit().
self.ads = DictParameter(app, "params")
self.add_parameter(self.ads)
@@ -721,6 +745,9 @@
if len(ads):
# we just returned from a submit
+ # Don't think this code is ever called, since process_cancel
+ # below clears self.ads and is called at the end of process_submit.
+ # Never saw the debugger hit a breakpoint here... tmckay 7/22/2011
cls = self.app.model.job_meta_data
return [self.gen_item(x, ads[x]["value"], cls, path=self.ads.path,
dtype=ads[x]["type"], error=ads[x],
Show replies by date