Mercurial > p > roundup > code
comparison roundup/cgi/templating.py @ 1104:d759c3cb1f06
Remeber values in edit/new submission error pages.
Some work done on query editing (search refinement)
Fixed logout link to work with cgi-bin
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 10 Sep 2002 23:05:00 +0000 |
| parents | db787cef1385 |
| children | a95428868bf4 |
comparison
equal
deleted
inserted
replaced
| 1103:db787cef1385 | 1104:d759c3cb1f06 |
|---|---|
| 200 return HTMLClass(self._client, attr) | 200 return HTMLClass(self._client, attr) |
| 201 def classes(self): | 201 def classes(self): |
| 202 l = self._client.db.classes.keys() | 202 l = self._client.db.classes.keys() |
| 203 l.sort() | 203 l.sort() |
| 204 return [HTMLClass(self._client, cn) for cn in l] | 204 return [HTMLClass(self._client, cn) for cn in l] |
| 205 | 205 |
| 206 def lookupIds(db, prop, ids, num_re=re.compile('-?\d+')): | |
| 207 cl = db.getclass(prop.classname) | |
| 208 l = [] | |
| 209 for entry in ids: | |
| 210 if num_re.match(entry): | |
| 211 l.append(entry) | |
| 212 else: | |
| 213 l.append(cl.lookup(entry)) | |
| 214 return l | |
| 215 | |
| 206 class HTMLClass: | 216 class HTMLClass: |
| 207 ''' Accesses through a class (either through *class* or *db.<classname>*) | 217 ''' Accesses through a class (either through *class* or *db.<classname>*) |
| 208 ''' | 218 ''' |
| 209 def __init__(self, client, classname): | 219 def __init__(self, client, classname): |
| 210 self._client = client | 220 self._client = client |
| 230 | 240 |
| 231 # get the property | 241 # get the property |
| 232 prop = self._props[item] | 242 prop = self._props[item] |
| 233 | 243 |
| 234 # look up the correct HTMLProperty class | 244 # look up the correct HTMLProperty class |
| 245 form = self._client.form | |
| 235 for klass, htmlklass in propclasses: | 246 for klass, htmlklass in propclasses: |
| 236 if isinstance(prop, hyperdb.Multilink): | 247 if not isinstance(prop, klass): |
| 237 value = [] | 248 continue |
| 249 if form.has_key(item): | |
| 250 if isinstance(prop, hyperdb.Multilink): | |
| 251 value = lookupIds(self._db, prop, | |
| 252 handleListCGIValue(form[item])) | |
| 253 elif isinstance(prop, hyperdb.Link): | |
| 254 value = form[item].value.strip() | |
| 255 if value: | |
| 256 value = lookupIds(self._db, prop, [value])[0] | |
| 257 else: | |
| 258 value = None | |
| 259 else: | |
| 260 value = form[item].value.strip() or None | |
| 238 else: | 261 else: |
| 239 value = None | 262 if isinstance(prop, hyperdb.Multilink): |
| 240 if isinstance(prop, klass): | 263 value = [] |
| 241 return htmlklass(self._client, '', prop, item, value) | 264 else: |
| 265 value = None | |
| 266 print (prop, value) | |
| 267 return htmlklass(self._client, '', prop, item, value) | |
| 242 | 268 |
| 243 # no good | 269 # no good |
| 244 raise KeyError, item | 270 raise KeyError, item |
| 245 | 271 |
| 246 def __getattr__(self, attr): | 272 def __getattr__(self, attr): |
| 985 .value that we're actually interested in. | 1011 .value that we're actually interested in. |
| 986 ''' | 1012 ''' |
| 987 if isinstance(value, type([])): | 1013 if isinstance(value, type([])): |
| 988 return [value.value for value in value] | 1014 return [value.value for value in value] |
| 989 else: | 1015 else: |
| 990 return value.value.split(',') | 1016 value = value.value.strip() |
| 1017 if not value: | |
| 1018 return [] | |
| 1019 return value.split(',') | |
| 991 | 1020 |
| 992 class ShowDict: | 1021 class ShowDict: |
| 993 ''' A convenience access to the :columns index parameters | 1022 ''' A convenience access to the :columns index parameters |
| 994 ''' | 1023 ''' |
| 995 def __init__(self, columns): | 1024 def __init__(self, columns): |
