commit-gnue
[Top][All Lists]
Advanced

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

gnue-appserver/src geasInstance.py geasList.py ...


From: Reinhard Mueller
Subject: gnue-appserver/src geasInstance.py geasList.py ...
Date: Wed, 10 Sep 2003 16:31:40 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue-appserver
Branch:         
Changes by:     Reinhard Mueller <address@hidden>       03/09/10 16:31:39

Modified files:
        src            : geasInstance.py geasList.py geasSession.py 
                         geasSessionManager.py 

Log message:
        Improved exception handling.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/geasInstance.py.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/geasList.py.diff?tr1=1.29&tr2=1.30&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/geasSession.py.diff?tr1=1.36&tr2=1.37&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/geasSessionManager.py.diff?tr1=1.15&tr2=1.16&r1=text&r2=text

Patches:
Index: gnue-appserver/src/geasInstance.py
diff -c gnue-appserver/src/geasInstance.py:1.18 
gnue-appserver/src/geasInstance.py:1.19
*** gnue-appserver/src/geasInstance.py:1.18     Wed Sep 10 15:31:42 2003
--- gnue-appserver/src/geasInstance.py  Wed Sep 10 16:31:39 2003
***************
*** 19,25 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasInstance.py,v 1.18 2003/09/10 19:31:42 reinhard Exp $
  
  # 
=============================================================================
  # Instance class
--- 19,25 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasInstance.py,v 1.19 2003/09/10 20:31:39 reinhard Exp $
  
  # 
=============================================================================
  # Instance class
***************
*** 50,70 ****
  
      elif propertydef.gnue_type == "number":
        # Number property
        if propertydef.gnue_scale == 0:
          # ... without fractional part
!         return int (self._record.getField (propertydef.column))
        else:
          # ... with fractional part
!         return float (self._record.getField (propertydef.column))
        
      elif self._classdef.classes.has_key (propertydef.gnue_type):
        # Reference property: gnue_type is a classname
        return self._record.getField (propertydef.column)
      # TODO: Missing property types:
      #       * datetime
      #       * boolean
      #       * list properties
      #       * calculated properties (must have triggers working first)
      else:
        raise Exception, "Field type '%s' not defined." % propertydef.gnue_type
  
--- 50,81 ----
  
      elif propertydef.gnue_type == "number":
        # Number property
+       s = self._record.getField (propertydef.column)
        if propertydef.gnue_scale == 0:
          # ... without fractional part
!         try:
!           return int (s)
!         except ValueError:
!           raise Exception, "Database returned invalid value '%s' for" + \
!                            "property '%s'" % (s, propertyname)
        else:
          # ... with fractional part
!         try:
!           return float (s)
!         except ValueError:
!           raise Exception, "Database returned invalid value '%s' for" + \
!                            "property '%s'" % (s, propertyname)
        
      elif self._classdef.classes.has_key (propertydef.gnue_type):
        # Reference property: gnue_type is a classname
        return self._record.getField (propertydef.column)
+ 
      # TODO: Missing property types:
      #       * datetime
      #       * boolean
      #       * list properties
      #       * calculated properties (must have triggers working first)
+ 
      else:
        raise Exception, "Field type '%s' not defined." % propertydef.gnue_type
  
Index: gnue-appserver/src/geasList.py
diff -c gnue-appserver/src/geasList.py:1.29 gnue-appserver/src/geasList.py:1.30
*** gnue-appserver/src/geasList.py:1.29 Mon Sep  1 16:11:37 2003
--- gnue-appserver/src/geasList.py      Wed Sep 10 16:31:39 2003
***************
*** 19,25 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasList.py,v 1.29 2003/09/01 20:11:37 reinhard Exp $
  
  from gnue.common.datasources import GDataSource, GConditions
  import geasInstance
--- 19,25 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasList.py,v 1.30 2003/09/10 20:31:39 reinhard Exp $
  
  from gnue.common.datasources import GDataSource, GConditions
  import geasInstance
***************
*** 85,96 ****
  
    # 
---------------------------------------------------------------------------
    # Populate the list with a single instance with given gnue_id, and return
!   # that instance
    # 
---------------------------------------------------------------------------
  
    def find (self, object_id):
      self.populate ([['eq', ''], ['field', 'gnue_id'], ['const', object_id]])
!     return self.firstInstance ()
  
    # 
---------------------------------------------------------------------------
    # Populate the list with a single empty instance, and return that instance
--- 85,100 ----
  
    # 
---------------------------------------------------------------------------
    # Populate the list with a single instance with given gnue_id, and return
!   # that instance, return an exception if not found
    # 
---------------------------------------------------------------------------
  
    def find (self, object_id):
      self.populate ([['eq', ''], ['field', 'gnue_id'], ['const', object_id]])
!     result = self.firstInstance ()
!     if result == None:
!       raise Exception, "Can't find object ID '%s' in class '%s'" % \
!                        (object_id, self._classdef.fullName)
!     return result
  
    # 
---------------------------------------------------------------------------
    # Populate the list with a single empty instance, and return that instance
Index: gnue-appserver/src/geasSession.py
diff -c gnue-appserver/src/geasSession.py:1.36 
gnue-appserver/src/geasSession.py:1.37
*** gnue-appserver/src/geasSession.py:1.36      Mon Sep  1 16:11:37 2003
--- gnue-appserver/src/geasSession.py   Wed Sep 10 16:31:39 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.36 2003/09/01 20:11:37 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.37 2003/09/10 20:31:39 reinhard Exp $
  
  import geasList
  import classrep
***************
*** 67,79 ****
      self._dirtyLists = []
  
    # 
---------------------------------------------------------------------------
-   # Get class definition from class name
-   # 
---------------------------------------------------------------------------
- 
-   def _getClassdef (self, classname):
-     return classrep.classes [classname]
- 
-   # 
---------------------------------------------------------------------------
    # Log into the application server
    # 
---------------------------------------------------------------------------
  
--- 67,72 ----
***************
*** 101,109 ****
  
      # check if user has access rights for this class
      if not self._authAdapter.hasAccess (self, self._user, classname):
!       raise Exception, "Access to class %s denied" % classname
  
!     classdef = self._getClassdef (classname)
  
      # create new List
      return geasList.geasList (self, classdef, propertylist, sortorder)
--- 94,102 ----
  
      # check if user has access rights for this class
      if not self._authAdapter.hasAccess (self, self._user, classname):
!       raise Exception, "Access to class '%s' denied" % classname
  
!     classdef = classrep.classes [classname]
  
      # create new List
      return geasList.geasList (self, classdef, propertylist, sortorder)
***************
*** 145,158 ****
      return list_id;
  
    # 
---------------------------------------------------------------------------
    # Count the number of objects in the list
    # 
---------------------------------------------------------------------------
  
    def count (self, list_id):
!     try:
!        list = self._lists [list_id]
!     except:
!       raise Error, 'The list you are trying to access does not exist.'
      return list.count ();
  
    # 
---------------------------------------------------------------------------
--- 138,158 ----
      return list_id;
  
    # 
---------------------------------------------------------------------------
+   # Check list id and raise exception if invalid, return list otherwise
+   # 
---------------------------------------------------------------------------
+ 
+   def _getList (self, list_id):
+     if self._lists.has_key (list_id):
+       return self._lists [list_id]
+     else:
+       raise Exception, "Can't find a list with ID '%s'" % list_id
+ 
+   # 
---------------------------------------------------------------------------
    # Count the number of objects in the list
    # 
---------------------------------------------------------------------------
  
    def count (self, list_id):
!     list = self._getList (list_id)
      return list.count ();
  
    # 
---------------------------------------------------------------------------
***************
*** 160,169 ****
    # 
---------------------------------------------------------------------------
  
    def fetch (self, list_id, start, count):
!     try:
!       list = self._lists [list_id]
!     except:
!       raise Error, 'The list you are trying to access does not exist.'
      return list.fetch (start, count)
  
    # 
---------------------------------------------------------------------------
--- 160,166 ----
    # 
---------------------------------------------------------------------------
  
    def fetch (self, list_id, start, count):
!     list = self._getList (list_id)
      return list.fetch (start, count)
  
    # 
---------------------------------------------------------------------------
Index: gnue-appserver/src/geasSessionManager.py
diff -c gnue-appserver/src/geasSessionManager.py:1.15 
gnue-appserver/src/geasSessionManager.py:1.16
*** gnue-appserver/src/geasSessionManager.py:1.15       Mon Sep  1 14:24:15 2003
--- gnue-appserver/src/geasSessionManager.py    Wed Sep 10 16:31:39 2003
***************
*** 19,25 ****
  #
  # Copyright 2001-2003 Free Software Foundation
  #
! # $Id: geasSessionManager.py,v 1.15 2003/09/01 18:24:15 reinhard Exp $
  
  import geasSession
  import geasAuthentication
--- 19,25 ----
  #
  # Copyright 2001-2003 Free Software Foundation
  #
! # $Id: geasSessionManager.py,v 1.16 2003/09/10 20:31:39 reinhard Exp $
  
  import geasSession
  import geasAuthentication
***************
*** 67,76 ****
    # 
---------------------------------------------------------------------------
  
    def _getSession (self, sess_id):
!     try:
        return self._sessions [sess_id]
!     except:
!       raise Exception, "The session you have requested don't exist anymore"
  
    # 
---------------------------------------------------------------------------
    # official API functions
--- 67,76 ----
    # 
---------------------------------------------------------------------------
  
    def _getSession (self, sess_id):
!     if self._sessions.has_key (sess_id):
        return self._sessions [sess_id]
!     else:
!       raise Exception, "Can't find a session with ID '%s'" % sess_id
  
    # 
---------------------------------------------------------------------------
    # official API functions




reply via email to

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