Changeset 8182


Ignore:
Timestamp:
16 Apr 2012, 20:56:59 (13 years ago)
Author:
Henrik Bettermann
Message:

Part 1: Add tzinfo to all persistent datetime objects.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
9 edited

Legend:

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

    r7819 r8182  
    3131from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    3232from random import SystemRandom as random
    33 from waeup.kofa.interfaces import IKofaPluggable, IObjectHistory
     33from zope.component import getUtility
     34from waeup.kofa.interfaces import IKofaUtils, IKofaPluggable, IObjectHistory
    3435from waeup.kofa.utils.logger import Logger
    3536from waeup.kofa.accesscodes.interfaces import (
     
    353354        if batch_name in self.keys():
    354355            raise KeyError('Batch already exists: %s' % batch_name)
     356        tz = getUtility(IKofaUtils).tzinfo
    355357        batch = AccessCodeBatch(
    356             datetime.now(), creator, prefix, cost, 0, num=num)
     358            datetime.now(tz), creator, prefix, cost, 0, num=num)
    357359        num_entries = 0
    358360        self[batch_name] = batch
     
    426428        creator = 'system'
    427429        entry_num = 0
    428         creation_date = datetime.now()
     430        tz = getUtility(IKofaUtils).tzinfo
     431        creation_date = datetime.now(tz)
    429432        basecontainer.createBatch(creation_date, creator,
    430433            'SFE', cost, entry_num)
  • main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/browser.py

    r7819 r8182  
    2020import grok
    2121from datetime import datetime
     22from zope.component import getUtility
    2223from hurry.workflow.interfaces import InvalidTransitionError
    2324from waeup.kofa.browser.resources import datatable
     
    2627from waeup.kofa.browser.viewlets import (
    2728    AdminTask, AddActionButton, SearchActionButton, BatchOpButton, ManageLink)
    28 from waeup.kofa.interfaces import IKofaObject
     29from waeup.kofa.interfaces import IKofaObject, IKofaUtils
    2930from waeup.kofa.interfaces import MessageFactory as _
    3031from waeup.kofa.accesscodes.interfaces import (
     
    8485    def createBatch(self, **data):
    8586        creator = self.request.principal.id
    86         creation_date = datetime.now()
     87        tz = getUtility(IKofaUtils).tzinfo
     88        creation_date = datetime.now(tz)
    8789        data.update(creation_date=creation_date, creator=creator)
    8890        batch = self.context.createBatch(**data)
  • main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/tests/test_accesscode.py

    r7819 r8182  
    2525from datetime import datetime
    2626from hurry.workflow.interfaces import InvalidTransitionError, IWorkflowState
     27from zope.component import getUtility
    2728from zope.component.hooks import setSite, clearSite
    2829from zope.interface.verify import verifyObject, verifyClass
    2930from zope.testing import renormalizing
    3031from waeup.kofa.app import University
    31 from waeup.kofa.interfaces import IObjectHistory, IKofaPluggable
     32from waeup.kofa.interfaces import IObjectHistory, IKofaPluggable, IKofaUtils
    3233from waeup.kofa.testing import (
    3334    FunctionalLayer, FunctionalTestCase, setUp, tearDown, getRootFolder)
     
    258259        self.app = self.getRootFolder()['app']
    259260
     261        tz = getUtility(IKofaUtils).tzinfo
    260262        batch = AccessCodeBatch(    # create batch with zero entries
    261             datetime.now(), 'testuser', 'FOO', 9.99, 0)
     263            datetime.now(tz), 'testuser', 'FOO', 9.99, 0)
    262264        self.app['accesscodes'].addBatch(batch)
    263265
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r8176 r8182  
    521521        self.context.r_code = u'00'
    522522        self.context.p_state = 'paid'
    523         self.context.payment_date = datetime.now()
     523        tz = getUtility(IKofaUtils).tzinfo
     524        self.context.payment_date = datetime.now(tz)
    524525        ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
    525526        self.context.__parent__.loggerInfo(
  • main/waeup.kofa/trunk/src/waeup/kofa/payments/payment.py

    r7811 r8182  
    2222from datetime import datetime
    2323from grok import index
     24from zope.component import getUtility
     25from waeup.kofa.interfaces import IKofaUtils
    2426from waeup.kofa.payments.interfaces import (
    2527    IPayment, ISCPayment, IOnlinePayment,
     
    3638    def __init__(self):
    3739        super(Payment, self).__init__()
    38         self.creation_date = datetime.now()
     40        try:
     41            tz = getUtility(IKofaUtils).tzinfo
     42        except:
     43            #In unit tests KofaUtils is not available.
     44            tz = None
     45        self.creation_date = datetime.now(tz)
    3946        self.p_id = None
    4047        return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/accommodation.py

    r7811 r8182  
    2121from datetime import datetime
    2222import grok
     23from zope.component import getUtility
    2324from zope.component.interfaces import IFactory
    2425from zope.interface import implementedBy
    25 from waeup.kofa.interfaces import academic_sessions_vocab
     26from waeup.kofa.interfaces import academic_sessions_vocab, IKofaUtils
    2627from waeup.kofa.students.interfaces import (
    2728    IStudentAccommodation, IStudentNavigation, IBedTicket)
     
    6162    def __init__(self):
    6263        super(BedTicket, self).__init__()
    63         self.booking_date = datetime.now()
     64        tz = getUtility(IKofaUtils).tzinfo
     65        self.booking_date = datetime.now(tz)
    6466        self.bed = None
    6567        return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r8176 r8182  
    11451145        self.context.r_code = u'00'
    11461146        self.context.p_state = 'paid'
    1147         self.context.payment_date = datetime.now()
     1147        tz = getUtility(IKofaUtils).tzinfo
     1148        self.context.payment_date = datetime.now(tz)
    11481149        if self.context.p_category == 'clearance':
    11491150            # Create CLR access code
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r8176 r8182  
    379379        )
    380380
     381    def addCourseTicket(courseticket):
     382        """Add a course ticket object.
     383        """
     384
     385    def getStudent():
     386        """Return student
     387        """
     388
    381389class ICourseTicket(IKofaObject):
    382390    """A course ticket.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r8119 r8182  
    2626import grok
    2727from zope.event import notify
    28 from zope.component import createObject, queryUtility
     28from zope.component import createObject, queryUtility, getUtility
    2929from zope.component.hooks import setSite, clearSite
    3030from zope.catalog.interfaces import ICatalog
     
    4040from waeup.kofa.university.faculty import Faculty
    4141from waeup.kofa.university.department import Department
    42 from waeup.kofa.interfaces import IUserAccount
     42from waeup.kofa.interfaces import IUserAccount, IKofaUtils
    4343from waeup.kofa.authentication import LocalRoleSetEvent
    4444from waeup.kofa.hostels.hostel import Hostel, Bed, NOT_OCCUPIED
     
    121121        # Create 5 access codes with prefix'PWD'
    122122        pin_container = self.app['accesscodes']
     123        tz = getUtility(IKofaUtils).tzinfo
    123124        pin_container.createBatch(
    124             datetime.now(), 'some_userid', 'PWD', 9.99, 5)
     125            datetime.now(tz), 'some_userid', 'PWD', 9.99, 5)
    125126        pins = pin_container['PWD-1'].values()
    126127        self.pwdpins = [x.representation for x in pins]
Note: See TracChangeset for help on using the changeset viewer.