Changeset 6709 for main


Ignore:
Timestamp:
10 Sep 2011, 00:29:02 (13 years ago)
Author:
uli
Message:

Add some onFailure implementation for password input. This one cares
for displaying invariant error messages properly (instead of a plain
'there were errors' message). Although this method is implemented in a
way usable also for other pages/view, please do not simply copy this
method over to other classes. Instead, put it somewhere in w.s.browser,
where it can be accessed from each interested form as it could be some
general form extension.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/branches/uli-studentpw/src/waeup/sirp/students/browser.py

    r6705 r6709  
    571571
    572572    def update(self):
    573         #datepicker.need() # Enable jQuery datepicker in date fields.
    574573        super(StudentBaseEditFormPage, self).update()
    575574        self.wf_info = IWorkflowInfo(self.context)
    576575        return
    577576
    578     @grok.action('Save')
     577    def onFailure(self, action, data, errors):
     578        new_status = []
     579        other_errors = False
     580        for error in errors:
     581            msg = getattr(error, 'message', '')
     582            if isinstance(msg, basestring) and msg != '':
     583                new_status.append(msg)
     584            else:
     585                other_errors = True
     586        if other_errors:
     587            if new_status:
     588                new_status.append('see below for further errors')
     589            else:
     590                new_status.append('See below for details.')
     591        if new_status:
     592            self.status = u'There were errors: %s' % ', '.join(new_status)
     593        return
     594
     595    @grok.action('Save', failure=onFailure)
    579596    def save(self, **data):
    580         print "PW1: ", self.context.password
    581597        form = self.request.form
    582598        ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
     
    588604        if fields_string:
    589605            self.context.loggerInfo(ob_class, 'saved: % s' % fields_string)
    590         print "PW2: ", self.context.password
    591606        return
    592607
Note: See TracChangeset for help on using the changeset viewer.