goa/gaesource.py
branchtls-sprint
changeset 1802 d628defebc17
parent 1398 5fe84a5f7035
child 1977 606923dff11b
--- a/goa/gaesource.py	Thu May 14 10:24:56 2009 +0200
+++ b/goa/gaesource.py	Thu May 14 11:38:40 2009 +0200
@@ -15,7 +15,7 @@
 
 from google.appengine.api.datastore import Key, Entity, Put, Delete
 from google.appengine.api import datastore_errors, users
-    
+
 def _init_groups(guser, euser):
     # set default groups
     if guser is None:
@@ -82,13 +82,13 @@
             gaeentity[relation] = related or None
     _mark_modified(session, gaeentity)
 
-    
+
 class DatastorePutOp(SingleOperation):
     """delayed put of entities to have less datastore write api calls
 
     * save all modified entities at precommit (should be the first operation
       processed, hence the 0 returned by insert_index())
-      
+
     * in case others precommit operations modify some entities, resave modified
       entities at commit. This suppose that no db changes will occurs during
       commit event but it should be the case.
@@ -103,10 +103,10 @@
             assert not eid in pending
             Put(gaeentity)
         modified.clear()
-        
+
     def commit_event(self):
         self._put_entities()
-        
+
     def precommit_event(self):
         self._put_entities()
 
@@ -117,9 +117,9 @@
     passwd_rql = "Any P WHERE X is CWUser, X login %(login)s, X upassword P"
     auth_rql = "Any X WHERE X is CWUser, X login %(login)s, X upassword %(pwd)s"
     _sols = ({'X': 'CWUser', 'P': 'Password'},)
-    
+
     options = ()
-    
+
     def __init__(self, repo, appschema, source_config, *args, **kwargs):
         AbstractSource.__init__(self, repo, appschema, source_config,
                                 *args, **kwargs)
@@ -128,11 +128,11 @@
             self.authenticate = self.authenticate_gauth
         else:
             self.authenticate = self.authenticate_local
-            
+
     def reset_caches(self):
         """method called during test to reset potential source caches"""
         pass
-    
+
     def init_creating(self):
         pass
 
@@ -144,7 +144,7 @@
 
     def get_connection(self):
         return ConnectionWrapper()
-    
+
     # ISource interface #######################################################
 
     def compile_rql(self, rql):
@@ -152,7 +152,7 @@
         rqlst.restricted_vars = ()
         rqlst.children[0].solutions = self._sols
         return rqlst
-    
+
     def set_schema(self, schema):
         """set the application'schema"""
         self.interpreter = RQLInterpreter(schema)
@@ -161,13 +161,13 @@
             # rql syntax trees used to authenticate users
             self._passwd_rqlst = self.compile_rql(self.passwd_rql)
             self._auth_rqlst = self.compile_rql(self.auth_rql)
-                
+
     def support_entity(self, etype, write=False):
         """return true if the given entity's type is handled by this adapter
         if write is true, return true only if it's a RW support
         """
         return True
-    
+
     def support_relation(self, rtype, write=False):
         """return true if the given relation's type is handled by this adapter
         if write is true, return true only if it's a RW support
@@ -200,7 +200,7 @@
             _init_groups(guser, euser)
             Put(euser)
             return str(euser.key())
-        
+
     def authenticate_local(self, session, login, password):
         """return CWUser eid for the given login/password if this account is
         defined in this source, else raise `AuthenticationError`
@@ -224,8 +224,8 @@
             return rset[0][0]
         except IndexError:
             raise AuthenticationError('bad password')
-    
-    def syntax_tree_search(self, session, union, args=None, cachekey=None, 
+
+    def syntax_tree_search(self, session, union, args=None, cachekey=None,
                            varmap=None):
         """return result from this source for a rql query (actually from a rql
         syntax tree and a solution dictionary mapping each used variable to a
@@ -235,16 +235,16 @@
         results, description = self.interpreter.interpret(union, args,
                                                           session.datastore_get)
         return results # XXX description
-                
+
     def flying_insert(self, table, session, union, args=None, varmap=None):
         raise NotImplementedError
-    
+
     def add_entity(self, session, entity):
         """add a new entity to the source"""
         # do not delay add_entity as other modifications, new created entity
         # needs an eid
         entity.put()
-        
+
     def update_entity(self, session, entity):
         """replace an entity in the source"""
         gaeentity = entity.to_gae_model()
@@ -253,7 +253,7 @@
             for asession in self.repo._sessions.itervalues():
                 if asession.user.eid == entity.eid:
                     asession.user.update(dict(gaeentity))
-                
+
     def delete_entity(self, session, etype, eid):
         """delete an entity from the source"""
         # do not delay delete_entity as other modifications to ensure
@@ -270,7 +270,7 @@
         _radd(session, gaesubj, gaeobj.key(), 's_' + rtype, cards[0])
         _radd(session, gaeobj, gaesubj.key(), 'o_' + rtype, cards[1])
         _clear_related_cache(session, gaesubj, rtype, gaeobj)
-            
+
     def delete_relation(self, session, subject, rtype, object):
         """delete a relation from the source"""
         gaesubj, gaeobj, cards = _rinfo(session, subject, rtype, object)
@@ -280,7 +280,7 @@
         if not object in pending:
             _rdel(session, gaeobj, gaesubj.key(), 'o_' + rtype, cards[1])
         _clear_related_cache(session, gaesubj, rtype, gaeobj)
-        
+
     # system source interface #################################################
 
     def eid_type_source(self, session, eid):
@@ -290,7 +290,7 @@
         except datastore_errors.BadKeyError:
             raise UnknownEid(eid)
         return key.kind(), 'system', None
-    
+
     def create_eid(self, session):
         return None # let the datastore generating key
 
@@ -303,15 +303,14 @@
         record from the entities table to the deleted_entities table
         """
         pass
-        
+
     def fti_unindex_entity(self, session, eid):
         """remove text content for entity with the given eid from the full text
         index
         """
         pass
-        
+
     def fti_index_entity(self, session, entity):
         """add text content of a created/modified entity to the full text index
         """
         pass
-