summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c16881d)
raw | patch | inline | side by side (parent: c16881d)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 4 Oct 2001 02:12:42 +0000 (02:12 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 4 Oct 2001 02:12:42 +0000 (02:12 +0000) |
interactive more which asks for each property in turn. While I was at it, I
fixed an implementation problem WRT the spec - I wasn't raising a
ValueError if the key property was missing from a create(). Also added a
protected=boolean argument to getprops() so we can list only the mutable
properties (defaults to yes, which lists the immutables).
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@270 57a73879-2fb5-44c3-a270-3262357dd7e2
fixed an implementation problem WRT the spec - I wasn't raising a
ValueError if the key property was missing from a create(). Also added a
protected=boolean argument to getprops() so we can list only the mutable
properties (defaults to yes, which lists the immutables).
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@270 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup-admin | patch | blob | history | |
roundup/hyperdb.py | patch | blob | history | |
roundup/roundupdb.py | patch | blob | history |
diff --git a/roundup-admin b/roundup-admin
index a29c0558262d5239a492d1e6bc9ede09a59be4a2..e8082a421ecd5008fcb92d2c926d9438b9256f32 100755 (executable)
--- a/roundup-admin
+++ b/roundup-admin
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: roundup-admin,v 1.19 2001-10-01 06:40:43 richard Exp $
+# $Id: roundup-admin,v 1.20 2001-10-04 02:12:42 richard Exp $
import sys
if int(sys.version[0]) < 2:
'''
classname = args[0]
cl = db.getclass(classname)
+ keyprop = cl.getkey()
for key, value in cl.properties.items():
- print '%s: %s'%(key, value)
+ if keyprop == key:
+ print '%s: %s (key property)'%(key, value)
+ else:
+ print '%s: %s'%(key, value)
-def do_create(db, args):
+def do_create(db, args, pretty_re=re.compile(r'<roundup\.hyperdb\.(.*)>')):
'''Usage: create classname property=value ...
Create a new entry of a given class.
classname = args[0]
cl = db.getclass(classname)
props = {}
- properties = cl.getprops()
- for prop in args[1:]:
- key, value = prop.split('=')
- type = properties[key]
- if isinstance(type, hyperdb.String):
+ properties = cl.getprops(protected = 0)
+ if len(args) == 1:
+ # ask for the properties
+ for key, value in properties.items():
+ if key == 'id': continue
+ m = pretty_re.match(str(value))
+ if m:
+ value = m.group(1)
+ value = raw_input('%s (%s): '%(key.capitalize(), value))
+ if value:
+ props[key] = value
+ else:
+ # use the args
+ for prop in args[1:]:
+ key, value = prop.split('=')
props[key] = value
- elif isinstance(type, hyperdb.Date):
+
+ # convert types
+ for key in props.keys():
+ type = properties[key]
+ if isinstance(type, hyperdb.Date):
props[key] = date.Date(value)
elif isinstance(type, hyperdb.Interval):
props[key] = date.Interval(value)
- elif isinstance(type, hyperdb.Link):
- props[key] = value
elif isinstance(type, hyperdb.Multilink):
props[key] = value.split(',')
- print apply(cl.create, (), props)
+
+ if cl.getkey() and not props.has_key(cl.getkey()):
+ print "You must provide the '%s' property."%cl.getkey()
+ else:
+ print apply(cl.create, (), props)
+
return 0
def do_list(db, args):
#
# $Log: not supported by cvs2svn $
+# Revision 1.19 2001/10/01 06:40:43 richard
+# made do_get have the args in the correct order
+#
# Revision 1.18 2001/09/18 22:58:37 richard
#
# Added some more help to roundu-admin
diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py
index 57a95b17a5bd7123e4e8af5f7c373745ee5f09e4..367abac6dd8847da3c0bfc9380bd4b042177b88a 100644 (file)
--- a/roundup/hyperdb.py
+++ b/roundup/hyperdb.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: hyperdb.py,v 1.19 2001-08-29 04:47:18 richard Exp $
+# $Id: hyperdb.py,v 1.20 2001-10-04 02:12:42 richard Exp $
# standard python modules
import cPickle, re, string
for key, prop in self.properties.items():
if propvalues.has_key(key):
continue
+ if key == self.key:
+ raise ValueError, 'key property "%s" is required'%key
if isinstance(prop, Multilink):
propvalues[key] = []
else:
# Manipulating properties:
- def getprops(self):
- """Return a dictionary mapping property names to property objects."""
+ def getprops(self, protected=1):
+ """Return a dictionary mapping property names to property objects.
+ If the "protected" flag is true, we include protected properties -
+ those which may not be modified."""
d = self.properties.copy()
- d['id'] = String()
+ if protected:
+ d['id'] = String()
return d
def addprop(self, **properties):
#
# $Log: not supported by cvs2svn $
+# Revision 1.19 2001/08/29 04:47:18 richard
+# Fixed CGI client change messages so they actually include the properties
+# changed (again).
+#
# Revision 1.18 2001/08/16 07:34:59 richard
# better CGI text searching - but hidden filter fields are disappearing...
#
diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py
index 0e30f71bb0452950ef1c5782b2e58c2044a626d9..1840147d725efa3c023ea3ba563196035b34c173 100644 (file)
--- a/roundup/roundupdb.py
+++ b/roundup/roundupdb.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: roundupdb.py,v 1.10 2001-08-07 00:24:42 richard Exp $
+# $Id: roundupdb.py,v 1.11 2001-10-04 02:12:42 richard Exp $
import re, os, smtplib, socket
that owns this connection to the hyperdatabase."""
return self.user.lookup(self.journaltag)
- def uidFromAddress(self, address):
+ def uidFromAddress(self, address, create=1):
''' address is from the rfc822 module, and therefore is (name, addr)
user is created if they don't exist in the db already
else:
return hyperdb.Class.get(self, nodeid, propname)
- def getprops(self):
+ def getprops(self, protected=1):
"""In addition to the actual properties on the node, these
- methods provide the "creation" and "activity" properties."""
+ methods provide the "creation" and "activity" properties. If the
+ "protected" flag is true, we include protected properties - those
+ which may not be modified.
+ """
d = hyperdb.Class.getprops(self).copy()
- d['creation'] = hyperdb.Date()
- d['activity'] = hyperdb.Date()
- d['creator'] = hyperdb.Link("user")
+ if protected:
+ d['creation'] = hyperdb.Date()
+ d['activity'] = hyperdb.Date()
+ d['creator'] = hyperdb.Link("user")
return d
#
else:
return Class.get(self, nodeid, propname)
- def getprops(self):
+ def getprops(self, protected=1):
''' In addition to the actual properties on the node, these methods
- provide the "content" property.
+ provide the "content" property. If the "protected" flag is true,
+ we include protected properties - those which may not be
+ modified.
'''
d = Class.getprops(self).copy()
- d['content'] = hyperdb.String()
+ if protected:
+ d['content'] = hyperdb.String()
return d
# XXX deviation from spec - was called ItemClass
#
# $Log: not supported by cvs2svn $
+# Revision 1.10 2001/08/07 00:24:42 richard
+# stupid typo
+#
# Revision 1.9 2001/08/07 00:15:51 richard
# Added the copyright/license notice to (nearly) all files at request of
# Bizar Software.