cleanups stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 20 Aug 2010 08:31:02 +0200
branchstable
changeset 6128 fbb8398f80dc
parent 6127 747e423093fc
child 6129 fea746b60093
cleanups
server/msplanner.py
server/querier.py
server/repository.py
server/serverconfig.py
server/sources/native.py
server/sources/pyrorql.py
server/utils.py
--- a/server/msplanner.py	Fri Aug 20 08:29:48 2010 +0200
+++ b/server/msplanner.py	Fri Aug 20 08:31:02 2010 +0200
@@ -100,9 +100,9 @@
 
 from cubicweb import server
 from cubicweb.utils import make_uid
+from cubicweb.rqlrewrite import add_types_restriction
 from cubicweb.server.utils import cleanup_solutions
-from cubicweb.server.ssplanner import (SSPlanner, OneFetchStep,
-                                       add_types_restriction)
+from cubicweb.server.ssplanner import SSPlanner, OneFetchStep
 from cubicweb.server.mssteps import *
 
 Variable._ms_table_key = lambda x: x.name
--- a/server/querier.py	Fri Aug 20 08:29:48 2010 +0200
+++ b/server/querier.py	Fri Aug 20 08:31:02 2010 +0200
@@ -422,7 +422,9 @@
         # raise Unautorized exception if the user can't access to any solution
         if not newsolutions:
             raise Unauthorized('\n'.join(msgs))
-        rqlst.set_possible_types(newsolutions)
+        if msgs:
+            # (else solutions have not been modified)
+            rqlst.set_possible_types(newsolutions)
         return localchecks, restricted_vars
 
     def finalize(self, select, solutions, insertedvars):
--- a/server/repository.py	Fri Aug 20 08:29:48 2010 +0200
+++ b/server/repository.py	Fri Aug 20 08:31:02 2010 +0200
@@ -201,8 +201,8 @@
             for source in self.sources:
                 source.init()
         else:
-            # call init_creating so for instance native source can configurate
-            # tsearch according to postgres version
+            # call init_creating so that for instance native source can
+            # configurate tsearch according to postgres version
             for source in self.sources:
                 source.init_creating()
         # close initialization pool and reopen fresh ones for proper
@@ -1237,15 +1237,15 @@
 
     @cached
     def rel_type_sources(self, rtype):
-        return [source for source in self.sources
-                if source.support_relation(rtype)
-                or rtype in source.dont_cross_relations]
+        return tuple([source for source in self.sources
+                      if source.support_relation(rtype)
+                      or rtype in source.dont_cross_relations])
 
     @cached
     def can_cross_relation(self, rtype):
-        return [source for source in self.sources
-                if source.support_relation(rtype)
-                and rtype in source.cross_relations]
+        return tuple([source for source in self.sources
+                      if source.support_relation(rtype)
+                      and rtype in source.cross_relations])
 
     @cached
     def is_multi_sources_relation(self, rtype):
--- a/server/serverconfig.py	Fri Aug 20 08:29:48 2010 +0200
+++ b/server/serverconfig.py	Fri Aug 20 08:31:02 2010 +0200
@@ -23,7 +23,7 @@
 
 from logilab.common.configuration import REQUIRED, Method, Configuration, \
      ini_format_section
-from logilab.common.decorators import wproperty, cached, clear_cache
+from logilab.common.decorators import wproperty, cached
 
 from cubicweb.toolsutils import read_config, restrict_perms_to_user
 from cubicweb.cwconfig import CubicWebConfiguration, merge_options
@@ -156,7 +156,7 @@
         ('multi-sources-etypes',
          {'type' : 'csv', 'default': (),
           'help': 'defines which entity types from this repository are used \
-by some other instances. You should set this properly so those instances to \
+by some other instances. You should set this properly for these instances to \
 detect updates / deletions.',
           'group': 'main', 'level': 3,
           }),
--- a/server/sources/native.py	Fri Aug 20 08:29:48 2010 +0200
+++ b/server/sources/native.py	Fri Aug 20 08:31:02 2010 +0200
@@ -505,7 +505,7 @@
     def manual_insert(self, results, table, session):
         """insert given result into a temporary table on the system source"""
         if server.DEBUG & server.DBG_RQL:
-            print '  manual insertion of', results, 'into', table
+            print '  manual insertion of', len(results), 'results into', table
         if not results:
             return
         query_args = ['%%(%s)s' % i for i in xrange(len(results[0]))]
--- a/server/sources/pyrorql.py	Fri Aug 20 08:29:48 2010 +0200
+++ b/server/sources/pyrorql.py	Fri Aug 20 08:31:02 2010 +0200
@@ -15,9 +15,8 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""Source to query another RQL repository using pyro
+"""Source to query another RQL repository using pyro"""
 
-"""
 __docformat__ = "restructuredtext en"
 
 import threading
@@ -59,8 +58,6 @@
     # migration
     connect_for_migration = False
 
-    support_entities = None
-
     options = (
         # XXX pyro-ns host/port
         ('pyro-ns-id',
--- a/server/utils.py	Fri Aug 20 08:29:48 2010 +0200
+++ b/server/utils.py	Fri Aug 20 08:31:02 2010 +0200
@@ -15,9 +15,7 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""Some utilities for the CubicWeb server.
-
-"""
+"""Some utilities for the CubicWeb server."""
 __docformat__ = "restructuredtext en"
 
 import sys
@@ -62,7 +60,7 @@
         """recursive looping function"""
         if seqin:                   # any more sequences to process?
             for item in seqin[0]:
-                newcomb = comb + [item]     # add next item to current combination
+                newcomb = comb + [item] # add next item to current combination
                 # call rloop w/ remaining seqs, newcomb
                 for item in rloop(seqin[1:], newcomb):
                     yield item          # seqs and newcomb