changeset 476:4be11eec9c4f

MoinMoin.util.datetime -> timefuncs to avoid conflict/confusion with stdlib datetime, also moved util.W3CDate there imported from: moin--main--1.5--patch-480
author Thomas Waldmann <tw@waldmann-edv.de>
date Sat, 18 Mar 2006 11:56:51 +0000
parents ad2bc0980876
children 4e85cddd2db4
files ChangeLog MoinMoin/Page.py MoinMoin/PageEditor.py MoinMoin/PageGraphicalEditor.py MoinMoin/action/rss_rc.py MoinMoin/i18n/POTFILES.in MoinMoin/server/standalone.py MoinMoin/stats/hitcounts.py MoinMoin/user.py MoinMoin/userform.py MoinMoin/util/__init__.py MoinMoin/util/datetime.py MoinMoin/util/timefuncs.py
diffstat 13 files changed, 86 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Mar 17 09:34:24 2006 +0000
+++ b/ChangeLog	Sat Mar 18 11:56:51 2006 +0000
@@ -2,6 +2,31 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-03-18 12:56:51 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-480
+
+    Summary:
+      MoinMoin.util.datetime -> timefuncs to avoid conflict/confusion with stdlib datetime, also moved util.W3CDate there
+    Revision:
+      moin--main--1.5--patch-480
+
+    MoinMoin.util.datetime -> timefuncs to avoid conflict/confusion with stdlib datetime, also moved util.W3CDate there
+    
+
+    modified files:
+     ChangeLog MoinMoin/Page.py MoinMoin/PageEditor.py
+     MoinMoin/PageGraphicalEditor.py MoinMoin/action/rss_rc.py
+     MoinMoin/i18n/POTFILES.in MoinMoin/server/standalone.py
+     MoinMoin/stats/hitcounts.py MoinMoin/user.py
+     MoinMoin/userform.py MoinMoin/util/__init__.py
+     MoinMoin/util/timefuncs.py
+
+    renamed files:
+     MoinMoin/util/.arch-ids/datetime.py.id
+       ==> MoinMoin/util/.arch-ids/timefuncs.py.id
+     MoinMoin/util/datetime.py
+       ==> MoinMoin/util/timefuncs.py
+
+
 2006-03-17 10:34:24 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-479
 
     Summary:
--- a/MoinMoin/Page.py	Fri Mar 17 09:34:24 2006 +0000
+++ b/MoinMoin/Page.py	Sat Mar 18 11:56:51 2006 +0000
@@ -10,8 +10,7 @@
 
 from MoinMoin import config, caching, user, util, wikiutil
 from MoinMoin.logfile import eventlog
-from MoinMoin.util import filesys, MoinMoinNoFooter
-from MoinMoin.util.datetime import formathttpdate
+from MoinMoin.util import filesys, MoinMoinNoFooter, timefuncs
 
 class Page:
     """Page - Manage an (immutable) page associated with a WikiName.
@@ -1138,7 +1137,7 @@
                     # use the correct last-modified value from the on-disk file
                     # to ensure cacheability where supported
                     request.http_headers(["Last-Modified: " +
-                         formathttpdate(os.path.getmtime(self._text_filename()))])
+                         timefuncs.formathttpdate(os.path.getmtime(self._text_filename()))])
 
             else:
                 request.http_headers(['Status: 404 NOTFOUND'])
--- a/MoinMoin/PageEditor.py	Fri Mar 17 09:34:24 2006 +0000
+++ b/MoinMoin/PageEditor.py	Sat Mar 18 11:56:51 2006 +0000
@@ -13,10 +13,9 @@
 from MoinMoin.widget import html
 from MoinMoin.widget.dialog import Status
 from MoinMoin.logfile import editlog, eventlog
-from MoinMoin.util import filesys
+from MoinMoin.util import filesys, timefuncs
 import MoinMoin.util.web
 import MoinMoin.util.mail
-import MoinMoin.util.datetime
 
 
 #############################################################################
@@ -583,7 +582,7 @@
         """
         # TODO: Allow addition of variables via wikiconfig or a global
         # wiki dict.
-        now = time.strftime("%Y-%m-%dT%H:%M:%SZ", util.datetime.tmtuple())
+        now = time.strftime("%Y-%m-%dT%H:%M:%SZ", timefuncs.tmtuple())
         user = self.request.user
         signature = user.signature()
         variables = {
--- a/MoinMoin/PageGraphicalEditor.py	Fri Mar 17 09:34:24 2006 +0000
+++ b/MoinMoin/PageGraphicalEditor.py	Sat Mar 18 11:56:51 2006 +0000
@@ -17,7 +17,6 @@
 from MoinMoin.util import filesys
 import MoinMoin.util.web
 import MoinMoin.util.mail
-import MoinMoin.util.datetime
 from MoinMoin.parser.wiki import Parser
 
 from StringIO import StringIO
--- a/MoinMoin/action/rss_rc.py	Fri Mar 17 09:34:24 2006 +0000
+++ b/MoinMoin/action/rss_rc.py	Sat Mar 18 11:56:51 2006 +0000
@@ -8,9 +8,9 @@
     @license: GNU GPL, see COPYING for details.
 """
 import StringIO, re, os, time
-from MoinMoin import wikixml, config, wikiutil, util
+from MoinMoin import wikixml, config, wikiutil
 from MoinMoin.logfile import editlog
-from MoinMoin.util.datetime import formathttpdate
+from MoinMoin.util import timefuncs
 from MoinMoin.Page import Page
 from MoinMoin.wikixml.util import RssGenerator
 
@@ -68,7 +68,7 @@
             ((line.pagename in pages) and unique)): continue
         #if log.dayChanged() and log.daycount > _MAX_DAYS: break
         line.editor = line.getInterwikiEditorData(request)
-        line.time = util.datetime.tmtuple(wikiutil.version2timestamp(line.ed_time_usecs)) # UTC
+        line.time = timefuncs.tmtuple(wikiutil.version2timestamp(line.ed_time_usecs)) # UTC
         logdata.append(line)
         pages[line.pagename] = None
 
@@ -149,7 +149,7 @@
         else:
             handler.simpleNode('link', link)
             
-        handler.simpleNode(('dc', 'date'), util.W3CDate(item.time))
+        handler.simpleNode(('dc', 'date'), timefuncs.W3CDate(item.time))
 
         # description
         desc_text = item.comment
@@ -208,15 +208,15 @@
 
     # generate an Expires header, using whatever setting the admin
     # defined for suggested cache lifetime of the RecentChanges RSS doc
-    expires = formathttpdate(time.time() + cfg.rss_cache)
+    expires = timefuncs.formathttpdate(time.time() + cfg.rss_cache)
 
     httpheaders = ["Content-Type: text/xml; charset=%s" % config.charset,
-                        "Expires: "+expires]
+                   "Expires: %s" % expires]
 
     # use a correct Last-Modified header, set to whatever the mod date
     # on the most recent page was; if there were no mods, don't send one
     if lastmod:
-        httpheaders.append("Last-Modified: "+formathttpdate(lastmod))
+        httpheaders.append("Last-Modified: %s" % timefuncs.formathttpdate(lastmod))
 
     # send the generated XML document
     request.http_headers(httpheaders)
--- a/MoinMoin/i18n/POTFILES.in	Fri Mar 17 09:34:24 2006 +0000
+++ b/MoinMoin/i18n/POTFILES.in	Sat Mar 18 11:56:51 2006 +0000
@@ -76,8 +76,6 @@
 theme/rightsidebar.py
 theme/modern.py
 
-util/antispam.py
-
 webapi/color.py
 
 widget/base.py
@@ -85,13 +83,14 @@
 widget/html.py
 
 util/__init__.py
+util/antispam.py
 util/dataset.py
-util/datetime.py
 util/diff.py
 util/diff3.py
 util/filesys.py
 util/mail.py
 util/pysupport.py
+util/timefuncs.py
 util/web.py
 util/wikiext.py
 
--- a/MoinMoin/server/standalone.py	Fri Mar 17 09:34:24 2006 +0000
+++ b/MoinMoin/server/standalone.py	Sat Mar 18 11:56:51 2006 +0000
@@ -34,15 +34,13 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-# Imports
 import os, sys, time, socket, errno, shutil
 import BaseHTTPServer, SimpleHTTPServer, SocketServer
 
-# MoinMoin imports
 from MoinMoin import version, wikiutil
 from MoinMoin.server import Config, switchUID
 from MoinMoin.request import RequestStandAlone
-from MoinMoin.util.datetime import formathttpdate
+from MoinMoin.util import timefuncs
 
 # Server globals
 httpd = None
@@ -371,7 +369,7 @@
         if self.expires:
             now = time.time()
             expires = now + self.expires
-            self.send_header('Expires', formathttpdate(expires))
+            self.send_header('Expires', timefuncs.formathttpdate(expires))
         SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)
         
     def copyfile(self, source, outputfile):
--- a/MoinMoin/stats/hitcounts.py	Fri Mar 17 09:34:24 2006 +0000
+++ b/MoinMoin/stats/hitcounts.py	Sat Mar 18 11:56:51 2006 +0000
@@ -16,7 +16,7 @@
 
 from MoinMoin import caching, config, wikiutil
 from MoinMoin.Page import Page
-from MoinMoin.util import MoinMoinNoFooter, datetime
+from MoinMoin.util import MoinMoinNoFooter
 from MoinMoin.formatter.text_html import Formatter
 from MoinMoin.logfile import eventlog, logfile
 
--- a/MoinMoin/user.py	Fri Mar 17 09:34:24 2006 +0000
+++ b/MoinMoin/user.py	Sat Mar 18 11:56:51 2006 +0000
@@ -17,7 +17,7 @@
 PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL
 
 from MoinMoin import config, caching, wikiutil
-from MoinMoin.util import datetime, filesys
+from MoinMoin.util import filesys, timefuncs
 
 
 def getUserList(request):
@@ -538,7 +538,7 @@
         @rtype: int
         @return: tm tuple adjusted for user's timezone
         """
-        return datetime.tmtuple(tm + self.tz_offset)
+        return timefuncs.tmtuple(tm + self.tz_offset)
 
 
     def getFormattedDate(self, tm):
--- a/MoinMoin/userform.py	Fri Mar 17 09:34:24 2006 +0000
+++ b/MoinMoin/userform.py	Sat Mar 18 11:56:51 2006 +0000
@@ -8,7 +8,7 @@
 
 import string, time, re
 from MoinMoin import user, util, wikiutil
-from MoinMoin.util import web, mail, datetime
+from MoinMoin.util import web, mail, timefuncs
 from MoinMoin.widget import html
 
 _debug = 0
@@ -364,7 +364,7 @@
             options.append((
                 str(offset),
                 '%s [%s%s:%s]' % (
-                    time.strftime(self.cfg.datetime_fmt, util.datetime.tmtuple(t)),
+                    time.strftime(self.cfg.datetime_fmt, timefuncs.tmtuple(t)),
                     "+-"[offset < 0],
                     string.zfill("%d" % (abs(offset) / 3600), 2),
                     string.zfill("%d" % (abs(offset) % 3600 / 60), 2),
@@ -523,7 +523,7 @@
                     self._tz_select(),
                     html.BR(),
                     _('Server time is'), ' ',
-                    time.strftime(self.cfg.datetime_fmt, util.datetime.tmtuple()),
+                    time.strftime(self.cfg.datetime_fmt, timefuncs.tmtuple()),
                     ' (UTC)',
                 ])
 
--- a/MoinMoin/util/__init__.py	Fri Mar 17 09:34:24 2006 +0000
+++ b/MoinMoin/util/__init__.py	Sat Mar 18 11:56:51 2006 +0000
@@ -7,10 +7,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import os
-import sys
-import re
-import time
+import os, sys, re
 
 #############################################################################
 ### XML helper functions
@@ -82,13 +79,6 @@
         return pattern[1:-1]
     return pattern[1:]
 
-
-def W3CDate(tm=None):
-    """ Return time string according to http://www.w3.org/TR/NOTE-datetime
-    """
-    if not tm: tm = time.gmtime()
-    return time.strftime("%Y-%m-%dT%H:%M:%S", tm) + "Z"
-
 def dumpFormData(form):
     """ Dump the form data for debugging purposes
     """
@@ -129,3 +119,4 @@
 
     def close(self):
         self.buffer = None
+
--- a/MoinMoin/util/datetime.py	Fri Mar 17 09:34:24 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - Date & Time Utilities
-
-    @copyright: 2003 by Jürgen Hermann <jh@web.de>
-    @license: GNU GPL, see COPYING for details.
-"""
-
-# we guarantee that time is always imported!
-import time
-import re
-from email.Utils import formatdate
-
-def tmtuple(tmsecs=None):
-    """ Return a time tuple.
-
-        This is currently an alias for gmtime(), but allows later tweaking.
-    """
-    # avoid problems due to timezones etc. - especially a underflow
-    if -86400 <= tmsecs <= 86400: # if we are around 0, we maybe had
-        tmsecs = 0                # 0 initially, so reset it to 0.
-    return time.gmtime(tmsecs or time.time())
-
-def formathttpdate(tmsecs=None):
-    """ Return a HTTP date/time stamp as defined in
-        http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3 .
-    """
-    stamp = formatdate(tmsecs, False)
-    # replace non-standard "-0000" at end with http-mandated "GMT"
-    stamp = re.match('^(.*) [\-\+]0000$', stamp).group(1) + " GMT"
-    return stamp
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/util/timefuncs.py	Sat Mar 18 11:56:51 2006 +0000
@@ -0,0 +1,38 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - Date & Time Utilities
+
+    @copyright: 2003 by Jürgen Hermann <jh@web.de>
+    @license: GNU GPL, see COPYING for details.
+"""
+
+# we guarantee that time is always imported!
+import re, time
+from email.Utils import formatdate
+
+def tmtuple(tmsecs=None):
+    """ Return a time tuple.
+
+        This is currently an alias for gmtime(), but allows later tweaking.
+    """
+    # avoid problems due to timezones etc. - especially a underflow
+    if -86400 <= tmsecs <= 86400: # if we are around 0, we maybe had
+        tmsecs = 0                # 0 initially, so reset it to 0.
+    return time.gmtime(tmsecs or time.time())
+
+def formathttpdate(tmsecs=None):
+    """ Return a HTTP date/time stamp as defined in
+        http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3 .
+    """
+    stamp = formatdate(tmsecs, False)
+    # replace non-standard "-0000" at end with http-mandated "GMT"
+    stamp = re.match('^(.*) [\-\+]0000$', stamp).group(1) + " GMT"
+    return stamp
+
+def W3CDate(tmsecs=None):
+    """ Return UTC time string according to http://www.w3.org/TR/NOTE-datetime
+    """
+    if not tmsecs:
+        tmsecs = time.gmtime()
+    return time.strftime("%Y-%m-%dT%H:%M:%S", tmsecs) + "Z"
+