Back to index

plone3  3.1.7
topic_editCriteria.py
Go to the documentation of this file.
00001 ## Script (Python) "topic_editCriteria"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=REQUEST, RESPONSE, criteria
00008 ##title=
00009 ##
00010 """\
00011 Save changes to the list of criteria.  This is done by going over
00012 the submitted criteria records and comparing them against the
00013 criteria object's editable attributes.  A 'command' object is
00014 built to send to the Criterion objects 'apply' method, which in turn
00015 applies the command to the Criterion objects 'edit' method.
00016 """
00017 
00018 for rec in criteria:
00019     crit = context.getCriterion(rec.id)
00020     command = {}
00021     for attr in crit.editableAttributes():
00022         tmp = getattr(rec, attr, None)
00023         # Due to having multiple radio buttons on the same page
00024         # with the same name but belonging to different records,
00025         # they needed to be associated with different records with ids
00026         if tmp is None:
00027             tmp = getattr(rec, '%s__%s' % (attr, rec.id), None)
00028         command[attr] = tmp
00029     crit.apply(command)
00030 
00031 message='Changes+saved.'
00032 RESPONSE.redirect('%s/topic_criteria_form?portal_status_message=%s' % (
00033     context.absolute_url(), message)
00034                   )
00035