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/accesscodes
Files:
3 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
Note: See TracChangeset for help on using the changeset viewer.