Ignore:
Timestamp:
16 Dec 2011, 07:32:42 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement fullname constructor as a global utility method which can easily be subject to customization. I think it's better to leave this here rather than selecting the constructor method via the customization object.

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

Legend:

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

    r7356 r7359  
    1919import grok
    2020from grok import index
     21from zope.component import getUtility
    2122from zope.component.interfaces import IFactory
    2223from zope.component import createObject, getUtility
     
    2930from waeup.sirp.imagestorage import DefaultFileStoreHandler
    3031from waeup.sirp.interfaces import (
    31     IObjectHistory, IFileStoreHandler, IFileStoreNameChooser)
     32    IObjectHistory, IFileStoreHandler, IFileStoreNameChooser, ISIRPUtils)
    3233from waeup.sirp.utils.helpers import attrs_to_fields, get_current_principal
    3334from waeup.sirp.applicants.interfaces import (
     
    7172    @property
    7273    def fullname(self):
    73         # We do not necessarily have the middlename attribute
    7474        middlename = getattr(self, 'middlename', None)
    75         if middlename:
    76             return '%s %s %s' % (self.firstname,
    77                 middlename, self.lastname)
    78         else:
    79             return '%s %s' % (self.firstname, self.lastname)
     75        sirp_utils = getUtility(ISIRPUtils)
     76        return sirp_utils.fullname(self.firstname, self.lastname, middlename)
    8077
    8178    def createStudent(self):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/student.py

    r7357 r7359  
    2121import os
    2222import grok
     23from zope.component import getUtility
    2324from zope.component.interfaces import IFactory
    2425from zope.interface import implementedBy
     
    2627from zope.securitypolicy.interfaces import IPrincipalRoleManager
    2728from waeup.sirp.interfaces import (
    28     IObjectHistory, IUserAccount, IFileStoreNameChooser, IFileStoreHandler)
     29    IObjectHistory, IUserAccount, IFileStoreNameChooser, IFileStoreHandler,
     30    ISIRPUtils)
    2931from waeup.sirp.image import SIRPImageFile
    3032from waeup.sirp.imagestorage import DefaultFileStoreHandler
     
    6365    @property
    6466    def fullname(self):
    65         # We do not necessarily have the middlename attribute
    6667        middlename = getattr(self, 'middlename', None)
    67         if middlename:
    68             return '%s %s %s' % (self.firstname,
    69                 middlename, self.lastname)
    70         else:
    71             return '%s %s' % (self.firstname, self.lastname)
     68        sirp_utils = getUtility(ISIRPUtils)
     69        return sirp_utils.fullname(self.firstname, self.lastname, middlename)
    7270
    7371    @property
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/helpers.py

    r7358 r7359  
    2323import shutil
    2424import grok
    25 import smtplib
    26 from email.mime.text import MIMEText
    2725from cStringIO import StringIO
    2826from docutils.core import publish_string
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/utils.py

    r7358 r7359  
    5353        server.quit()
    5454        return True
     55
     56    def fullname(self,firstname,lastname,middlename=None):
     57        # We do not necessarily have the middlename attribute
     58        if middlename:
     59            return '%s %s %s' % (firstname, middlename, lastname)
     60        else:
     61            return '%s %s' % (firstname, lastname)
Note: See TracChangeset for help on using the changeset viewer.