Changeset 8186


Ignore:
Timestamp:
17 Apr 2012, 00:31:10 (13 years ago)
Author:
uli
Message:

Use new helper functions to compute pytz timezones correctly.

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

Legend:

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

    r8183 r8186  
    3333from zope.component import getUtility
    3434from waeup.kofa.interfaces import IKofaUtils, IKofaPluggable, IObjectHistory
     35from waeup.kofa.utils.helpers import now
    3536from waeup.kofa.utils.logger import Logger
    3637from waeup.kofa.accesscodes.interfaces import (
     
    247248        ac_storage = self._getStoragePath()
    248249        tz = getUtility(IKofaUtils).tzinfo
    249         now = datetime.now(tz)
    250         timestamp = now.strftime('%Y_%m_%d_%H_%M_%S')
     250        dt_now = now(tz)
     251        timestamp = dt_now.strftime('%Y_%m_%d_%H_%M_%S')
    251252        csv_path = os.path.join(
    252253            ac_storage, '%s-%s_archive-%s-%s.csv' % (
  • main/waeup.kofa/trunk/src/waeup/kofa/accesscodes/tests/test_accesscode.py

    r8182 r8186  
    233233        # Access codes have a history.
    234234        match = re.match(
    235             '^....-..-.. ..:..:.. - initialized by system',
     235            '^....-..-.. ..:..:.. ..... .+ - initialized by system',
    236236            self.ac1.history)
    237237        assert match is not None
     
    301301"prefix","serial","ac","state","history"
    302302"FOO","9.99","1","0"
    303 "FOO","0","FOO-1-11111111","used","<YYYY-MM-DD hh:mm:ss> - ..."
    304 "FOO","1","FOO-1-22222222","initialized","<YYYY-MM-DD hh:mm:ss> - ..."
    305 "FOO","2","FOO-1-33333333","disabled","<YYYY-MM-DD hh:mm:ss> - ..."
     303"FOO","0","FOO-1-11111111","used","<YYYY-MM-DD hh:mm:ss TZ> - ..."
     304"FOO","1","FOO-1-22222222","initialized","<YYYY-MM-DD hh:mm:ss TZ> - ..."
     305"FOO","2","FOO-1-33333333","disabled","<YYYY-MM-DD hh:mm:ss TZ> - ..."
    306306'''[1:]
    307307        contents = open(result_path, 'rb').read()
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r8183 r8186  
    5151from waeup.kofa.permissions import get_users_with_local_roles
    5252from waeup.kofa.students.interfaces import IStudentsUtils
    53 from waeup.kofa.utils.helpers import string_from_bytes, file_size
     53from waeup.kofa.utils.helpers import string_from_bytes, file_size, now
    5454from waeup.kofa.widgets.datewidget import (
    5555    FriendlyDateDisplayWidget, FriendlyDateDisplayWidget,
     
    829829        IWorkflowInfo(self.context).fireTransition('submit')
    830830        tz = getUtility(IKofaUtils).tzinfo
    831         self.context.application_date = datetime.now(tz)
     831        self.context.application_date = now(tz)
    832832        self.context.locked = True
    833833        self.flash(_('Form has been submitted.'))
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pdf.py

    r8183 r8186  
    3434from zope.component import getUtility
    3535from waeup.kofa.browser.interfaces import IPDFCreator
     36from waeup.kofa.utils.helpers import now
    3637from waeup.kofa.interfaces import IKofaUtils
    3738from waeup.kofa.interfaces import MessageFactory as _
     
    331332        if not getattr(doc, 'kofa_nodate', False):
    332333            tz = getUtility(IKofaUtils).tzinfo
    333             today = datetime.now(tz).strftime('%d/%m/%Y %H:%M:%S')
     334            today = now(tz).strftime('%d/%m/%Y %H:%M:%S %z %Z')
    334335            canvas.drawString(2.2*cm, 0.5 * inch,
    335336                translate(_(u'Date: ${a}', mapping = {'a': today})))
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/hostel.py

    r8183 r8186  
    2929from waeup.kofa.interfaces import IKofaUtils
    3030from waeup.kofa.interfaces import MessageFactory as _
     31from waeup.kofa.utils.helpers import now
    3132
    3233class Hostel(grok.Container):
     
    164165
    165166            # Comment of Martijn:
    166             # If you have a non-Persistent subobject (like a list) and you change it,
    167             # you need to manually flag the persistence machinery on the object that
    168             # its subobject changed, with _p_changed. This is only necessary if some
    169             # of the objects are not sublclasses of Persistent. For common built-in
    170             # collections in Python such as list and dictionary there are replacements
    171             # (PersistentList, PersistentMapping), and more advanced building blocks
     167            # If you have a non-Persistent subobject (like a list) and
     168            # you change it, you need to manually flag the persistence
     169            # machinery on the object that its subobject changed, with
     170            # _p_changed. This is only necessary if some of the
     171            # objects are not sublclasses of Persistent. For common
     172            # built-in collections in Python such as list and
     173            # dictionary there are replacements (PersistentList,
     174            # PersistentMapping), and more advanced building blocks
    172175            # for indexes (BTrees), that don't have this issue.
    173176            #hostel._p_changed = True
     
    207210            bedticket.bed = None
    208211            tz = getUtility(IKofaUtils).tzinfo
    209             timestamp = datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
    210             bedticket.bed_coordinates = u'-- booking cancelled on %s --' % timestamp
     212            timestamp = now(tz).strftime("%Y-%m-%d %H:%M:%S %z %Z")
     213            bedticket.bed_coordinates = u'-- booking cancelled on %s --' % (
     214                timestamp,)
    211215            return old_owner
    212216
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py

    r7811 r8186  
    284284          self.browser.contents)
    285285        self.assertMatches(bedticket.bed_coordinates,
    286           u' -- booking cancelled on <YYYY-MM-DD hh:mm:ss> --')
     286          u' -- booking cancelled on <YYYY-MM-DD hh:mm:ss TZ> --')
    287287        # If we release a free be, nothing will happen
    288288        ctrl = self.browser.getControl(name='val_id')
  • main/waeup.kofa/trunk/src/waeup/kofa/objecthistory.py

    r8183 r8186  
    2323from zope.annotation.interfaces import IAnnotations
    2424from waeup.kofa.interfaces import IObjectHistory, IKofaObject, IKofaUtils
    25 from waeup.kofa.utils.helpers import get_current_principal
     25from waeup.kofa.utils.helpers import get_current_principal, now
    2626
    2727from waeup.kofa.interfaces import MessageFactory as _
     
    6161        msgs = self._getMessages()
    6262        tz = getUtility(IKofaUtils).tzinfo
    63         timestamp = datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
     63        timestamp = now(tz).strftime("%Y-%m-%d %H:%M:%S %z %Z")
    6464        user = get_current_principal()
    6565        if user is None:
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r8183 r8186  
    3939from waeup.kofa.interfaces import MessageFactory as _
    4040from waeup.kofa.students.interfaces import IStudentsUtils
     41from waeup.kofa.utils.helpers import now
    4142
    4243SLIP_STYLE = [
     
    208209      frame_footer = Frame(1*cm,0,width-(2*cm),1*cm)
    209210      tz = getUtility(IKofaUtils).tzinfo
    210       timestamp = datetime.now(tz).strftime("%d/%m/%Y %H:%M:%S")
     211      timestamp = now(tz).strftime("%d/%m/%Y %H:%M:%S %z %Z")
    211212      left_text = '<font size=10>%s</font>' % timestamp
    212213      story.append(Paragraph(left_text, style["Normal"]))
  • main/waeup.kofa/trunk/src/waeup/kofa/testing.py

    r7827 r8186  
    295295    (re.compile(r'httperror_seek_wrapper:'), 'HTTPError:' ),
    296296    (re.compile('[\d]{10}'), '<10-DIGITS>'),
     297    (re.compile('\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d [\+\-]\d\d\d\d [^ ]+'),
     298     '<YYYY-MM-DD hh:mm:ss TZ>'),
    297299    (re.compile('\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d'), '<YYYY-MM-DD hh:mm:ss>'),
    298300    (re.compile('\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d'), '<DATETIME>'),
  • main/waeup.kofa/trunk/src/waeup/kofa/tests/test_objecthistory.py

    r7819 r8186  
    8080        hist.addMessage('blah')
    8181        result = ''.join(hist.messages)
    82         self.assertMatches('<YYYY-MM-DD hh:mm:ss> - blah by system', result)
     82        self.assertMatches('<YYYY-MM-DD hh:mm:ss TZ> - blah by system', result)
    8383
    8484    def test_add_messages_existing_principal(self):
     
    8989        hist.addMessage('blah')
    9090        result = ''.join(hist.messages)
    91         self.assertMatches('<YYYY-MM-DD hh:mm:ss> - blah by Bob', result)
     91        self.assertMatches('<YYYY-MM-DD hh:mm:ss TZ> - blah by Bob', result)
    9292
    9393    def test_messages(self):
Note: See TracChangeset for help on using the changeset viewer.