comparison roundup/hyperdb.py @ 270:a4241ddd22d7

Added the Password property type. See "pydoc roundup.password" for implementation details. Have updated some of the documentation too.
author Richard Jones <richard@users.sourceforge.net>
date Tue, 09 Oct 2001 07:25:59 +0000
parents a671e5917b33
children 1cc866cec608
comparison
equal deleted inserted replaced
269:82cfd78f3c4e 270:a4241ddd22d7
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: hyperdb.py,v 1.21 2001-10-05 02:23:24 richard Exp $ 18 # $Id: hyperdb.py,v 1.22 2001-10-09 07:25:59 richard Exp $
19 19
20 # standard python modules 20 # standard python modules
21 import cPickle, re, string 21 import cPickle, re, string
22 22
23 # roundup modules 23 # roundup modules
24 import date 24 import date, password
25 25
26 26
27 # 27 #
28 # Types 28 # Types
29 # 29 #
30 class String: 30 class String:
31 """An object designating a String property.""" 31 """An object designating a String property."""
32 def __repr__(self):
33 return '<%s>'%self.__class__
34
35 class Password:
36 """An object designating a Password property."""
32 def __repr__(self): 37 def __repr__(self):
33 return '<%s>'%self.__class__ 38 return '<%s>'%self.__class__
34 39
35 class Date: 40 class Date:
36 """An object designating a Date property.""" 41 """An object designating a Date property."""
187 192
188 elif isinstance(prop, String): 193 elif isinstance(prop, String):
189 if type(value) != type(''): 194 if type(value) != type(''):
190 raise TypeError, 'new property "%s" not a string'%key 195 raise TypeError, 'new property "%s" not a string'%key
191 196
197 elif isinstance(prop, Password):
198 if not isinstance(value, password.Password):
199 raise TypeError, 'new property "%s" not a Password'%key
200
192 elif isinstance(prop, Date): 201 elif isinstance(prop, Date):
193 if not isinstance(value, date.Date): 202 if not isinstance(value, date.Date):
194 raise TypeError, 'new property "%s" not a Date'% key 203 raise TypeError, 'new property "%s" not a Date'%key
195 204
196 elif isinstance(prop, Interval): 205 elif isinstance(prop, Interval):
197 if not isinstance(value, date.Interval): 206 if not isinstance(value, date.Interval):
198 raise TypeError, 'new property "%s" not an Interval'% key 207 raise TypeError, 'new property "%s" not an Interval'%key
199 208
200 for key, prop in self.properties.items(): 209 for key, prop in self.properties.items():
201 if propvalues.has_key(key): 210 if propvalues.has_key(key):
202 continue 211 continue
203 if key == self.key: 212 if key == self.key:
345 354
346 elif isinstance(prop, String): 355 elif isinstance(prop, String):
347 if value is not None and type(value) != type(''): 356 if value is not None and type(value) != type(''):
348 raise TypeError, 'new property "%s" not a string'%key 357 raise TypeError, 'new property "%s" not a string'%key
349 358
359 elif isinstance(prop, Password):
360 if not isinstance(value, password.Password):
361 raise TypeError, 'new property "%s" not a Password'% key
362
350 elif isinstance(prop, Date): 363 elif isinstance(prop, Date):
351 if not isinstance(value, date.Date): 364 if not isinstance(value, date.Date):
352 raise TypeError, 'new property "%s" not a Date'% key 365 raise TypeError, 'new property "%s" not a Date'% key
353 366
354 elif isinstance(prop, Interval): 367 elif isinstance(prop, Interval):
398 411
399 'propname' must be the name of a String property of this class or 412 'propname' must be the name of a String property of this class or
400 None, or a TypeError is raised. The values of the key property on 413 None, or a TypeError is raised. The values of the key property on
401 all existing nodes must be unique or a ValueError is raised. 414 all existing nodes must be unique or a ValueError is raised.
402 """ 415 """
416 # TODO: validate that the property is a String!
403 self.key = propname 417 self.key = propname
404 418
405 def getkey(self): 419 def getkey(self):
406 """Return the name of the key property for this class or None.""" 420 """Return the name of the key property for this class or None."""
407 return self.key 421 return self.key
798 cl.create(name=option[i], order=i) 812 cl.create(name=option[i], order=i)
799 return hyperdb.Link(name) 813 return hyperdb.Link(name)
800 814
801 # 815 #
802 # $Log: not supported by cvs2svn $ 816 # $Log: not supported by cvs2svn $
817 # Revision 1.21 2001/10/05 02:23:24 richard
818 # . roundup-admin create now prompts for property info if none is supplied
819 # on the command-line.
820 # . hyperdb Class getprops() method may now return only the mutable
821 # properties.
822 # . Login now uses cookies, which makes it a whole lot more flexible. We can
823 # now support anonymous user access (read-only, unless there's an
824 # "anonymous" user, in which case write access is permitted). Login
825 # handling has been moved into cgi_client.Client.main()
826 # . The "extended" schema is now the default in roundup init.
827 # . The schemas have had their page headings modified to cope with the new
828 # login handling. Existing installations should copy the interfaces.py
829 # file from the roundup lib directory to their instance home.
830 # . Incorrectly had a Bizar Software copyright on the cgitb.py module from
831 # Ping - has been removed.
832 # . Fixed a whole bunch of places in the CGI interface where we should have
833 # been returning Not Found instead of throwing an exception.
834 # . Fixed a deviation from the spec: trying to modify the 'id' property of
835 # an item now throws an exception.
836 #
803 # Revision 1.20 2001/10/04 02:12:42 richard 837 # Revision 1.20 2001/10/04 02:12:42 richard
804 # Added nicer command-line item adding: passing no arguments will enter an 838 # Added nicer command-line item adding: passing no arguments will enter an
805 # interactive more which asks for each property in turn. While I was at it, I 839 # interactive more which asks for each property in turn. While I was at it, I
806 # fixed an implementation problem WRT the spec - I wasn't raising a 840 # fixed an implementation problem WRT the spec - I wasn't raising a
807 # ValueError if the key property was missing from a create(). Also added a 841 # ValueError if the key property was missing from a create(). Also added a

Roundup Issue Tracker: http://roundup-tracker.org/