[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r6308 - in trunk/gnue-common/src/schema: . scripter
From: |
johannes |
Subject: |
r6308 - in trunk/gnue-common/src/schema: . scripter |
Date: |
Thu, 16 Sep 2004 10:26:54 -0500 (CDT) |
Author: johannes
Date: 2004-09-16 10:26:53 -0500 (Thu, 16 Sep 2004)
New Revision: 6308
Modified:
trunk/gnue-common/src/schema/GSData.py
trunk/gnue-common/src/schema/Objects.py
trunk/gnue-common/src/schema/scripter/Scripter.py
Log:
Fixed Exceptions (messages and groups)
Modified: trunk/gnue-common/src/schema/GSData.py
===================================================================
--- trunk/gnue-common/src/schema/GSData.py 2004-09-16 15:02:18 UTC (rev
6307)
+++ trunk/gnue-common/src/schema/GSData.py 2004-09-16 15:26:53 UTC (rev
6308)
@@ -23,6 +23,7 @@
import re
import mx.DateTime.ISO
from string import join
+from gnue.common.apps import errors
# =============================================================================
@@ -36,31 +37,17 @@
# =============================================================================
-# Base Exception class
+# Exceptions
# =============================================================================
-class EGSData (Exception):
- """
- This class is the ancestor of all exceptions used by this module.
- """
- def __init__ (self, text):
- self._text = text
- Exception.__init__ (self, text)
+class Error (errors.ApplicationError):
+ pass
-
- # ---------------------------------------------------------------------------
- # Object representation
- # ---------------------------------------------------------------------------
-
- def __repr__ (self):
- return self._text
-
-
# =============================================================================
# Invalid or unknown datatype
# =============================================================================
-class EInvalidType (EGSData):
+class EInvalidType (Error):
"""
This exception is raised, if a invalid or unknown datatype was found.
"""
@@ -72,19 +59,19 @@
msg = u_("%(fieldname)sInvalid datatype '%(datatype)s'.") \
% {'fieldname': fName,
'datatype' : dataType}
- EGSData.__init__ (self, msg)
+ Error.__init__ (self, msg)
# =============================================================================
# Invalid or unknown value
# =============================================================================
-class EInvalidValue (EGSData):
+class EInvalidValue (Error):
"""
This exception is raised, if a native object has an invalid value/type
"""
def __init__ (self, value, text):
- EGSData.__init__ (self, "'%s' %s" % (str (value), text))
+ Error.__init__ (self, "'%s' %s" % (str (value), text))
@@ -92,7 +79,7 @@
# Fieldvalue out of range
# =============================================================================
-class EOutOfRange (EGSData):
+class EOutOfRange (Error):
"""
This exception is raised if a fieldvalue is out of range, e.g. a string
exceeds it's length or a number exceeds it's numeric bounds.
@@ -112,14 +99,14 @@
'value' : fieldValue,
'range' : rDef}
- EGSData.__init__ (self, msg)
+ Error.__init__ (self, msg)
# =============================================================================
# EInvalidFormat
# =============================================================================
-class EInvalidFormat (EGSData):
+class EInvalidFormat (Error):
"""
This exception is the base class of format errors.
"""
@@ -132,7 +119,7 @@
% {'fieldname': fName,
'value' : fieldValue,
'format' : fmtString}
- EGSData.__init__ (self, msg)
+ Error.__init__ (self, msg)
# =============================================================================
@@ -159,7 +146,7 @@
Exception class for invalid formatted booleans
"""
def __init__ (self, gsValue, fieldValue):
- fmt = _("is not a boolean (TRUE or FALSE)")
+ fmt = u_("is not a boolean (TRUE or FALSE)")
EInvalidFormat.__init__ (self, gsValue, fieldValue, fmt)
@@ -172,7 +159,7 @@
Exception class for invalid formatted dates
"""
def __init__ (self, gsValue, fieldValue):
- fmt = _("is not a date (YYYY-MM-DD)")
+ fmt = u_("is not a date (YYYY-MM-DD)")
EInvalidFormat.__init__ (self, gsValue, fieldValue, fmt)
@@ -185,7 +172,7 @@
Exception class for invalid formatted times
"""
def __init__ (self, gsValue, fieldValue):
- fmt = _("is not a time (HH:MM:SS.ss)")
+ fmt = u_("is not a time (HH:MM:SS.ss)")
EInvalidFormat.__init__ (self, gsValue, fieldValue, fmt)
@@ -198,7 +185,7 @@
Exception class for invalid formatted datetimes
"""
def __init__ (self, gsValue, fieldValue):
- fmt = _("is not a datetime (YYYY-MM-DD HH:MM:SS.ss)")
+ fmt = u_("is not a datetime (YYYY-MM-DD HH:MM:SS.ss)")
EInvalidFormat.__init__ (self, gsValue, fieldValue, fmt)
@@ -321,7 +308,7 @@
if bool in ["TRUE", "FALSE"]:
return bool == "TRUE"
else:
- raise EInvalidBoolean (gsValue, fieldValue)
+ raise EInvalidBoolean, (gsValue, fieldValue)
# Dates must conform with the ISO spec: YYYY-MM-DD
Modified: trunk/gnue-common/src/schema/Objects.py
===================================================================
--- trunk/gnue-common/src/schema/Objects.py 2004-09-16 15:02:18 UTC (rev
6307)
+++ trunk/gnue-common/src/schema/Objects.py 2004-09-16 15:26:53 UTC (rev
6308)
@@ -31,18 +31,50 @@
from gnue.common.definitions.GObjects import GObj
from gnue.common.definitions.GRootObj import GRootObj
from gnue.common.schema.GSData import verifyDataType, valueToNative
+from gnue.common.apps import errors
import GSParser
import types
-class EFoundErrors (Exception):
+# =============================================================================
+# Exceptions
+# =============================================================================
+
+class Error (errors.ApplicationError):
+ pass
+
+class EFoundErrors (Error):
def __init__ (self):
- text = _("Errors found while processing GSD file.")
- Exception.__init__ (self, text)
+ text = u_("Errors found while processing GSD file.")
+ Error.__init__ (self, text)
-class GSObject(GObj):
+class ConstraintTypeError (Error):
+ def __init__ (self, ctype):
+ msg = u_("Invalid constraint type '%s'.") % ctype
+ Error.__init__ (self, msg)
+
+class ConstraintRefError (Error):
+ def __init__ (self, name):
+ msg = u_("Constraint '%s' has no reference fields.") % name
+ Error.__init__ (self, msg)
+
+class ConstraintFieldsError (Error):
+ def __init__ (self, name):
+ msg = u_("Constraint '%s' has unbalanced fields.") % name
+ Error.__init__ (self, msg)
+
+
+# =============================================================================
+# The base class for GNUe Schema Definitions
+# =============================================================================
+
+class GSObject (GObj):
pass
-class GSSchema(GRootObj, GSObject):
+# =============================================================================
+# This class implements the object tree for schema definitions
+# =============================================================================
+
+class GSSchema (GRootObj, GSObject):
def __init__(self, parent=None):
GRootObj.__init__(self, 'schema', GSParser.getXMLelements, GSParser)
GSObject.__init__(self, parent, type='GSSchema')
@@ -106,7 +138,7 @@
try:
if not self.type in ["unique", "foreignkey"]:
- raise Exception (u_("Invalid constraint type '%s'.") % self.type)
+ raise ConstraintTypeError, self.type
csFields = self.findChildrenOfType ('GSConstraintField')
self.__checkFields (None, csFields)
@@ -114,13 +146,12 @@
if self.type == "foreignkey":
refFields = self.findChildrenOfType ('GSConstraintRef')
if refFields is None:
- raise Exception (u_("Constraint '%s' has no reference fields.") % \
- self.name)
+ raise ConstraintRefError, self.name
+
self.__checkFields (refFields [0].table, refFields)
if len (refFields) <> len (csFields):
- raise Exception (u_("Constraint '%s' has unbalanced fields.") % \
- self.name)
+ raise ConstraintFieldsError, self.name
self.__typeCheck (csFields, refFields)
@@ -167,10 +198,10 @@
tbFields = table.findChildrenOfType ('GSField', True, True)
if len (cFields) > len (tbFields):
- raise gException, u_("Constraint '%(name)s' has more fields than the "
- "table '%(table)s'") \
- % {'name' : self.name,
- 'table': table.name}
+ raise errors.ApplicationError, \
+ u_("Constraint '%(name)s' has more fields than the table
'%(table)s'")\
+ % {'name' : self.name,
+ 'table': table.name}
for check in cFields:
try:
@@ -182,9 +213,10 @@
pass
else:
- raise Exception, u_("Table '%(table)s' has no field '%(field)s'.") \
- % {'table': table.name,
- 'field': check.name}
+ raise errors.ApplicationError, \
+ u_("Table '%(table)s' has no field '%(field)s'.") \
+ % {'table': table.name,
+ 'field': check.name}
# ---------------------------------------------------------------------------
@@ -212,10 +244,11 @@
for ix in range (0, len (csFields)):
if myFields [csFields [ix].name].type != \
rfFields [refFields [ix].name].type:
- raise gException, u_("Constraint '%(name)s': typemismatch in "
- "reference field '%(field)s'.") \
- % {'name' : self.name,
- 'field': csFields [ix].name}
+ raise errors.ApplicationError, \
+ u_("Constraint '%(name)s': typemismatch in reference field "
+ "'%(field)s'.") \
+ % {'name' : self.name,
+ 'field': csFields [ix].name}
class GSConstraintField(GSObject):
@@ -324,7 +357,8 @@
if self._parent._children [index] == self:
return index
- raise Exception (_("GSD-Error: can't find myself in the XML tree?!"))
+ raise errors.ApplicationError, \
+ u_("GSD-Error: can't find myself in the XML tree?!")
Modified: trunk/gnue-common/src/schema/scripter/Scripter.py
===================================================================
--- trunk/gnue-common/src/schema/scripter/Scripter.py 2004-09-16 15:02:18 UTC
(rev 6307)
+++ trunk/gnue-common/src/schema/scripter/Scripter.py 2004-09-16 15:26:53 UTC
(rev 6308)
@@ -165,7 +165,7 @@
"""
if not len (self.ARGUMENTS):
- raise StartupError, _("No input file specified.")
+ raise StartupError, u_("No input file specified.")
try:
self._files = []
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r6308 - in trunk/gnue-common/src/schema: . scripter,
johannes <=