Changeset 7747 for main/waeup.sirp/trunk


Ignore:
Timestamp:
2 Mar 2012, 08:08:31 (13 years ago)
Author:
Henrik Bettermann
Message:

Add logger for accesscodes.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
Files:
2 edited

Legend:

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

    r7689 r7747  
    3232from random import SystemRandom as random
    3333from waeup.sirp.interfaces import ISIRPPluggable, IObjectHistory
     34from waeup.sirp.utils.logger import Logger
    3435from waeup.sirp.accesscodes.interfaces import (
    3536    IAccessCode, IAccessCodeBatch, IAccessCodeBatchContainer
     
    276277
    277278
    278 class AccessCodeBatchContainer(grok.Container):
     279class AccessCodeBatchContainer(grok.Container, Logger):
    279280    grok.implements(IAccessCodeBatchContainer)
    280281
     
    400401            return
    401402        reenable_accesscode(ac_id, comment)
     403        return
     404
     405    logger_name = 'waeup.sirp.${sitename}.accesscodes'
     406    logger_filename = 'accesscodes.log'
     407
     408    def logger_info(self, ob_class, comment=None):
     409        """Get the logger's info method.
     410        """
     411        self.logger.info('%s - %s' % (
     412                ob_class, comment))
    402413        return
    403414
  • main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser.py

    r7745 r7747  
    5555        if isinstance(batches, basestring):
    5656            batches = [batches]
     57        ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
    5758        for name in batches:
    5859            batch = self.context[name]
     
    6061            self.flash(_('Archived ${a} (${b})',
    6162                mapping = {'a':name, 'b':csv_file}))
     63            message = 'archived: %s (%s)' % (name,csv_file)
     64            self.context.logger_info(ob_class, message)
    6265            if delete is None:
    6366                continue
    6467            del self.context[name]
    6568            self.flash(_('Deleted batch ${a}', mapping = {'a':name}))
     69            message = 'deleted: %s' % name
     70            self.context.logger_info(ob_class, message)
    6671
    6772class AddBatchPage(SIRPAddFormPage):
     
    8792            mapping = {'a':data['entry_num']}))
    8893        self.flash(_('Data written to ${a}', mapping = {'a':csv_file}))
     94        ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
     95        message = 'created: %s (%d, %f)' % (
     96            csv_file, data['entry_num'], data['cost'])
     97        self.context.logger_info(ob_class, message)
    8998        self.redirect(self.url(self.context))
    9099
     
    130139            self.flash(_('Successfully reimported: ${a}',
    131140                mapping = {'a':filename}))
     141            ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
     142            message = 'reimported: %s' % filename
     143            self.context.logger_info(ob_class, message)
    132144        self.redirect(self.url(self.context))
    133145
     
    162174        if isinstance(entries, basestring):
    163175            entries = [entries]
     176        ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
    164177        for entry in entries:
    165178            if 'disable' in form:
     
    168181                    self.context.disable(entry, comment)
    169182                    self.flash(_('${a} disabled.', mapping = {'a':entry}))
     183                    message = 'disabled: %s' % entry
     184                    self.context.logger_info(ob_class, message)
    170185                except InvalidTransitionError:
    171186                    self.flash(_('${a}: Disable transition not allowed.',
     
    176191                    self.context.enable(entry, comment)
    177192                    self.flash(_('${a} (re-)enabled.', mapping = {'a':entry}))
     193                    message = '(re-)enabled: %s' % entry
     194                    self.context.logger_info(ob_class, message)
    178195                except InvalidTransitionError:
    179196                    self.flash(_('${a}: Re-enable transition not allowed.', mapping = {'a':entry}))
Note: See TracChangeset for help on using the changeset viewer.