commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r7641 - in trunk/gnue-appserver/src: . gcd generator gld language


From: johannes
Subject: [gnue] r7641 - in trunk/gnue-appserver/src: . gcd generator gld language
Date: Wed, 22 Jun 2005 08:58:34 -0500 (CDT)

Author: johannes
Date: 2005-06-22 08:58:32 -0500 (Wed, 22 Jun 2005)
New Revision: 7641

Modified:
   trunk/gnue-appserver/src/data.py
   trunk/gnue-appserver/src/gcd/readgcd.py
   trunk/gnue-appserver/src/geasAuthentication.py
   trunk/gnue-appserver/src/geasGsdGen.py
   trunk/gnue-appserver/src/geasInstance.py
   trunk/gnue-appserver/src/geasList.py
   trunk/gnue-appserver/src/geasSession.py
   trunk/gnue-appserver/src/geasSessionManager.py
   trunk/gnue-appserver/src/generator/form.py
   trunk/gnue-appserver/src/gld/readgld.py
   trunk/gnue-appserver/src/language/Object.py
   trunk/gnue-appserver/src/language/ObjectList.py
   trunk/gnue-appserver/src/language/Session.py
Log:
replaced string.* and types.*, fixed gnue-gsdgen


Modified: trunk/gnue-appserver/src/data.py
===================================================================
--- trunk/gnue-appserver/src/data.py    2005-06-22 13:27:19 UTC (rev 7640)
+++ trunk/gnue-appserver/src/data.py    2005-06-22 13:58:32 UTC (rev 7641)
@@ -21,9 +21,6 @@
 #
 # $Id$
 
-from types import *
-
-import string
 import copy
 import weakref
 import time
@@ -127,9 +124,9 @@
         it will change the clean cache.
     """
 
-    checktype (table, UnicodeType)
-    checktype (row, UnicodeType)
-    checktype (field, UnicodeType)
+    checktype (table, unicode)
+    checktype (row, unicode)
+    checktype (field, unicode)
 
     key = "%s-%s" % (table, row)
 
@@ -180,9 +177,9 @@
     @return: The current or clean value of the given field
     """
 
-    checktype (table, UnicodeType)
-    checktype (row, UnicodeType)
-    checktype (field, UnicodeType)
+    checktype (table, unicode)
+    checktype (row, unicode)
+    checktype (field, unicode)
 
     # Make sure to use the proper dictionary; use the dirty tables only if a
     # dirty value is available, otherwise always use the clean tables.
@@ -241,9 +238,9 @@
     @return: True if a value for field is available, False otherwise
     """
 
-    checktype (table, UnicodeType)
-    checktype (row, UnicodeType)
-    checktype (field, UnicodeType)
+    checktype (table, unicode)
+    checktype (row, unicode)
+    checktype (field, unicode)
 
     try:
       # If we do not search for a given kind (clean/dirty) try both
@@ -282,8 +279,8 @@
     @raises StateChangeError: if the former state is not 'initializing'.
     """
 
-    checktype (table, UnicodeType)
-    checktype (row, UnicodeType)
+    checktype (table, unicode)
+    checktype (row, unicode)
 
     key = "%s-%s" % (table, row)
 
@@ -469,8 +466,8 @@
     @return: current state of the given (table, row) tuple in the cache
     """
 
-    checktype (table, UnicodeType)
-    checktype (row, UnicodeType)
+    checktype (table, unicode)
+    checktype (row, unicode)
 
     key   = "%s-%s" % (table, row)
     state = self.__state.get (key, 'clean')
@@ -686,8 +683,8 @@
   attributes ['name']      = ''
   attributes ['database']  = database
   attributes ['table']     = "%s %s" % \
-      (string.join ([m [1] for m in master], ','),
-       string.join ([t [1] for t in tables], ' '))
+      (','.join ([m [1] for m in master]),
+       ' '.join ([t [1] for t in tables]))
 
   attributes ['primarykey'] = primarykey
 
@@ -740,7 +737,7 @@
 
   def __init__ (self, connections, database):
     checktype (connections, GConnections.GConnections)
-    checktype (database, StringType)
+    checktype (database, str)
 
     self.__connections = connections
     self.__database    = database
@@ -799,21 +796,21 @@
         by.  In case aliases are defined in the content parameter, these field
         names must be in the format 'alias.field'.
     """
-    checktype (content, DictType)
+    checktype (content, dict)
     for (content_key, content_value) in content.items ():
-      checktype (content_key, [NoneType, UnicodeType])
-      checktype (content_value, TupleType)
+      checktype (content_key, [None, unicode])
+      checktype (content_value, tuple)
       (table, fk_alias, fk_field, fields) = content_value
-      checktype (table, UnicodeType)
-      checktype (fk_alias, [NoneType, UnicodeType])
-      checktype (fk_field, [NoneType, UnicodeType])
-      checktype (fields, ListType)
-      for fields_element in fields: checktype (fields_element, UnicodeType)
+      checktype (table, unicode)
+      checktype (fk_alias, [None, unicode])
+      checktype (fk_field, [None, unicode])
+      checktype (fields, list)
+      for fields_element in fields: checktype (fields_element, unicode)
 
-    checktype (order, [NoneType, ListType])
+    checktype (order, [None, list])
     if order:
       for order_element in order:
-        checktype (order_element, DictType)
+        checktype (order_element, dict)
 
     return recordset (self.__cache, self.__connections, self.__database,
                       content, GConditions.buildCondition (conditions), order)
@@ -830,7 +827,7 @@
     Table must be a unicode string.
     """
 
-    checktype (table, UnicodeType)
+    checktype (table, unicode)
 
     if self.__uuidType == 'time':
       row = UUID.generateTimeBased ()
@@ -855,8 +852,8 @@
     Table and row must be unicode strings.
     """
 
-    checktype (table, UnicodeType)
-    checktype (row, UnicodeType)
+    checktype (table, unicode)
+    checktype (row, unicode)
 
     self.__cache.deleteRecord (table, row)
 
@@ -876,11 +873,11 @@
     Table and row must be unicode strings, fields must be a list of unicode
     strings.
     """
-    checktype (table, UnicodeType)
-    checktype (row, UnicodeType)
-    checktype (fields, ListType)
+    checktype (table, unicode)
+    checktype (row, unicode)
+    checktype (fields, list)
     for fields_element in fields:
-      checktype (fields_element, UnicodeType)
+      checktype (fields_element, unicode)
 
     # Let's have a look wether we need a requery or not. Newly inserted records
     # cannot have uncached fields since they are new :)
@@ -1840,7 +1837,7 @@
     @return: current or original value of the given field
     """
 
-    checktype (field, UnicodeType)
+    checktype (field, unicode)
 
     # If an original value is requested, set the dirty-flag to False, otherwise
     # leave it unspecified (=None), which means use a dirty or clean value in
@@ -1887,7 +1884,7 @@
     @param value: value to be set for the given field (native Python datatype)
     """
 
-    checktype (field, UnicodeType)
+    checktype (field, unicode)
 
     self.__cache.write (self.__table, self.__row, field, value, True)
 

Modified: trunk/gnue-appserver/src/gcd/readgcd.py
===================================================================
--- trunk/gnue-appserver/src/gcd/readgcd.py     2005-06-22 13:27:19 UTC (rev 
7640)
+++ trunk/gnue-appserver/src/gcd/readgcd.py     2005-06-22 13:58:32 UTC (rev 
7641)
@@ -23,7 +23,6 @@
 
 import sys
 import os
-import string
 
 from gnue.common.apps import i18n, errors
 from gnue.common.apps.i18n import translate as _        # for epydoc
@@ -58,10 +57,10 @@
     text = []
 
     if files:
-      text.append (u_("In file(s) '%s':") % string.join (files, ', '))
+      text.append (u_("In file(s) '%s':") % ', '.join (files))
 
     text.append (message)
-    self.detail = string.join (text, os.linesep)
+    self.detail = os.linesep.join (text)
 
 
 class ModuleNotFoundError (Error):

Modified: trunk/gnue-appserver/src/geasAuthentication.py
===================================================================
--- trunk/gnue-appserver/src/geasAuthentication.py      2005-06-22 13:27:19 UTC 
(rev 7640)
+++ trunk/gnue-appserver/src/geasAuthentication.py      2005-06-22 13:58:32 UTC 
(rev 7641)
@@ -21,8 +21,6 @@
 #
 # $Id$
 
-import string
-
 from gnue.common.apps import errors
 
 # =============================================================================
@@ -110,7 +108,7 @@
     gDebug (1, "User '%s' logged in." % user)
 
     # possibly not the best solution
-    session.tablelist = string.split (authData[0][3],',')
+    session.tablelist = authData[0][3].split (',')
 
     return 1 # = has access
 

Modified: trunk/gnue-appserver/src/geasGsdGen.py
===================================================================
--- trunk/gnue-appserver/src/geasGsdGen.py      2005-06-22 13:27:19 UTC (rev 
7640)
+++ trunk/gnue-appserver/src/geasGsdGen.py      2005-06-22 13:58:32 UTC (rev 
7641)
@@ -22,9 +22,7 @@
 # $Id$
 
 import sys
-import types
 import copy
-import string
 import mx.DateTime
 
 if sys.version_info [:2] >= (2, 3):
@@ -32,9 +30,8 @@
 
 from gnue.common.apps import i18n, errors
 from gnue.common.apps.i18n import translate as _        # for epydoc
-from gnue.common.schema import Objects
 from gnue.common.apps.GClientApp import *
-from gnue.common.datasources import GDataSource, GConditions
+from gnue.common.datasources import GDataSource, GConditions, GSchema
 from gnue.common.definitions import GParserHelpers
 
 from gnue.appserver import VERSION
@@ -157,11 +154,11 @@
 
     print o(u_("Generating schema definition ..."))
 
-    schema = Objects.GSSchema ()
+    schema = GSchema.GSSchema ()
     schema.title   = 'Appserver Data Dump'
     schema.author  = self.COMMAND
     schema.version = '1.0'
-    self._data = Objects.GSData (schema)
+    self._data = GSchema.GSData (schema)
 
     for classname in self.exports:
       self.__exportClass (classname)
@@ -189,26 +186,20 @@
     print o(u_("Exporting data of class '%s' ...") % className)
 
     # Prepare the tabledata- and it's definition tags
-    table = Objects.GSTableData (self._data)
+    table = GSchema.GSTableData (self._data)
     table.name      = "%s_dump" % cDef.table
     table.tablename = cDef.table
 
-    columns = Objects.GSDefinition (table)
+    pk = GSchema.GSPrimaryKey (table, name = u"pk_%s" % cDef.table)
+    GSchema.GSPKField (pk, name = u'gnue_id')
 
     fieldlist = []
     for prop in cDef.properties.values ():
       if prop.isCalculated: continue
 
-      column = Objects.GSColumn (columns)
-      column.field = prop.column
-      column.type  = prop.dbFullType
-
-      if prop.fullName == 'gnue_id':
-        column.key = True
-
       fieldlist.append (prop.column)
 
-    rows = Objects.GSRows (table)
+    rows = GSchema.GSRows (table)
 
     if self.__fishes.has_key (className):
       self.__fishDataDump (cDef, fieldlist, rows)
@@ -256,7 +247,7 @@
     @param rows: GSRows instance which is parent of the newly created rows
     """
 
-    row = Objects.GSRow (rows)
+    row = GSchema.GSRow (rows)
 
     for field in fields:
       pName = "." in field and field.split (".", 1) [-1] or field
@@ -264,7 +255,7 @@
       data  = record.getField (field)
 
       if data is not None:
-        value = Objects.GSValue (row)
+        value = GSchema.GSValue (row)
         value.field = prop.column
 
         GParserHelpers.GContent ( \
@@ -343,12 +334,12 @@
     """
 
     if datatype [:6] == "string" or datatype == "id":
-      checktype (native, [types.NoneType, types.UnicodeType])
+      checktype (native, [None, unicode])
 
       if native is None:
         return u''
 
-      if isinstance (native, types.UnicodeType):
+      if isinstance (native, unicode):
         return native
 
     elif datatype [:6] == "number":
@@ -772,7 +763,7 @@
     # make sure the list of tables is sorted by alias
     tl = [(al, name) for (name, al) in alias.items ()]
     tl.sort ()
-    table = string.join (["%s %s" % (t, a.strip ()) for (a, t) in tl], ", ")
+    table = ", ".join (["%s %s" % (t, a.strip ()) for (a, t) in tl])
 
     # add alias information to the field list
     if len (alias [classdef.table]):

Modified: trunk/gnue-appserver/src/geasInstance.py
===================================================================
--- trunk/gnue-appserver/src/geasInstance.py    2005-06-22 13:27:19 UTC (rev 
7640)
+++ trunk/gnue-appserver/src/geasInstance.py    2005-06-22 13:58:32 UTC (rev 
7641)
@@ -21,8 +21,6 @@
 #
 # $Id$
 
-import types
-import string
 import sys
 import mx.DateTime
 import mx.DateTime.ISO
@@ -118,9 +116,9 @@
 
     elif propertydef.dbType == "string":
       # String property: we expect the database to deliver a unicode string
-      if isinstance (value, types.UnicodeType):
+      if isinstance (value, unicode):
         return value
-      elif isinstance (value, types.StringType):
+      elif isinstance (value, str):
         return unicode (value)
       else:
         try:
@@ -143,10 +141,10 @@
       
     elif propertydef.dbType == "date":
       # Date property: Must be an mx.DateTime or at least parseable as such
-      if isinstance (value, types.UnicodeType):
+      if isinstance (value, unicode):
         value = mx.DateTime.ISO.ParseDateTime (value.encode ('utf-8') + \
                                                ' 00:00:00')
-      elif isinstance (value, types.StringType):
+      elif isinstance (value, str):
         value = mx.DateTime.ISO.ParseDateTime (value + ' 00:00:00')
 
       elif sys.version_info [:2] >= (2, 3) and \
@@ -161,10 +159,10 @@
 
     elif propertydef.dbType == "time":
       # Time property: Must be an mx.DateTime or at least parseable as such
-      if isinstance (value, types.UnicodeType):
+      if isinstance (value, unicode):
         value = mx.DateTime.ISO.ParseDateTime ('0001-01-01 ' + \
                                                value.encode ('utf-8'))
-      elif isinstance (value, types.StringType):
+      elif isinstance (value, str):
         value = mx.DateTime.ISO.ParseDateTime ('0001-01-01 ' + value)
 
       elif sys.version_info [:2] >= (2, 3) and \
@@ -186,10 +184,10 @@
     elif propertydef.dbType == "datetime":
       # Date/Time property: Must be an mx.DateTime or at least parseable as
       # such
-      if isinstance (value, types.UnicodeType):
+      if isinstance (value, unicode):
         return mx.DateTime.ISO.ParseDateTime (value.encode ('utf-8'))
 
-      elif isinstance (value, types.StringType):
+      elif isinstance (value, str):
         return mx.DateTime.ISO.ParseDateTime (value)
 
       elif sys.version_info [:2] >= (2, 3) and \
@@ -223,7 +221,7 @@
   def __getValue (self, propertyname):
 
     #resolve indirect properties
-    elements = string.split (propertyname, '.')
+    elements = propertyname.split ('.')
     classdef = self.__classdef
     record   = self.__record
 
@@ -308,7 +306,7 @@
     # TODO: This should run in a separate process so that a segfaulting
     # procedure doesn't kill appserver.
     # (needs to be implemented as an option in gnue-common)
-    checktype (namespace, [types.NoneType, types.DictType])
+    checktype (namespace, [None, dict])
 
     # Create a session object which with the actual session id
     sess = Session.Session (self.__session.sm, id (self.__session),
@@ -472,7 +470,7 @@
         the value to be compared and 'descending' specifies the sort-direction.
     """
 
-    checktype (order, [types.NoneType, types.ListType])
+    checktype (order, [None, list])
     self.__order = order
 
 

Modified: trunk/gnue-appserver/src/geasList.py
===================================================================
--- trunk/gnue-appserver/src/geasList.py        2005-06-22 13:27:19 UTC (rev 
7640)
+++ trunk/gnue-appserver/src/geasList.py        2005-06-22 13:58:32 UTC (rev 
7641)
@@ -22,7 +22,6 @@
 # $Id$
 
 import geasInstance
-import string
 import time
 import copy
 

Modified: trunk/gnue-appserver/src/geasSession.py
===================================================================
--- trunk/gnue-appserver/src/geasSession.py     2005-06-22 13:27:19 UTC (rev 
7640)
+++ trunk/gnue-appserver/src/geasSession.py     2005-06-22 13:58:32 UTC (rev 
7641)
@@ -21,9 +21,6 @@
 #
 # $Id$
 
-from types import *
-
-import string
 import copy
 
 from gnue.common.apps import errors, i18n
@@ -78,7 +75,7 @@
 class ValidationCyclesError (errors.ApplicationError):
   def __init__ (self, classlist):
     msg = u_("Maximum validation cycle reached. Classes in current cycle: %s")\
-          % string.join (classlist, ", ")
+          % ", ".join (classlist)
     errors.ApplicationError.__init__ (self, msg)
 
 # =============================================================================
@@ -147,7 +144,7 @@
   def __getFieldname (self, classdef, propertyname, contentdict, add,
                       skipCalculated = True):
 
-    elements = string.split (propertyname, '.')
+    elements = propertyname.split ('.')
 
     a = u't0'                           # start with main table
     c = classdef
@@ -408,10 +405,10 @@
 
     result = {'name': None, 'descending': False, 'ignorecase': False}
 
-    if isinstance (item, DictType):
+    if isinstance (item, dict):
       result = item
 
-    elif isinstance (item, TupleType) or isinstance (item, ListType):
+    elif isinstance (item, tuple) or isinstance (item, list):
       result ['name'] = item [0]
       if len (item) > 1: result ['descending'] = item [1]
       if len (item) > 2: result ['ignorecase'] = item [2]
@@ -472,7 +469,7 @@
     # Only query the main table here.  geasInstance.get will do the rest.
     fields = {}
     for p in propertylist:
-      pdef = classdef.properties [string.split (p, '.') [0]]
+      pdef = classdef.properties [p.split ('.') [0]]
       if not fields.has_key (pdef.column) and not pdef.isCalculated:
         fields [pdef.column] = True
 

Modified: trunk/gnue-appserver/src/geasSessionManager.py
===================================================================
--- trunk/gnue-appserver/src/geasSessionManager.py      2005-06-22 13:27:19 UTC 
(rev 7640)
+++ trunk/gnue-appserver/src/geasSessionManager.py      2005-06-22 13:58:32 UTC 
(rev 7641)
@@ -21,8 +21,6 @@
 #
 # $Id$
 
-from types import *
-
 import geasSession
 import geasAuthentication
 import geasFilter
@@ -63,11 +61,6 @@
     self._modulepath  = modulepath or \
                         os.path.join (paths.data, "share", "gnue", "appserver")
 
-    #import profile
-    #prof = profile.Profile ()
-    #prof.runctx ('self.updateRepository (haltOnError = True)', globals (),
-        #locals ())
-    #prof.dump_stats ('appserver.profile')
     self.repository = repository.Repository (self._internalSession)
     self.updateRepository (scanModules, haltOnError = True)
 

Modified: trunk/gnue-appserver/src/generator/form.py
===================================================================
--- trunk/gnue-appserver/src/generator/form.py  2005-06-22 13:27:19 UTC (rev 
7640)
+++ trunk/gnue-appserver/src/generator/form.py  2005-06-22 13:58:32 UTC (rev 
7641)
@@ -21,7 +21,6 @@
 #
 # $Id$
 
-import string
 import classdef
 import layout
 import sys
@@ -102,7 +101,7 @@
 
       code.append ('</form>')
 
-      return string.join (code, "\n")
+      return "\n".join (code)
 
     finally:
       self.__classDef.release ()
@@ -455,7 +454,7 @@
 
     if contents is not None:
       iLen = len (indent) + len (gap)
-      cString = string.join (["%s%s" % (" " * iLen, i) for i in contents], 
"\n")
+      cString = "\n".join (["%s%s" % (" " * iLen, i) for i in contents])
 
       result.append (cString)
       if not keep:

Modified: trunk/gnue-appserver/src/gld/readgld.py
===================================================================
--- trunk/gnue-appserver/src/gld/readgld.py     2005-06-22 13:27:19 UTC (rev 
7640)
+++ trunk/gnue-appserver/src/gld/readgld.py     2005-06-22 13:58:32 UTC (rev 
7641)
@@ -23,7 +23,6 @@
 
 import sys
 import os
-import string
 
 from gnue.common.apps import GClientApp, i18n, errors
 from gnue.common.apps.i18n import translate as _        # for epydoc
@@ -51,10 +50,10 @@
     text = []
 
     if files:
-      text.append (u_("In file(s) '%s':") % string.join (files, ', '))
+      text.append (u_("In file(s) '%s':") % ', '.join (files))
 
     text.append (message)
-    self.detail = string.join (text, os.linesep)
+    self.detail = os.linesep.join (text)
 
 class ClassNotFoundError (Error):
   def __init__ (self, classname, filename = None):
@@ -312,8 +311,9 @@
     """
 
     # This key makes sure to have no clashes
-    key = string.lower ("%s::%s.%s" % (self.__currentModule.language,
-                         self.__currentClass.fullName, item.fullName))
+    key = "%s::%s.%s" % (self.__currentModule.language,
+                         self.__currentClass.fullName, item.fullName)
+    key = key.lower ()
 
     if self.labels.has_key (key):
       raise DuplicateItemError, \
@@ -344,7 +344,7 @@
     already listed, a DuplicateItemError will be raised.
     """
 
-    key = string.lower ("%s::%s") % (item.language, item.fullName)
+    key = "%s::%s" % (item.language.lower (), item.fullName.lower ())
     if self.messages.has_key (key):
       raise DuplicateItemError, \
           (self.__currentModule.language, item.fullName,

Modified: trunk/gnue-appserver/src/language/Object.py
===================================================================
--- trunk/gnue-appserver/src/language/Object.py 2005-06-22 13:27:19 UTC (rev 
7640)
+++ trunk/gnue-appserver/src/language/Object.py 2005-06-22 13:58:32 UTC (rev 
7641)
@@ -21,8 +21,6 @@
 #
 # $Id$
 
-import string
-
 from Procedure import Procedure
 from gnue import appserver
 from gnue.common.apps import errors

Modified: trunk/gnue-appserver/src/language/ObjectList.py
===================================================================
--- trunk/gnue-appserver/src/language/ObjectList.py     2005-06-22 13:27:19 UTC 
(rev 7640)
+++ trunk/gnue-appserver/src/language/ObjectList.py     2005-06-22 13:58:32 UTC 
(rev 7641)
@@ -21,8 +21,6 @@
 #
 # $Id$
 
-import types
-
 from Object import Object
 from gnue.common.datasources import GConditions
 
@@ -78,7 +76,7 @@
   # -------------------------------------------------------------------------
   def __getitem__ (self, index):
     try:
-      if type (index) == types.SliceType:
+      if isinstance (index, slice):
         if index.start < 0:
           self.__fillup ()
 
@@ -204,13 +202,13 @@
     result = []
 
     for item in sorting:
-      if isinstance (item, types.DictType):
+      if isinstance (item, dict):
         item ['name'] = self.__session.qualifyMultiple (item ['name'])
 
-      elif isinstance (item, types.ListType):
+      elif isinstance (item, list):
         item [0] = self.__session.qualifyMultiple (item [0])
 
-      elif isinstance (item, types.TupleType):
+      elif isinstance (item, tuple):
         data = list (item)
         data [0] = self.__session.qualifyMultiple (data [0])
         item = tuple (data)

Modified: trunk/gnue-appserver/src/language/Session.py
===================================================================
--- trunk/gnue-appserver/src/language/Session.py        2005-06-22 13:27:19 UTC 
(rev 7640)
+++ trunk/gnue-appserver/src/language/Session.py        2005-06-22 13:58:32 UTC 
(rev 7641)
@@ -21,9 +21,6 @@
 #
 # $Id$
 
-import types
-import string
-
 from ObjectList import ObjectList
 from Object import Object
 from gnue.common.apps import i18n, errors
@@ -178,7 +175,7 @@
     @return: fully qualified version of name
     """
 
-    return string.join ([self.qualify (p) for p in name.split ('.')], ".")
+    return ".".join ([self.qualify (p) for p in name.split ('.')])
 
 
   # -------------------------------------------------------------------------
@@ -381,7 +378,7 @@
         text = result [0].gnue_text
 
         if len (args):
-          if isinstance (args [0], types.DictType):
+          if isinstance (args [0], dict):
             text = text % args [0]
           else:
             text = text % args





reply via email to

[Prev in Thread] Current Thread [Next in Thread]