commit-gnue
[Top][All Lists]
Advanced

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

gnue/appserver/src frontend.py geasInstance.py ...


From: Reinhard Mueller
Subject: gnue/appserver/src frontend.py geasInstance.py ...
Date: Tue, 07 Jan 2003 16:56:56 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Reinhard Mueller <address@hidden>       03/01/07 16:56:56

Modified files:
        appserver/src  : frontend.py geasInstance.py geasSession.py 

Log message:
        Implemented "delete" function. Fixed build of Condition in load, store, 
and call.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/appserver/src/frontend.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/appserver/src/geasInstance.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/appserver/src/geasSession.py.diff?tr1=1.20&tr2=1.21&r1=text&r2=text

Patches:
Index: gnue/appserver/src/frontend.py
diff -c gnue/appserver/src/frontend.py:1.7 gnue/appserver/src/frontend.py:1.8
*** gnue/appserver/src/frontend.py:1.7  Mon Jan  6 11:43:15 2003
--- gnue/appserver/src/frontend.py      Tue Jan  7 16:56:56 2003
***************
*** 19,25 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: frontend.py,v 1.7 2003/01/06 16:43:15 reinhard Exp $
  
  import os, getpass
  from gnue.common import GClientApp
--- 19,25 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: frontend.py,v 1.8 2003/01/07 21:56:56 reinhard Exp $
  
  import os, getpass
  from gnue.common import GClientApp
***************
*** 90,95 ****
--- 90,96 ----
      print "  2 - Display more data"
      print "  3 - Modify objects"
      print "  4 - Add object"
+     print "  5 - Delete objects"
      print "  8 - Request another list"
      print "  9 - Exit"
      print
***************
*** 105,110 ****
--- 106,113 ----
          return self.modify
        elif choice == 4:
          return self.add
+       elif choice == 5:
+         return self.delete
        elif choice == 8:
          return self.request
        elif choice == 9:
***************
*** 257,262 ****
--- 260,292 ----
      # Now, we have the new data in "row" and we can call the "store" function.
      self.server.store (self.session, self.classname, [None], propertylist,
                         [row])
+     self.server.commit (self.session)
+ 
+   # 
---------------------------------------------------------------------------
+   # Delete objects
+   # 
---------------------------------------------------------------------------
+ 
+   def delete (self):
+     # select objects to modify
+     start = askint ("Start with object number", "0")
+ 
+     # get maximum possible object count from given start position
+     if start < 0:                       # from end of list
+       maxcount = -start
+     else:
+       maxcount = self.server.count (self.session, self.list) - start
+ 
+     count = askint ("Number of objects to delete", "%d" % maxcount)
+ 
+     # First, get all object_ids
+     rset = self.server.fetch (self.session, self.list, start, count)
+     object_ids = []
+     for index in range (0, count):
+       object = rset [index]
+       object_ids.append (object ["_id_"])
+ 
+     # Now, delete the objects
+     self.server.delete (self.session, self.classname, object_ids)
      self.server.commit (self.session)
  
    # 
---------------------------------------------------------------------------
Index: gnue/appserver/src/geasInstance.py
diff -c gnue/appserver/src/geasInstance.py:1.9 
gnue/appserver/src/geasInstance.py:1.10
*** gnue/appserver/src/geasInstance.py:1.9      Mon Jan  6 18:50:01 2003
--- gnue/appserver/src/geasInstance.py  Tue Jan  7 16:56:56 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.9 2003/01/06 23:50:01 siesel 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.10 2003/01/07 21:56:56 reinhard Exp $
  
  # 
=============================================================================
  # Instance class
***************
*** 53,58 ****
--- 53,65 ----
      self._record.setField (fieldname, value)
  
    # 
---------------------------------------------------------------------------
+   # Delete this instance 
+   # 
---------------------------------------------------------------------------
+ 
+   def delete (self):
+     self._record.delete ()
+ 
+   # 
---------------------------------------------------------------------------
    # Call a method
    # 
---------------------------------------------------------------------------
  
***************
*** 74,83 ****
        print
      else:
        print "The method %s is not implemented." % methodname
- 
-   # 
---------------------------------------------------------------------------
-   # Delete this instance 
-   # 
---------------------------------------------------------------------------
- 
-   def delete(self):
-     self._record.delete()
--- 81,83 ----
Index: gnue/appserver/src/geasSession.py
diff -c gnue/appserver/src/geasSession.py:1.20 
gnue/appserver/src/geasSession.py:1.21
*** gnue/appserver/src/geasSession.py:1.20      Mon Jan  6 18:50:01 2003
--- gnue/appserver/src/geasSession.py   Tue Jan  7 16:56:56 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.20 2003/01/06 23:50:01 siesel Exp $
  
  import geasList
  import geasTrigger 
--- 19,25 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasSession.py,v 1.21 2003/01/07 21:56:56 reinhard Exp $
  
  import geasList
  import geasTrigger 
***************
*** 38,44 ****
    # FIXME: need a better algorithm here
    result = ""
    for i in range (0, 32):
!     result = result + str ( int (whrandom.random () * 10))
    return result
  
  # 
=============================================================================
--- 38,44 ----
    # FIXME: need a better algorithm here
    result = ""
    for i in range (0, 32):
!     result = result + str (int (whrandom.random () * 10))
    return result
  
  # 
=============================================================================
***************
*** 205,211 ****
      # but for now it works. -- Reinhard
      result = []
      for object_id in obj_id_list:
!       list.setConditions ("= _id_ %s" % object_id)
        list.populate ()
        object = list.firstInstance ()
        row = {}
--- 205,211 ----
      # but for now it works. -- Reinhard
      result = []
      for object_id in obj_id_list:
!       list.setConditions ([['eq', ''], ['field', '_id_'], ['const', 
object_id]])
        list.populate ()
        object = list.firstInstance ()
        row = {}
***************
*** 238,244 ****
        list.setPrefetch (["_id_"] + propertylist)
        list.setSort (["_id_"])
        # Even for an empty object_id, we need to popluate the list.
!       list.setConditions ("= _id_ %s" % object_id)
        list.populate ()
        if object_id:
          object = list.firstInstance ()
--- 238,244 ----
        list.setPrefetch (["_id_"] + propertylist)
        list.setSort (["_id_"])
        # Even for an empty object_id, we need to popluate the list.
!       list.setConditions ([['eq', ''], ['field', '_id_'], ['const', 
object_id]])
        list.populate ()
        if object_id:
          object = list.firstInstance ()
***************
*** 255,260 ****
--- 255,281 ----
        i += 1
      return result
  
+   # 
---------------------------------------------------------------------------
+   # Delete business objects
+   # 
---------------------------------------------------------------------------
+ 
+   def delete (self, classname, obj_id_list):
+     for object_id in obj_id_list:
+       # create a temporary geasList
+       list = self.createList (classname)
+       list.setPrefetch (["_id_"])
+       list.setSort (["_id_"])
+       list.setConditions ([['eq', ''], ['field', '_id_'], ['const', 
object_id]])
+       list.populate ()
+       object = list.firstInstance ()
+       object.delete ()
+       # FIXME: remove this instance from all lists of this session it was
+       # a member of.
+ 
+   # 
---------------------------------------------------------------------------
+   # Call a procedure of business objects
+   # 
---------------------------------------------------------------------------
+ 
    def call(self,classname,obj_id_list,methodname,parameters):    
      # create a temporary geasList
      list = geasList.geasList (self, classname)
***************
*** 264,270 ****
      # but for now it works. -- Reinhard
      result = []
      for object_id in obj_id_list:
!       list.setConditions ("= _id_ %s" % object_id)
        list.populate ()
        object = list.firstInstance ()
        result.append (object.call(methodname,parameters))
--- 285,291 ----
      # but for now it works. -- Reinhard
      result = []
      for object_id in obj_id_list:
!       list.setConditions ([['eq', ''], ['field', '_id_'], ['const', 
object_id]])
        list.populate ()
        object = list.firstInstance ()
        result.append (object.call(methodname,parameters))
***************
*** 275,279 ****
  #   it is working  -- Siesel
  #   return self._getClass(classname).call(obj_id_list,methodname,parameters)
  
-   def delete(self,classname,obj_id_list):
-     return self._getClass(classname).delete(obj_id_list)
--- 296,298 ----




reply via email to

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