1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: cgi_client.py,v 1.31 2001-10-14 10:55:00 richard Exp $
18+ # $Id: cgi_client.py,v 1.32 2001-10-16 03:36:21 richard Exp $
1919
2020import os , cgi , pprint , StringIO , urlparse , re , traceback , mimetypes
2121import base64 , Cookie , time
@@ -218,7 +218,8 @@ def shownode(self, message=None):
218218 num_re = re .compile ('^\d+$' )
219219 if keys :
220220 try :
221- props , changed = parsePropsFromForm (cl , self .form , self .nodeid )
221+ props , changed = parsePropsFromForm (self .db , cl , self .form ,
222+ self .nodeid )
222223 cl .set (self .nodeid , ** props )
223224 self ._post_editnode (self .nodeid , changed )
224225 # and some nice feedback for the user
@@ -265,7 +266,7 @@ def _createnode(self):
265266 ''' create a node based on the contents of the form
266267 '''
267268 cl = self .db .classes [self .classname ]
268- props , dummy = parsePropsFromForm (cl , self .form )
269+ props , dummy = parsePropsFromForm (self . db , cl , self .form )
269270 return cl .create (** props )
270271
271272 def _post_editnode (self , nid , changes = None ):
@@ -545,7 +546,7 @@ def newuser_action(self, message=None):
545546 '''
546547 # TODO: pre-check the required fields and username key property
547548 cl = self .db .classes ['user' ]
548- props , dummy = parsePropsFromForm (cl , self .form )
549+ props , dummy = parsePropsFromForm (self . db , cl , self .form )
549550 uid = cl .create (** props )
550551 self .user = self .db .user .get (uid , 'username' )
551552 password = self .db .user .get (uid , 'password' )
@@ -722,7 +723,7 @@ def pagehead(self, title, message=None):
722723''' % (title , style , message , title , user_name , add_links , admin_links ,
723724 user_info ))
724725
725- def parsePropsFromForm (cl , form , nodeid = 0 ):
726+ def parsePropsFromForm (db , cl , form , nodeid = 0 ):
726727 '''Pull properties for the given class out of the form.
727728 '''
728729 props = {}
@@ -747,8 +748,8 @@ def parsePropsFromForm(cl, form, nodeid=0):
747748 link = cl .properties [key ].classname
748749 if not num_re .match (value ):
749750 try :
750- value = self . db .classes [link ].lookup (value )
751- except :
751+ value = db .classes [link ].lookup (value )
752+ except KeyError :
752753 raise ValueError , 'property "%s": %s not a %s' % (
753754 key , value , link )
754755 elif isinstance (proptype , hyperdb .Multilink ):
@@ -762,11 +763,11 @@ def parsePropsFromForm(cl, form, nodeid=0):
762763 for entry in map (str , value ):
763764 if not num_re .match (entry ):
764765 try :
765- entry = self . db .classes [link ].lookup (entry )
766- except :
766+ entry = db .classes [link ].lookup (entry )
767+ except KeyError :
767768 raise ValueError , \
768- 'property "%s": %s not a %s' % (key ,
769- entry , link )
769+ 'property "%s": "%s" not an entry of %s' % (key ,
770+ entry , link . capitalize () )
770771 l .append (entry )
771772 l .sort ()
772773 value = l
@@ -779,6 +780,9 @@ def parsePropsFromForm(cl, form, nodeid=0):
779780
780781#
781782# $Log: not supported by cvs2svn $
783+ # Revision 1.31 2001/10/14 10:55:00 richard
784+ # Handle empty strings in HTML template Link function
785+ #
782786# Revision 1.30 2001/10/09 07:38:58 richard
783787# Pushed the base code for the extended schema CGI interface back into the
784788# code cgi_client module so that future updates will be less painful.
0 commit comments