[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r6922 - trunk/gnue-appserver/src
From: |
johannes |
Subject: |
[gnue] r6922 - trunk/gnue-appserver/src |
Date: |
Tue, 25 Jan 2005 04:15:23 -0600 (CST) |
Author: johannes
Date: 2005-01-25 04:15:23 -0600 (Tue, 25 Jan 2005)
New Revision: 6922
Modified:
trunk/gnue-appserver/src/geasList.py
trunk/gnue-appserver/src/geasSession.py
Log:
Implemented <exist> conditions
Modified: trunk/gnue-appserver/src/geasList.py
===================================================================
--- trunk/gnue-appserver/src/geasList.py 2005-01-25 10:14:57 UTC (rev
6921)
+++ trunk/gnue-appserver/src/geasList.py 2005-01-25 10:15:23 UTC (rev
6922)
@@ -24,7 +24,10 @@
import geasInstance
import string
import time
+import copy
+from gnue.common.datasources import GConditions
+
# =============================================================================
# List class
# =============================================================================
@@ -50,6 +53,11 @@
self.__asSorting = asSort # additional sortorder of this list
self.__length = 0
+ # If we have a condition to process, make sure we set a proper callback for
+ # exist-conditions
+ if self.__condition is not None:
+ for item in self.__condition.findChildrenOfType ('GCexist', True, True):
+ item.callback = self.__evaluateExist
# ---------------------------------------------------------------------------
@@ -268,3 +276,37 @@
self.__instances = []
self.__unsorted = []
+
+
+ # ---------------------------------------------------------------------------
+ # Evaluate an exist condition for an instance
+ # ---------------------------------------------------------------------------
+
+ def __evaluateExist (self, caller, lookup):
+ """
+ This function evaluates an exist-condition for the instance given in
+ 'lookup'.
+ @param caller: GCexist instance defining the condition
+ @param lookup: geasInstance instance to be evaluated
+ @return: True if there are instance matching the condition, False otherwise
+ """
+
+ linkCond = GConditions.buildConditionFromDict ( \
+ {caller.detaillink: lookup [caller.masterlink]})
+
+ parent = linkCond._children [0]
+
+ # If the condition has a subcondition we need to 'copy' this subcondition
+ # elements. This is to prevent appserver's changes made to the condition
+ # elements later, disturbing the following request.
+ if len (caller._children):
+ for c in caller._children:
+ new = GConditions.buildTreeFromList (c.prefixNotation ())
+ new.parent = parent
+ parent._children.append (new)
+
+ resList = self.__session.request (caller.table, linkCond, [], [u'gnue_id'])
+ result = self.__session.fetch (resList, 0, 1)
+
+ return len (result) > 0
+
Modified: trunk/gnue-appserver/src/geasSession.py
===================================================================
--- trunk/gnue-appserver/src/geasSession.py 2005-01-25 10:14:57 UTC (rev
6921)
+++ trunk/gnue-appserver/src/geasSession.py 2005-01-25 10:15:23 UTC (rev
6922)
@@ -794,10 +794,13 @@
def __dbHandlesTree (self, tree, classdef):
"""
This function traverses the given condition tree and determines if it can
- be handled be the datasource completely.
+ be handled by the datasource completely.
"""
if isinstance (tree, GConditions.GCField):
return self.__usable (tree, classdef)
+ # a backend cannot handle an exist-condition (yet)
+ elif isinstance (tree, GConditions.GCexist):
+ return False
else:
for child in tree._children:
res = self.__dbHandlesTree (child, classdef)
@@ -845,7 +848,10 @@
"""
if isinstance (tree, GConditions.GCField):
self.__getFieldname (classdef, tree.name, content, True)
- else:
+
+ # Note: we do not add fields from an exist-condition to the current
+ # content-dictionary, cause they will be handled by an extra request ()
+ elif not isinstance (tree, GConditions.GCexist):
for child in tree._children:
self.__addConditionToContent (classdef, content, child)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r6922 - trunk/gnue-appserver/src,
johannes <=