Skip to content

Commit 781d017

Browse files
author
Richard Jones
committed
bugger, dropping support for "+" special char
1 parent 7a18b83 commit 781d017

File tree

3 files changed

+41
-28
lines changed

3 files changed

+41
-28
lines changed

doc/customizing.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.73 $
5+
:Version: $Revision: 1.74 $
66

77
.. This document borrows from the ZopeBook section on ZPT. The original is at:
88
http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -1290,8 +1290,11 @@ email only on String properties - render the value of the
12901290
confirm only on Password properties - render a second form edit field for
12911291
the property, used for confirmation that the user typed the
12921292
password correctly. Generates a field with name "name:confirm".
1293+
now only on Date properties - return the current date as a new property
12931294
reldate only on Date properties - render the interval between the
12941295
date and now
1296+
local only on Date properties - return this date as a new property with
1297+
some timezone offset
12951298
pretty only on Interval properties - render the interval in a
12961299
pretty format (eg. "yesterday")
12971300
menu only on Link and Multilink properties - render a form select

roundup/cgi/client.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.86 2003-02-16 22:57:09 richard Exp $
1+
# $Id: client.py,v 1.87 2003-02-17 00:39:28 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -83,29 +83,26 @@ class Client:
8383
Special form variables:
8484
Note that in various places throughout this code, special form
8585
variables of the form :<name> are used. The colon (":") part may
86-
actually be one of several characters from the set:
87-
88-
: @ +
89-
86+
actually be one of either ":" or "@".
9087
'''
9188

9289
#
9390
# special form variables
9491
#
95-
FV_TEMPLATE = re.compile(r'[@+:]template')
96-
FV_OK_MESSAGE = re.compile(r'[@+:]ok_message')
97-
FV_ERROR_MESSAGE = re.compile(r'[@+:]error_message')
92+
FV_TEMPLATE = re.compile(r'[@:]template')
93+
FV_OK_MESSAGE = re.compile(r'[@:]ok_message')
94+
FV_ERROR_MESSAGE = re.compile(r'[@:]error_message')
9895

9996
# specials for parsePropsFromForm
100-
FV_REQUIRED = re.compile(r'[@+:]required')
101-
FV_ADD = re.compile(r'([@+:])add\1')
102-
FV_REMOVE = re.compile(r'([@+:])remove\1')
103-
FV_CONFIRM = re.compile(r'.+[@+:]confirm')
104-
FV_LINK = re.compile(r'([@+:])link\1(.+)')
97+
FV_REQUIRED = re.compile(r'[@:]required')
98+
FV_ADD = re.compile(r'([@:])add\1')
99+
FV_REMOVE = re.compile(r'([@:])remove\1')
100+
FV_CONFIRM = re.compile(r'.+[@:]confirm')
101+
FV_LINK = re.compile(r'([@:])link\1(.+)')
105102

106103
# deprecated
107-
FV_NOTE = re.compile(r'[@+:]note')
108-
FV_FILE = re.compile(r'[@+:]file')
104+
FV_NOTE = re.compile(r'[@:]note')
105+
FV_FILE = re.compile(r'[@:]file')
109106

110107
# Note: index page stuff doesn't appear here:
111108
# columns, sort, sortdir, filter, group, groupdir, search_text,
@@ -755,6 +752,7 @@ def newItemAction(self):
755752
special form values.
756753
'''
757754
# parse the props from the form
755+
# XXX reinstate exception handling
758756
# try:
759757
if 1:
760758
props, links = self.parsePropsFromForm()
@@ -763,6 +761,7 @@ def newItemAction(self):
763761
# return
764762

765763
# handle the props - edit or create
764+
# XXX reinstate exception handling
766765
# try:
767766
if 1:
768767
# create the context here
@@ -785,7 +784,7 @@ def newItemAction(self):
785784
self.db.commit()
786785

787786
# redirect to the new item's page
788-
raise Redirect, '%s%s%s?:ok_message=%s'%(self.base, self.classname,
787+
raise Redirect, '%s%s%s?@ok_message=%s'%(self.base, self.classname,
789788
nid, urllib.quote(messages))
790789

791790
def newItemPermission(self, props):
@@ -910,6 +909,7 @@ def searchAction(self):
910909
_('You do not have permission to search %s' %self.classname))
911910

912911
# add a faked :filter form variable for each filtering prop
912+
# XXX migrate to new : @ +
913913
props = self.db.classes[self.classname].getprops()
914914
for key in self.form.keys():
915915
if not props.has_key(key): continue
@@ -1004,6 +1004,7 @@ def retirePermission(self):
10041004
def showAction(self):
10051005
''' Show a node
10061006
'''
1007+
# XXX allow : @ +
10071008
t = self.form[':type'].value
10081009
n = self.form[':number'].value
10091010
url = '%s%s%s'%(self.db.config.TRACKER_WEB, t, n)
@@ -1097,7 +1098,7 @@ def parsePropsFromForm(self, num_re=re.compile('^\d+$')):
10971098
''' Pull properties for the given class out of the form.
10981099
10991100
In the following, <bracketed> values are variable, ":" may be
1100-
any of : @ + and other text "required" is fixed.
1101+
one of ":" or "@", and other text "required" is fixed.
11011102
11021103
Properties are specified as form variables
11031104
<designator>:<propname>
@@ -1126,7 +1127,7 @@ def parsePropsFromForm(self, num_re=re.compile('^\d+$')):
11261127
[classname|designator] will be set/appended the id of the
11271128
newly created item of class <classname>.
11281129
1129-
Note: the colon may be one of: : @ +
1130+
Note: the colon may be either ":" or "@".
11301131
11311132
Any of the form variables may be prefixed with a classname or
11321133
designator.
@@ -1158,7 +1159,7 @@ def parsePropsFromForm(self, num_re=re.compile('^\d+$')):
11581159
# generate the regexp for detecting
11591160
# <classname|designator>[@:+]property
11601161
classes = '|'.join(db.classes.keys())
1161-
self.FV_ITEMSPEC = re.compile(r'(%s)([-\d]+)[@+:](.+)$'%classes)
1162+
self.FV_ITEMSPEC = re.compile(r'(%s)([-\d]+)[@:](.+)$'%classes)
11621163
self.FV_DESIGNATOR = re.compile(r'(%s)([-\d]+)'%classes)
11631164

11641165
# these indicate the default class / item

roundup/cgi/templating.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,15 @@ def plain(self):
927927
return ''
928928
return str(self._value.local(self._db.getUserTimezone()))
929929

930+
def now(self):
931+
''' Return the current time.
932+
933+
This is useful for defaulting a new value. Returns a
934+
DateHTMLProperty.
935+
'''
936+
return DateHTMLProperty(self._client, self._nodeid, self._prop,
937+
self._name, date.Date('.'))
938+
930939
def field(self, size = 30):
931940
''' Render a form edit field for the property
932941
'''
@@ -965,7 +974,7 @@ def local(self, offset):
965974
''' Return the date/time as a local (timezone offset) date/time.
966975
'''
967976
return DateHTMLProperty(self._client, self._nodeid, self._prop,
968-
self._name, self._value.local())
977+
self._name, self._value.local(offset))
969978

970979
class IntervalHTMLProperty(HTMLProperty):
971980
def plain(self):
@@ -1351,7 +1360,7 @@ def _post_init(self):
13511360
'''
13521361
# extract the index display information from the form
13531362
self.columns = []
1354-
for name in ':columns +columns @columns'.split():
1363+
for name in ':columns @columns'.split():
13551364
if self.form.has_key(name):
13561365
self.special_char = name[0]
13571366
self.columns = handleListCGIValue(self.form[name])
@@ -1360,7 +1369,7 @@ def _post_init(self):
13601369

13611370
# sorting
13621371
self.sort = (None, None)
1363-
for name in ':sort +sort @sort'.split():
1372+
for name in ':sort @sort'.split():
13641373
if self.form.has_key(name):
13651374
self.special_char = name[0]
13661375
sort = self.form[name].value
@@ -1373,7 +1382,7 @@ def _post_init(self):
13731382

13741383
# grouping
13751384
self.group = (None, None)
1376-
for name in ':group +group @group'.split():
1385+
for name in ':group @group'.split():
13771386
if self.form.has_key(name):
13781387
self.special_char = name[0]
13791388
group = self.form[name].value
@@ -1386,7 +1395,7 @@ def _post_init(self):
13861395

13871396
# filtering
13881397
self.filter = []
1389-
for name in ':filter +filter @filter'.split():
1398+
for name in ':filter @filter'.split():
13901399
if self.form.has_key(name):
13911400
self.special_char = name[0]
13921401
self.filter = handleListCGIValue(self.form[name])
@@ -1408,21 +1417,21 @@ def _post_init(self):
14081417

14091418
# full-text search argument
14101419
self.search_text = None
1411-
for name in ':search_text +search_text @search_text'.split():
1420+
for name in ':search_text @search_text'.split():
14121421
if self.form.has_key(name):
14131422
self.special_char = name[0]
14141423
self.search_text = self.form[name].value
14151424

14161425
# pagination - size and start index
14171426
# figure batch args
14181427
self.pagesize = 50
1419-
for name in ':pagesize +pagesize @pagesize'.split():
1428+
for name in ':pagesize @pagesize'.split():
14201429
if self.form.has_key(name):
14211430
self.special_char = name[0]
14221431
self.pagesize = int(self.form[name].value)
14231432

14241433
self.startwith = 0
1425-
for name in ':startwith +startwith @startwith'.split():
1434+
for name in ':startwith @startwith'.split():
14261435
if self.form.has_key(name):
14271436
self.special_char = name[0]
14281437
self.startwith = int(self.form[name].value)

0 commit comments

Comments
 (0)