[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5346 - in trunk/gnue-appserver/src: . classrep
From: |
johannes |
Subject: |
r5346 - in trunk/gnue-appserver/src: . classrep |
Date: |
Thu, 18 Mar 2004 04:17:26 -0600 (CST) |
Author: johannes
Date: 2004-03-18 04:17:25 -0600 (Thu, 18 Mar 2004)
New Revision: 5346
Modified:
trunk/gnue-appserver/src/classrep/repository.ini
trunk/gnue-appserver/src/classrep/test.py
trunk/gnue-appserver/src/geasInstance.py
trunk/gnue-appserver/src/geasSession.py
Log:
Implemented gnue_nullable.
Modified: trunk/gnue-appserver/src/classrep/repository.ini
===================================================================
--- trunk/gnue-appserver/src/classrep/repository.ini 2004-03-18 10:14:45 UTC
(rev 5345)
+++ trunk/gnue-appserver/src/classrep/repository.ini 2004-03-18 10:17:25 UTC
(rev 5346)
@@ -87,7 +87,7 @@
gnue_length = 35
gnue_scale = 0
gnue_comment = Name
-gnue_nullable =
+gnue_nullable = FALSE
[gnue_module.gnue_comment]
gnue_id = 00000000000000000000000000000013
@@ -134,7 +134,7 @@
gnue_length = 35
gnue_scale = 0
gnue_comment = Classname without modulename
-gnue_nullable =
+gnue_nullable = FALSE
[gnue_class.gnue_comment]
gnue_id = 00000000000000000000000000000024
@@ -192,7 +192,7 @@
gnue_length = 35
gnue_scale = 0
gnue_comment = Propertyname without modulename
-gnue_nullable =
+gnue_nullable = FALSE
[gnue_property.gnue_type]
gnue_id = 00000000000000000000000000000035
@@ -203,7 +203,7 @@
gnue_length = 35
gnue_scale = 0
gnue_comment = Property type
-gnue_nullable =
+gnue_nullable = FALSE
[gnue_property.gnue_length]
gnue_id = 00000000000000000000000000000036
@@ -247,7 +247,7 @@
gnue_length = 0
gnue_scale = 0
gnue_comment = Property can contain NULL values
-gnue_nullable =
+gnue_nullable = FALSE
; -----------------------------------------------------------------------------
@@ -295,7 +295,7 @@
gnue_length = 35
gnue_scale = 0
gnue_comment = Procedurename without modulename
-gnue_nullable =
+gnue_nullable = FALSE
[gnue_procedure.gnue_language]
gnue_id = 00000000000000000000000000000045
@@ -306,7 +306,7 @@
gnue_length = 10
gnue_scale = 0
gnue_comment = Procedure language
-gnue_nullable =
+gnue_nullable = FALSE
[gnue_procedure.gnue_code]
gnue_id = 00000000000000000000000000000046
@@ -317,7 +317,7 @@
gnue_length = 0
gnue_scale = 0
gnue_comment = Procedure code
-gnue_nullable =
+gnue_nullable = FALSE
[gnue_procedure.gnue_compiledcode]
gnue_id = 00000000000000000000000000000047
Modified: trunk/gnue-appserver/src/classrep/test.py
===================================================================
--- trunk/gnue-appserver/src/classrep/test.py 2004-03-18 10:14:45 UTC (rev
5345)
+++ trunk/gnue-appserver/src/classrep/test.py 2004-03-18 10:17:25 UTC (rev
5346)
@@ -72,3 +72,9 @@
print
print 'Is there a module "address": %d' % sm.modules.has_key ("address")
print 'Is there a module "foo": %d' % sm.modules.has_key ("foo")
+
+ x = sm.classes ['gnue_class']
+ print "gnue_class.gnue_id nullable: %s" % \
+ x.properties ['gnue_id'].gnue_nullable
+ print "gnue_class.gnue_comment nullable: %s" % \
+ x.properties ['gnue_comment'].gnue_nullable
Modified: trunk/gnue-appserver/src/geasInstance.py
===================================================================
--- trunk/gnue-appserver/src/geasInstance.py 2004-03-18 10:14:45 UTC (rev
5345)
+++ trunk/gnue-appserver/src/geasInstance.py 2004-03-18 10:17:25 UTC (rev
5346)
@@ -32,17 +32,16 @@
# Exceptions
# =============================================================================
-class EInvalidDBValue (Exception):
- def __init__ (self, value, propertyName):
- self._text = _(
-"""Database returned invalid value '%(value)s' for
+class DbValueError (Exception):
+ def __init__ (self, propertyName, value):
+ msg = _("""Database returned invalid value '%(value)s' for
property '%(property)s'""") % { "value" : repr (value),
"property": propertyName}
Exception.__init__ (self, self._text)
-class EInvalidValue (Exception):
- def __init__ (self, value, propertyName):
+class PropertyValueError (Exception):
+ def __init__ (self, propertyName, value):
self._text = _("Invalid value '%(value)s' for property '%(property)s'") % \
{"value": repr (value), "property": propertyName}
Exception.__init__ (self, self._text)
@@ -85,7 +84,7 @@
# if not UnicodeType then return normal string
return value
else:
- raise EInvalidDBValue (value, propertyname)
+ raise DbValueError (propertyname, value)
# Number property
@@ -98,7 +97,7 @@
# ... with fractional part
return float (value)
except ValueError:
- raise EInvalidDBValue (value, propertyname)
+ raise DbValueError (propertyname, value)
# Date property
elif propertydef.gnue_type == "date":
@@ -111,7 +110,7 @@
# TODO: Check if valid date
return value
else:
- raise EInvalidDBValue (value, propertyname)
+ raise DbValueError (propertyname, value)
# Time property
elif propertydef.gnue_type == "time":
@@ -127,7 +126,7 @@
# TODO: Check if valid time
return value
else:
- raise EInvalidDBValue (value, propertyname)
+ raise DbValueError (propertyname, value)
# Date/Time property
elif propertydef.gnue_type == "datetime":
@@ -140,7 +139,7 @@
# TODO: Check if valid datetime
return value
else:
- raise EInvalidDBValue (value, propertyname)
+ raise DbValueError (propertyname, value)
# Boolean property
elif propertydef.gnue_type == "boolean":
@@ -149,7 +148,7 @@
elif value in [1, "1", "t", "T", "true", "true", "y", "Y", "yes", "YES"]:
return 1
else:
- raise EInvalidDBValue (value, propertyname)
+ raise DbValueError (propertyname, value)
# Reference property: gnue_type is a classname
elif self.__classdef.classes.has_key (propertydef.gnue_type):
@@ -160,7 +159,7 @@
# if not UnicodeType then return normal string
return value
else:
- raise EInvalidDBValue (value, propertyname)
+ raise DbValueError (propertyname, value)
# TODO: Missing property types:
# * list properties
@@ -211,7 +210,7 @@
# ... with fractional part
value = float (value)
except ValueError:
- raise EInvalidValue (value, propertyname)
+ raise PropertyValueError (propertyname, value)
# Date property
elif propertydef.gnue_type == "date":
@@ -220,7 +219,7 @@
# value for date properties. So silently accept that.
value = mx.DateTime.ISO.ParseDateTime (value)
except ValueError:
- raise EInvalidValue (value, propertyname)
+ raise PropertyValueError (propertyname, value)
# Time property
elif propertydef.gnue_type == "time":
@@ -229,14 +228,14 @@
# value for time properties. So silently accept that.
value = mx.DateTime.ISO.ParseDateTime (value)
except ValueError:
- raise EInvalidValue (value, propertyname)
+ raise PropertyValueError (propertyname, value)
# Date/Time property
elif propertydef.gnue_type == "datetime":
try:
value = mx.DateTime.ISO.ParseDateTime (value)
except ValueError:
- raise EInvalidValue (value, propertyname)
+ raise PropertyValueError (propertyname, value)
# Boolean property
elif propertydef.gnue_type == "boolean":
@@ -245,7 +244,7 @@
elif value in [1, "1", "t", "T", "true", "true", "y", "Y", "yes", "YES"]:
value = 1
else:
- raise EInvalidValue (value, propertyname)
+ raise PropertyValueError (propertyname, value)
self.__record.putField (propertydef.column, value)
@@ -323,3 +322,21 @@
# return value of '1' to make XMLRPC happy
return retcode or 1
+
+
+ # ---------------------------------------------------------------------------
+ # Validate all properties of an instance
+ # ---------------------------------------------------------------------------
+
+ def validate (self):
+ """
+ This function checks all properties marked as 'not nullable' to have a
+ value other than None. If a none value is encountered a PropertyValueError
+ is raised.
+ """
+ for prop in self.__classdef.properties.values ():
+ if prop.gnue_nullable is not None and not prop.gnue_nullable:
+ value = self.__record.getField (prop.column)
+ if value is None:
+ raise PropertyValueError (prop.fullName, None)
+
Modified: trunk/gnue-appserver/src/geasSession.py
===================================================================
--- trunk/gnue-appserver/src/geasSession.py 2004-03-18 10:14:45 UTC (rev
5345)
+++ trunk/gnue-appserver/src/geasSession.py 2004-03-18 10:17:25 UTC (rev
5346)
@@ -49,6 +49,7 @@
self.__listcount = 0
self.__authAdapter = authAdapter
self.__connection = None
+ self.__dirtyInstances = {}
self.sm = sm # The session manager
self.id = id # The session id
@@ -104,8 +105,11 @@
# ---------------------------------------------------------------------------
def commit (self):
+ for instance in self.__dirtyInstances.values ():
+ instance.validate ()
self.__connection.commit ()
+ self.__dirtyInstances = {}
# ---------------------------------------------------------------------------
# Rollback the active transaction
@@ -114,6 +118,7 @@
def rollback (self):
self.__connection.rollback ()
+ self.__dirtyInstances = {}
# ---------------------------------------------------------------------------
# Create a new list of business objects of a given class
@@ -226,6 +231,8 @@
instance.put (propertylist, data [i])
i += 1
+ self.__dirtyInstances [object_id] = instance
+
return result
# ---------------------------------------------------------------------------
@@ -238,6 +245,7 @@
for object_id in obj_id_list:
self.__connection.deleteRecord (classdef.table, object_id)
+ del self.__dirtyInstances [object_id]
# ---------------------------------------------------------------------------
# Call a procedure of business objects
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5346 - in trunk/gnue-appserver/src: . classrep,
johannes <=