Ignore:
Timestamp:
26 Oct 2011, 03:54:42 (13 years ago)
Author:
Henrik Bettermann
Message:

Add logger and add hostels container to site root.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
4 edited

Legend:

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

    r6907 r6952  
    88from waeup.sirp.datacenter import DataCenter
    99from waeup.sirp.students.container import StudentsContainer
     10from waeup.sirp.hostels.container import HostelsContainer
    1011from waeup.sirp.imagestorage import ImageStorageFileRetrieval, ImageStorage
    1112from waeup.sirp.interfaces import (
     
    4647        self['students'] = StudentsContainer()
    4748        self['configuration'] = ConfigurationContainer()
     49        self['hostels'] = HostelsContainer()
    4850        self._createPlugins()
    4951
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/container.py

    r6951 r6952  
    2121from waeup.sirp.hostels.interfaces import IHostelsContainer
    2222from waeup.sirp.utils.helpers import attrs_to_fields
     23from waeup.sirp.utils.logger import Logger
    2324
    24 class HostelsContainer(grok.Container):
     25class HostelsContainer(grok.Container, Logger):
    2526    """This is a container for all kind of hostels.
    2627    """
     
    3839        raise NotImplementedError()
    3940
    40 HostelsContainer = attrs_to_fields(HostelsContainer)
     41    def addHostel(self, hostel):
     42        """Add a hostel.
     43        """
     44        if not IHostel.providedBy(hostel):
     45            raise TypeError(
     46                'HostelsContainers contain only IHostel instances')
     47        self[hostel.hostel_id] = hostel
     48        return
     49
     50    logger_name = 'waeup.sirp.${sitename}.hostels'
     51    logger_filename = 'hostels.log'
     52
     53    def logger_info(self, ob_class, target, comment=None):
     54        """Get the logger's info method.
     55        """
     56        user = get_current_principal()
     57        if user is None:
     58            user = 'system'
     59        else:
     60            user = user.id
     61        self.logger.info('%s - %s - %s - %s' % (
     62                user, ob_class, target, comment))
     63        return
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/hostel.py

    r6951 r6952  
    3535        return
    3636
     37    def loggerInfo(self, ob_class, comment=None):
     38        target = self.__name__
     39        return grok.getSite()['hostels'].logger_info(ob_class,target,comment)
     40
    3741Hostel = attrs_to_fields(Hostel)
  • main/waeup.sirp/trunk/src/waeup/sirp/hostels/interfaces.py

    r6951 r6952  
    1414
    1515    """
     16
     17    def loggerInfo(ob_class, comment):
     18        """Adds an INFO message to the log file
     19        """
     20
     21    hostel_id = schema.TextLine(
     22        title = u'Student ID',
     23        required = False,
     24        )
Note: See TracChangeset for help on using the changeset viewer.