[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue-appserver/src geasSession.py classrep/Clas...
From: |
Johannes Vetter |
Subject: |
gnue-appserver/src geasSession.py classrep/Clas... |
Date: |
Thu, 18 Sep 2003 11:14:11 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue-appserver
Branch:
Changes by: Johannes Vetter <address@hidden> 03/09/18 11:14:10
Modified files:
src : geasSession.py
src/classrep : Class.py Definition.py Module.py Namespace.py
Property.py mtest.py
src/language : Object.py ObjectList.py
Removed files:
src/classrep : ctest.py
Log message:
Code cleanup
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/geasSession.py.diff?tr1=1.37&tr2=1.38&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/classrep/Class.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/classrep/Definition.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/classrep/Module.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/classrep/Namespace.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/classrep/Property.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/classrep/mtest.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/language/Object.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/language/ObjectList.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: gnue-appserver/src/classrep/Class.py
diff -c gnue-appserver/src/classrep/Class.py:1.6
gnue-appserver/src/classrep/Class.py:1.7
*** gnue-appserver/src/classrep/Class.py:1.6 Sat Aug 16 13:07:16 2003
--- gnue-appserver/src/classrep/Class.py Thu Sep 18 11:14:10 2003
***************
*** 19,25 ****
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Class.py,v 1.6 2003/08/16 17:07:16 siesel Exp $
from Base import *
from Namespace import *
--- 19,25 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Class.py,v 1.7 2003/09/18 15:14:10 jvetter Exp $
from Base import *
from Namespace import *
***************
*** 65,72 ****
# Request a list of matching business objects
#
---------------------------------------------------------------------------
def _requestData (self, moduleId, className=None):
- # print "DEBUG: Class: requestData %s, %s" % (moduleId, className)
-
cond = [["eq", ""], ["field", "gnue_module"], ["const", moduleId]]
if className:
cond += [["eq", ""], ["field", "gnue_name"], ["const", className]]
--- 65,70 ----
***************
*** 99,109 ****
module = self.modules [moduleName]
# is the class already cached ?
! if self._cache.has_key(name):
return self._cache [name]
# since we had no match cached, ask for it
- # print "DEBUG: Class: REFETCH %s, %s" % (module.gnue_id, className)
res = self._requestData (module.gnue_id, className)
if len (res) == 1:
--- 97,106 ----
module = self.modules [moduleName]
# is the class already cached ?
! if self._cache.has_key (name):
return self._cache [name]
# since we had no match cached, ask for it
res = self._requestData (module.gnue_id, className)
if len (res) == 1:
Index: gnue-appserver/src/classrep/Definition.py
diff -c gnue-appserver/src/classrep/Definition.py:1.1
gnue-appserver/src/classrep/Definition.py:1.2
*** gnue-appserver/src/classrep/Definition.py:1.1 Tue May 27 10:30:57 2003
--- gnue-appserver/src/classrep/Definition.py Thu Sep 18 11:14:10 2003
***************
*** 19,25 ****
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Definition.py,v 1.1 2003/05/27 14:30:57 jvetter Exp $
import ConfigParser
import string
--- 19,25 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Definition.py,v 1.2 2003/09/18 15:14:10 jvetter Exp $
import ConfigParser
import string
***************
*** 129,135 ****
#
=============================================================================
if __name__ == '__main__':
! x = RepositoryDefinition ('classrepository.ini')
print "\nModules:"
for m in x.modules ():
--- 129,135 ----
#
=============================================================================
if __name__ == '__main__':
! x = RepositoryDefinition ('repository.ini')
print "\nModules:"
for m in x.modules ():
Index: gnue-appserver/src/classrep/Module.py
diff -c gnue-appserver/src/classrep/Module.py:1.5
gnue-appserver/src/classrep/Module.py:1.6
*** gnue-appserver/src/classrep/Module.py:1.5 Mon Aug 11 11:29:35 2003
--- gnue-appserver/src/classrep/Module.py Thu Sep 18 11:14:10 2003
***************
*** 19,25 ****
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Module.py,v 1.5 2003/08/11 15:29:35 reinhard Exp $
from Base import *
--- 19,25 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Module.py,v 1.6 2003/09/18 15:14:10 jvetter Exp $
from Base import *
***************
*** 56,63 ****
# Internal: Request modules from datasource (optional matching a name)
#
---------------------------------------------------------------------------
def _requestData (self, name = None):
- # print "DEBUG: Module: requestData (%s)" % name
-
cond = []
if name:
cond = [["eq", ""], ["field", "gnue_name"], ["const", name]]
--- 56,61 ----
***************
*** 79,85 ****
return self._cache [name]
# since it isn't cached we've to ask for it
- # print "DEBUG: Module: REFETCH (%s)" % name
list = self._requestData (name)
# if we have an exact match extend the cache
--- 77,82 ----
***************
*** 113,117 ****
--- 110,119 ----
return self.classes
else:
+ # +jve
+ if attr == 'gnue_comment':
+ print "RETR : ", self._object._cache
+ print "delegating request to", self._object
+ # -jve
return getattr (self._object, attr)
Index: gnue-appserver/src/classrep/Namespace.py
diff -c gnue-appserver/src/classrep/Namespace.py:1.1
gnue-appserver/src/classrep/Namespace.py:1.2
*** gnue-appserver/src/classrep/Namespace.py:1.1 Sat Mar 8 12:41:53 2003
--- gnue-appserver/src/classrep/Namespace.py Thu Sep 18 11:14:10 2003
***************
*** 19,30 ****
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Namespace.py,v 1.1 2003/03/08 17:41:53 jvetter Exp $
import string
#
=============================================================================
! # Exception class all exceptions or the class-repository are derived from
#
=============================================================================
class EClassRepository (Exception):
def __init__ (self, text):
--- 19,30 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Namespace.py,v 1.2 2003/09/18 15:14:10 jvetter Exp $
import string
#
=============================================================================
! # Base class for all class-repository exceptions
#
=============================================================================
class EClassRepository (Exception):
def __init__ (self, text):
***************
*** 39,45 ****
#
=============================================================================
class EInvalidName (EClassRepository):
def __init__ (self, name):
! msg = "'%s' is not a valid fully qualified identifier." % name
EClassRepository.__init__ (self, msg)
--- 39,45 ----
#
=============================================================================
class EInvalidName (EClassRepository):
def __init__ (self, name):
! msg = "'%s' is not a valid, fully qualified identifier." % name
EClassRepository.__init__ (self, msg)
***************
*** 83,88 ****
--- 83,92 ----
msg = "Invalid repository definition: %s" % text
EClassRepository.__init__ (self, msg)
+ #
=============================================================================
+ # Namespace constants
+ #
=============================================================================
+
NSID_INVALID = -1
NSID_MODULE = 1
NSID_CLASS = 2
***************
*** 111,117 ****
#
-----------------------------------------------------------------------------
# Try to figure out which NSID_* constant applies to identifier
# TODO: implement some methods to recognize class-/typeinformation about
! # the class repository itself.
#
-----------------------------------------------------------------------------
def getNamespaceId (identifier):
# a valid identifier must contain at least one character
--- 115,121 ----
#
-----------------------------------------------------------------------------
# Try to figure out which NSID_* constant applies to identifier
# TODO: implement some methods to recognize class-/typeinformation about
! # the classrepository itself.
#
-----------------------------------------------------------------------------
def getNamespaceId (identifier):
# a valid identifier must contain at least one character
Index: gnue-appserver/src/classrep/Property.py
diff -c gnue-appserver/src/classrep/Property.py:1.5
gnue-appserver/src/classrep/Property.py:1.6
*** gnue-appserver/src/classrep/Property.py:1.5 Tue Aug 12 13:04:52 2003
--- gnue-appserver/src/classrep/Property.py Thu Sep 18 11:14:10 2003
***************
*** 19,25 ****
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Property.py,v 1.5 2003/08/12 17:04:52 reinhard Exp $
from Base import *
from Namespace import *
--- 19,25 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Property.py,v 1.6 2003/09/18 15:14:10 jvetter Exp $
from Base import *
from Namespace import *
***************
*** 69,76 ****
if prop.gnue_class == classId:
return []
- # print "DEBUG: Property: requestData %s, %s" % (classId, propertyName)
-
cond = [["eq", ""], ["field", "gnue_class"], ["const", classId]]
if propertyName:
--- 69,74 ----
***************
*** 108,114 ****
return self._cache [name]
# since we had no match in the cache ask for it
- # print "DEBUG: Property: REFETCH: %s, %s" % (self.klass.fullName, name)
res = self._requestData (self.klass.gnue_id, name)
if len (res) == 1:
--- 106,111 ----
Index: gnue-appserver/src/classrep/mtest.py
diff -c gnue-appserver/src/classrep/mtest.py:1.3
gnue-appserver/src/classrep/mtest.py:1.4
*** gnue-appserver/src/classrep/mtest.py:1.3 Fri Aug 8 15:33:51 2003
--- gnue-appserver/src/classrep/mtest.py Thu Sep 18 11:14:10 2003
***************
*** 1,4 ****
! # Testing unit for Class Repository
from language import App
from gnue.appserver import classrep
--- 1,28 ----
! # GNU Enterprise Application Server - Testing unit for Class Repository
! #
! # Copyright 2003 Free Software Foundation
! #
! # This file is part of GNU Enterprise.
! #
! # GNU Enterprise is free software; you can redistribute it
! # and/or modify it under the terms of the GNU General Public
! # License as published by the Free Software Foundation; either
! # version 2, or (at your option) any later version.
! #
! # GNU Enterprise is distributed in the hope that it will be
! # useful, but WITHOUT ANY WARRANTY; without even the implied
! # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
! # PURPOSE. See the GNU General Public License for more details.
! #
! # You should have received a copy of the GNU General Public
! # License along with program; see the file COPYING. If not,
! # write to the Free Software Foundation, Inc., 59 Temple Place
! # - Suite 330, Boston, MA 02111-1307, USA.
! #
! # $Id: mtest.py,v 1.4 2003/09/18 15:14:10 jvetter Exp $
! #
! # This testing unit dumps some values of class definitions.
! #
from language import App
from gnue.appserver import classrep
***************
*** 16,21 ****
--- 40,46 ----
print "Fullname:", aClass.fullName
print "Id :", aClass.gnue_id
print "Module :", aClass.module.fullName
+ print "Comment :", aClass.gnue_comment
print "\nProperties:"
***************
*** 28,33 ****
--- 53,59 ----
print "End of dump for '%s'\n" % aName
+ # dump some class definitions
dumpClass ('address_person')
dumpClass ('gnue_class')
***************
*** 36,39 ****
y = x.findProp ('gnue_name')
print "Fullname:", y.fullName
print "Module :", y.klass.module.fullName
!
--- 62,65 ----
y = x.findProp ('gnue_name')
print "Fullname:", y.fullName
print "Module :", y.klass.module.fullName
! print "Type :", y.gnue_type
Index: gnue-appserver/src/geasSession.py
diff -c gnue-appserver/src/geasSession.py:1.37
gnue-appserver/src/geasSession.py:1.38
*** gnue-appserver/src/geasSession.py:1.37 Wed Sep 10 16:31:39 2003
--- gnue-appserver/src/geasSession.py Thu Sep 18 11:14:10 2003
***************
*** 19,25 ****
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: geasSession.py,v 1.37 2003/09/10 20:31:39 reinhard Exp $
import geasList
import classrep
--- 19,25 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: geasSession.py,v 1.38 2003/09/18 15:14:10 jvetter Exp $
import geasList
import classrep
***************
*** 168,174 ****
#
---------------------------------------------------------------------------
def load (self, classname, obj_id_list, propertylist):
! list = self._createList (self, classname, ["gnue_id"] + propertylist, [])
result = []
for object_id in obj_id_list:
instance = list.find (object_id)
--- 168,174 ----
#
---------------------------------------------------------------------------
def load (self, classname, obj_id_list, propertylist):
! list = self._createList (classname, ["gnue_id"] + propertylist, [])
result = []
for object_id in obj_id_list:
instance = list.find (object_id)
Index: gnue-appserver/src/language/Object.py
diff -c gnue-appserver/src/language/Object.py:1.5
gnue-appserver/src/language/Object.py:1.6
*** gnue-appserver/src/language/Object.py:1.5 Mon Feb 24 11:33:36 2003
--- gnue-appserver/src/language/Object.py Thu Sep 18 11:14:10 2003
***************
*** 19,25 ****
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Object.py,v 1.5 2003/02/24 16:33:36 jvetter Exp $
import sys
--- 19,25 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: Object.py,v 1.6 2003/09/18 15:14:10 jvetter Exp $
import sys
***************
*** 46,74 ****
# if a dictionary with instance data is given, populate the cache
if objData:
! self.objectId = objData['gnue_id']
# transfer all data from objData to the initial cache
for key in objData.keys ():
! self._cache[key] = objData[key]
# -------------------------------------------------------------------------
# Return an attribute's value; if not available in cache load from server
# -------------------------------------------------------------------------
def __getattr__ (self, attr):
if not self._cache.has_key (attr):
! try:
! if self._attrIsValid (attr):
! res = self._server.load (self._session_id, self._class,
! [self.objectId], [attr]) [0]
! self._cache[attr] = res[attr]
! else:
! raise AttributeError, attr
! except:
! raise AttributeError, attr
!
! return self._cache[attr]
# -------------------------------------------------------------------------
--- 46,70 ----
# if a dictionary with instance data is given, populate the cache
if objData:
! self.objectId = objData ['gnue_id']
# transfer all data from objData to the initial cache
for key in objData.keys ():
! self._cache [key] = objData [key]
# -------------------------------------------------------------------------
# Return an attribute's value; if not available in cache load from server
# -------------------------------------------------------------------------
def __getattr__ (self, attr):
if not self._cache.has_key (attr):
! if self._attrIsValid (attr):
! res = self._server.load (self._session_id, self._class,
! [self.objectId], [attr]) [0]
! self._cache [attr] = res [0]
! else:
! raise AttributeError, attr
! return self._cache [attr]
# -------------------------------------------------------------------------
***************
*** 76,87 ****
# -------------------------------------------------------------------------
def __setattr__ (self, attr, value):
if self.__dict__.has_key (attr):
! self.__dict__[attr] = value
else:
if not self._attrIsValid (attr):
raise AttributeError, attr
! self._cache[attr] = value
# -------------------------------------------------------------------------
# Check if 'attr' is a valid attribute of this class
--- 72,83 ----
# -------------------------------------------------------------------------
def __setattr__ (self, attr, value):
if self.__dict__.has_key (attr):
! self.__dict__ [attr] = value
else:
if not self._attrIsValid (attr):
raise AttributeError, attr
! self._cache [attr] = value
# -------------------------------------------------------------------------
# Check if 'attr' is a valid attribute of this class
***************
*** 109,115 ****
res = self._server.store (self._session_id, self._class, [self.objectId],
prop, [data])
! self.objectId = res[0]
# -------------------------------------------------------------------------
# Delete instance and clear object-id
--- 105,111 ----
res = self._server.store (self._session_id, self._class, [self.objectId],
prop, [data])
! self.objectId = res [0]
# -------------------------------------------------------------------------
# Delete instance and clear object-id
Index: gnue-appserver/src/language/ObjectList.py
diff -c gnue-appserver/src/language/ObjectList.py:1.5
gnue-appserver/src/language/ObjectList.py:1.6
*** gnue-appserver/src/language/ObjectList.py:1.5 Wed Aug 13 08:44:40 2003
--- gnue-appserver/src/language/ObjectList.py Thu Sep 18 11:14:10 2003
***************
*** 19,25 ****
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: ObjectList.py,v 1.5 2003/08/13 12:44:40 siesel Exp $
import types
from Object import newObject
--- 19,25 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: ObjectList.py,v 1.6 2003/09/18 15:14:10 jvetter Exp $
import types
from Object import newObject
***************
*** 97,120 ****
# Populate Cache
# -------------------------------------------------------------------------
def _populateCache (self):
! rset = self._server.fetch (self._session_id, self.list_id,
len(self._cache), CACHE_STEP,
! 0)
for row in rset:
## Convert array into dictonary
! i=1
! objData={}
for p in self.properties:
! objData[p]=row[i]
! i=i+1
! objData["gnue_id"]=row[0]
obj = newObject (self._server, self._session_id, self.classname,
objData)
self._cache.append (obj)
! # fix for gnue-common 0.5.1 release (will be removed for later releases
of gnue-common)
! self._length = len(self._cache)
# return number of updated rows
! return len(rset)
# -------------------------------------------------------------------------
--- 97,123 ----
# Populate Cache
# -------------------------------------------------------------------------
def _populateCache (self):
! rset = self._server.fetch (self._session_id, self.list_id,
! len (self._cache), CACHE_STEP, 0)
for row in rset:
## Convert array into dictonary
! i = 1
! objData = {}
!
for p in self.properties:
! objData [p] = row [i]
! i = i + 1
!
! objData ["gnue_id"] = row [0]
obj = newObject (self._server, self._session_id, self.classname,
objData)
self._cache.append (obj)
! # fix for gnue-common 0.5.1 release (will be removed for later releases
! # of gnue-common)
! self._length = len (self._cache)
# return number of updated rows
! return len (rset)
# -------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue-appserver/src geasSession.py classrep/Clas...,
Johannes Vetter <=