]> git.tokkee.org Git - roundup.git/commitdiff

Code

bugger, dropping support for "+" special char
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 17 Feb 2003 00:39:28 +0000 (00:39 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 17 Feb 2003 00:39:28 +0000 (00:39 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1514 57a73879-2fb5-44c3-a270-3262357dd7e2

doc/customizing.txt
roundup/cgi/client.py
roundup/cgi/templating.py

index a1b46ac3172f61e75c3bedf0cab5843160cf18f0..bcaf3d3555e4154e037a3a561db1798f6d628ae5 100644 (file)
@@ -2,7 +2,7 @@
 Customising Roundup
 ===================
 
-:Version: $Revision: 1.73 $
+:Version: $Revision: 1.74 $
 
 .. This document borrows from the ZopeBook section on ZPT. The original is at:
    http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -1290,8 +1290,11 @@ email     only on String properties - render the value of the
 confirm   only on Password properties - render a second form edit field for
           the property, used for confirmation that the user typed the
           password correctly. Generates a field with name "name:confirm".
+now       only on Date properties - return the current date as a new property
 reldate   only on Date properties - render the interval between the
           date and now
+local     only on Date properties - return this date as a new property with
+          some timezone offset
 pretty    only on Interval properties - render the interval in a
           pretty format (eg. "yesterday")
 menu      only on Link and Multilink properties - render a form select
index 74e19a871499d75ac314f1901e5287b70b6052a9..23edf8fdacb330c5cfbe7159b3096f5db8405fb1 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: client.py,v 1.86 2003-02-16 22:57:09 richard Exp $
+# $Id: client.py,v 1.87 2003-02-17 00:39:28 richard Exp $
 
 __doc__ = """
 WWW request handler (also used in the stand-alone server).
@@ -83,29 +83,26 @@ class Client:
     Special form variables:
      Note that in various places throughout this code, special form
      variables of the form :<name> are used. The colon (":") part may
-     actually be one of several characters from the set:
-
-       : @ + 
-
+     actually be one of either ":" or "@".
     '''
 
     #
     # special form variables
     #
-    FV_TEMPLATE = re.compile(r'[@+:]template')
-    FV_OK_MESSAGE = re.compile(r'[@+:]ok_message')
-    FV_ERROR_MESSAGE = re.compile(r'[@+:]error_message')
+    FV_TEMPLATE = re.compile(r'[@:]template')
+    FV_OK_MESSAGE = re.compile(r'[@:]ok_message')
+    FV_ERROR_MESSAGE = re.compile(r'[@:]error_message')
 
     # specials for parsePropsFromForm
-    FV_REQUIRED = re.compile(r'[@+:]required')
-    FV_ADD = re.compile(r'([@+:])add\1')
-    FV_REMOVE = re.compile(r'([@+:])remove\1')
-    FV_CONFIRM = re.compile(r'.+[@+:]confirm')
-    FV_LINK = re.compile(r'([@+:])link\1(.+)')
+    FV_REQUIRED = re.compile(r'[@:]required')
+    FV_ADD = re.compile(r'([@:])add\1')
+    FV_REMOVE = re.compile(r'([@:])remove\1')
+    FV_CONFIRM = re.compile(r'.+[@:]confirm')
+    FV_LINK = re.compile(r'([@:])link\1(.+)')
 
     # deprecated
-    FV_NOTE = re.compile(r'[@+:]note')
-    FV_FILE = re.compile(r'[@+:]file')
+    FV_NOTE = re.compile(r'[@:]note')
+    FV_FILE = re.compile(r'[@:]file')
 
     # Note: index page stuff doesn't appear here:
     # columns, sort, sortdir, filter, group, groupdir, search_text,
@@ -755,6 +752,7 @@ class Client:
             special form values.
         '''
         # parse the props from the form
+# XXX reinstate exception handling
 #        try:
         if 1:
             props, links = self.parsePropsFromForm()
@@ -763,6 +761,7 @@ class Client:
 #            return
 
         # handle the props - edit or create
+# XXX reinstate exception handling
 #        try:
         if 1:
             # create the context here
@@ -785,7 +784,7 @@ class Client:
         self.db.commit()
 
         # redirect to the new item's page
-        raise Redirect, '%s%s%s?:ok_message=%s'%(self.base, self.classname,
+        raise Redirect, '%s%s%s?@ok_message=%s'%(self.base, self.classname,
             nid, urllib.quote(messages))
 
     def newItemPermission(self, props):
@@ -910,6 +909,7 @@ class Client:
                 _('You do not have permission to search %s' %self.classname))
 
         # add a faked :filter form variable for each filtering prop
+# XXX migrate to new : @ + 
         props = self.db.classes[self.classname].getprops()
         for key in self.form.keys():
             if not props.has_key(key): continue
@@ -1004,6 +1004,7 @@ class Client:
     def showAction(self):
         ''' Show a node
         '''
+# XXX allow : @ +
         t = self.form[':type'].value
         n = self.form[':number'].value
         url = '%s%s%s'%(self.db.config.TRACKER_WEB, t, n)
@@ -1097,7 +1098,7 @@ class Client:
         ''' Pull properties for the given class out of the form.
 
             In the following, <bracketed> values are variable, ":" may be
-            any of : @ + and other text "required" is fixed.
+            one of ":" or "@", and other text "required" is fixed.
 
             Properties are specified as form variables
              <designator>:<propname>
@@ -1126,7 +1127,7 @@ class Client:
               [classname|designator] will be set/appended the id of the
               newly created item of class <classname>.
 
-            Note: the colon may be one of:  : @ +
+            Note: the colon may be either ":" or "@".
 
             Any of the form variables may be prefixed with a classname or
             designator.
@@ -1158,7 +1159,7 @@ class Client:
             # generate the regexp for detecting
             # <classname|designator>[@:+]property
             classes = '|'.join(db.classes.keys())
-            self.FV_ITEMSPEC = re.compile(r'(%s)([-\d]+)[@+:](.+)$'%classes)
+            self.FV_ITEMSPEC = re.compile(r'(%s)([-\d]+)[@:](.+)$'%classes)
             self.FV_DESIGNATOR = re.compile(r'(%s)([-\d]+)'%classes)
 
         # these indicate the default class / item
index 87243a763148265c8158cde0e4eba6b3d03512c1..6992e061f3625c758953e864dd880af262cb00fe 100644 (file)
@@ -927,6 +927,15 @@ class DateHTMLProperty(HTMLProperty):
             return ''
         return str(self._value.local(self._db.getUserTimezone()))
 
+    def now(self):
+        ''' Return the current time.
+
+            This is useful for defaulting a new value. Returns a
+            DateHTMLProperty.
+        '''
+        return DateHTMLProperty(self._client, self._nodeid, self._prop,
+            self._name, date.Date('.'))
+
     def field(self, size = 30):
         ''' Render a form edit field for the property
         '''
@@ -965,7 +974,7 @@ class DateHTMLProperty(HTMLProperty):
         ''' Return the date/time as a local (timezone offset) date/time.
         '''
         return DateHTMLProperty(self._client, self._nodeid, self._prop,
-            self._name, self._value.local())
+            self._name, self._value.local(offset))
 
 class IntervalHTMLProperty(HTMLProperty):
     def plain(self):
@@ -1351,7 +1360,7 @@ class HTMLRequest:
         '''
         # extract the index display information from the form
         self.columns = []
-        for name in ':columns +columns @columns'.split():
+        for name in ':columns @columns'.split():
             if self.form.has_key(name):
                 self.special_char = name[0]
                 self.columns = handleListCGIValue(self.form[name])
@@ -1360,7 +1369,7 @@ class HTMLRequest:
 
         # sorting
         self.sort = (None, None)
-        for name in ':sort +sort @sort'.split():
+        for name in ':sort @sort'.split():
             if self.form.has_key(name):
                 self.special_char = name[0]
                 sort = self.form[name].value
@@ -1373,7 +1382,7 @@ class HTMLRequest:
 
         # grouping
         self.group = (None, None)
-        for name in ':group +group @group'.split():
+        for name in ':group @group'.split():
             if self.form.has_key(name):
                 self.special_char = name[0]
                 group = self.form[name].value
@@ -1386,7 +1395,7 @@ class HTMLRequest:
 
         # filtering
         self.filter = []
-        for name in ':filter +filter @filter'.split():
+        for name in ':filter @filter'.split():
             if self.form.has_key(name):
                 self.special_char = name[0]
                 self.filter = handleListCGIValue(self.form[name])
@@ -1408,7 +1417,7 @@ class HTMLRequest:
 
         # full-text search argument
         self.search_text = None
-        for name in ':search_text +search_text @search_text'.split():
+        for name in ':search_text @search_text'.split():
             if self.form.has_key(name):
                 self.special_char = name[0]
                 self.search_text = self.form[name].value
@@ -1416,13 +1425,13 @@ class HTMLRequest:
         # pagination - size and start index
         # figure batch args
         self.pagesize = 50
-        for name in ':pagesize +pagesize @pagesize'.split():
+        for name in ':pagesize @pagesize'.split():
             if self.form.has_key(name):
                 self.special_char = name[0]
                 self.pagesize = int(self.form[name].value)
 
         self.startwith = 0
-        for name in ':startwith +startwith @startwith'.split():
+        for name in ':startwith @startwith'.split():
             if self.form.has_key(name):
                 self.special_char = name[0]
                 self.startwith = int(self.form[name].value)