Ignore:
Timestamp:
25 Jun 2011, 08:44:21 (13 years ago)
Author:
Henrik Bettermann
Message:

Save detailed logging messages (experimental).

Location:
main/waeup.sirp/trunk/src/waeup/sirp/applicants
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicants.py

    r6348 r6475  
    4848        return
    4949
    50     def getApplicantsRootLogger(self):
    51         return grok.getSite()['applicants'].logger
     50    #def getApplicantsRootLogger(self):
     51    #    return grok.getSite()['applicants'].logger
     52
     53    def loggerInfo(self, ob_class, comment=None):
     54        target = self.__name__
     55        return grok.getSite()['applicants'].logger_info(ob_class,target,comment)
    5256
    5357    @property
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r6471 r6475  
    640640        header_title = getattr(grok.getSite(), 'name', u'Sample University')
    641641        story.append(Paragraph(header_title, style["Heading1"]))
    642         #import pdb; pdb.set_trace()
    643642        frame_header.addFromList(story,pdf)
    644643
     
    733732    @grok.action('Save')
    734733    def save(self, **data):
    735         self.applyData(self.context, **data)
     734        #import pdb; pdb.set_trace()
     735        changed_fields = self.applyData(self.context, **data)
     736        changed_fields = changed_fields.values()
     737        fields_string = '+'.join('+'.join('+'.join(str(i) for i in b)) for b in changed_fields)
    736738        self.context._p_changed = True
    737739        form = self.request.form
     
    740742            self.wf_info.fireTransition(transition_id)
    741743        self.flash('Form has been saved.')
    742         self.context.getApplicantsRootLogger().info('Saved')
     744        ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
     745        self.context.loggerInfo(ob_class, 'saved: % s' % fields_string)
    743746        return
    744747
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/root.py

    r6444 r6475  
    3030from waeup.sirp.utils.logger import ISiteLoggers
    3131from waeup.sirp.applicants.interfaces import IApplicantsRoot
     32from waeup.sirp.utils.helpers import get_current_principal
    3233
    3334class ApplicantsRoot(grok.Container):
     
    4748            loggers.register('waeup.sirp.%s.applicants')
    4849        return loggers.getLogger('waeup.sirp.%s.applicants')
     50
     51    def logger_info(self, target, ob_class, comment=None):
     52        """Get the logger's info method.
     53        """
     54        user = get_current_principal()
     55        if user is None:
     56            user = 'system'
     57        elif user.title == 'Applicant':
     58            user = 'applicant'
     59        else:
     60            user = user.id
     61        self.logger.info('%s - %s - %s  - %s' % (user, target, ob_class, comment))
    4962
    5063class ApplicantsPlugin(grok.GlobalUtility):
Note: See TracChangeset for help on using the changeset viewer.