--- a/cwvreg.py Mon Jun 14 12:13:46 2010 +0200
+++ b/cwvreg.py Tue Jun 15 18:16:19 2010 +0200
@@ -575,10 +575,11 @@
if depends_on is not None:
self._needs_appobject[obj] = depends_on
- def register_objects(self, path, force_reload=False):
- """overriden to remove objects requiring a missing interface"""
+ def register_objects(self, path):
+ """overriden to give cubicweb's extrapath (eg cubes package's __path__)
+ """
super(CubicWebVRegistry, self).register_objects(
- path, force_reload, self.config.extrapath)
+ path, self.config.extrapath)
def initialization_completed(self):
"""cw specific code once vreg initialization is completed:
--- a/devtools/testlib.py Mon Jun 14 12:13:46 2010 +0200
+++ b/devtools/testlib.py Tue Jun 15 18:16:19 2010 +0200
@@ -83,6 +83,9 @@
def refresh_repo(repo, resetschema=False, resetvreg=False):
+ for pool in repo.pools:
+ pool.close(True)
+ repo.system_source.shutdown()
devtools.reset_test_database(repo.config)
for pool in repo.pools:
pool.reconnect()
--- a/etwist/twctl.py Mon Jun 14 12:13:46 2010 +0200
+++ b/etwist/twctl.py Tue Jun 15 18:16:19 2010 +0200
@@ -40,6 +40,9 @@
cmdname = 'stop'
cfgname = 'twisted'
+ def poststop(self):
+ pass
+
try:
from cubicweb.server import serverctl
--- a/rset.py Mon Jun 14 12:13:46 2010 +0200
+++ b/rset.py Tue Jun 15 18:16:19 2010 +0200
@@ -44,6 +44,7 @@
:type rql: str or unicode
:param rql: the original RQL query string
"""
+
def __init__(self, results, rql, args=None, description=(), rqlst=None):
self.rows = results
self.rowcount = results and len(results) or 0
--- a/schema.py Mon Jun 14 12:13:46 2010 +0200
+++ b/schema.py Tue Jun 15 18:16:19 2010 +0200
@@ -471,10 +471,14 @@
assert action in ('read', 'add', 'delete')
if 'fromeid' in kwargs:
subjtype = session.describe(kwargs['fromeid'])[0]
+ elif 'frometype' in kwargs:
+ subjtype = kwargs.pop('frometype')
else:
subjtype = None
if 'toeid' in kwargs:
objtype = session.describe(kwargs['toeid'])[0]
+ elif 'toetype' in kwargs:
+ objtype = kwargs.pop('toetype')
else:
objtype = None
if objtype and subjtype:
--- a/server/__init__.py Mon Jun 14 12:13:46 2010 +0200
+++ b/server/__init__.py Tue Jun 15 18:16:19 2010 +0200
@@ -180,6 +180,7 @@
{'name': unicode(group)})
create_user(session, login, pwd, 'managers')
session.commit()
+ repo.shutdown()
# reloging using the admin user
config._cubes = None # avoid assertion error
repo, cnx = in_memory_cnx(config, login, password=pwd)
--- a/server/hook.py Mon Jun 14 12:13:46 2010 +0200
+++ b/server/hook.py Tue Jun 15 18:16:19 2010 +0200
@@ -122,6 +122,7 @@
_MARKER = object()
def entity_oldnewvalue(entity, attr):
"""returns the couple (old attr value, new attr value)
+
NOTE: will only work in a before_update_entity hook
"""
# get new value and remove from local dict to force a db query to
@@ -130,6 +131,8 @@
oldvalue = getattr(entity, attr)
if newvalue is not _MARKER:
entity[attr] = newvalue
+ else:
+ newvalue = oldvalue
return oldvalue, newvalue
--- a/server/repository.py Mon Jun 14 12:13:46 2010 +0200
+++ b/server/repository.py Tue Jun 15 18:16:19 2010 +0200
@@ -319,6 +319,7 @@
"""
assert not self._shutting_down, 'already shutting down'
self._shutting_down = True
+ self.system_source.shutdown()
if isinstance(self._looping_tasks, tuple): # if tasks have been started
for looptask in self._looping_tasks:
self.info('canceling task %s...', looptask.name)
@@ -344,7 +345,7 @@
pyro_unregister(self.config)
hits, misses = self.querier.cache_hit, self.querier.cache_miss
try:
- self.info('rqlt st cache hit/miss: %s/%s (%s%% hits)', hits, misses,
+ self.info('rql st cache hit/miss: %s/%s (%s%% hits)', hits, misses,
(hits * 100) / (hits + misses))
hits, misses = self.system_source.cache_hit, self.system_source.cache_miss
self.info('sql cache hit/miss: %s/%s (%s%% hits)', hits, misses,
@@ -497,9 +498,10 @@
"""return a result set containing system wide properties"""
session = self.internal_session()
try:
- return session.execute('Any K,V WHERE P is CWProperty,'
- 'P pkey K, P value V, NOT P for_user U',
- build_descr=False)
+ # don't use session.execute, we don't want rset.req set
+ return self.querier.execute(session, 'Any K,V WHERE P is CWProperty,'
+ 'P pkey K, P value V, NOT P for_user U',
+ build_descr=False)
finally:
session.close()
@@ -584,8 +586,13 @@
session = self._get_session(sessionid, setpool=True)
try:
try:
- return self.querier.execute(session, rqlstring, args,
+ rset = self.querier.execute(session, rqlstring, args,
build_descr)
+ # NOTE: the web front will (re)build it when needed
+ # e.g in facets
+ # Zeroed to avoid useless overhead with pyro
+ rset._rqlst = None
+ return rset
except (Unauthorized, RQLSyntaxError):
raise
except ValidationError, ex:
--- a/server/sources/native.py Mon Jun 14 12:13:46 2010 +0200
+++ b/server/sources/native.py Tue Jun 15 18:16:19 2010 +0200
@@ -335,6 +335,11 @@
def init(self):
self.init_creating()
+ def shutdown(self):
+ if self._eid_creation_cnx:
+ self._eid_creation_cnx.close()
+ self._eid_creation_cnx = None
+
# XXX deprecates [un]map_attribute ?
def map_attribute(self, etype, attr, cb, sourcedb=True):
self._rql_sqlgen.attr_map['%s.%s' % (etype, attr)] = (cb, sourcedb)
--- a/test/unittest_rset.py Mon Jun 14 12:13:46 2010 +0200
+++ b/test/unittest_rset.py Tue Jun 15 18:16:19 2010 +0200
@@ -21,6 +21,7 @@
"""
from urlparse import urlsplit
+import pickle
from rql import parse
@@ -84,6 +85,9 @@
params2 = dict(pair.split('=') for pair in info1[3].split('&'))
self.assertDictEquals(params1, params2)
+ def test_pickle(self):
+ del self.rset.req
+ self.assertEquals(len(pickle.dumps(self.rset)), 392)
def test_build_url(self):
req = self.request()
--- a/vregistry.py Mon Jun 14 12:13:46 2010 +0200
+++ b/vregistry.py Tue Jun 15 18:16:19 2010 +0200
@@ -404,11 +404,11 @@
self._loadedmods = {}
return filemods
- def register_objects(self, path, force_reload=False, extrapath=None):
+ def register_objects(self, path, extrapath=None):
# load views from each directory in the instance's path
filemods = self.init_registration(path, extrapath)
for filepath, modname in filemods:
- self.load_file(filepath, modname, force_reload)
+ self.load_file(filepath, modname)
self.initialization_completed()
def initialization_completed(self):
@@ -446,7 +446,7 @@
return True
return False
- def load_file(self, filepath, modname, force_reload=False):
+ def load_file(self, filepath, modname):
"""load app objects from a python file"""
from logilab.common.modutils import load_module_from_name
if modname in self._loadedmods:
@@ -463,7 +463,7 @@
# module
self._lastmodifs[filepath] = mdate
# load the module
- module = load_module_from_name(modname, use_sys=not force_reload)
+ module = load_module_from_name(modname)
self.load_module(module)
def load_module(self, module):
--- a/web/views/actions.py Mon Jun 14 12:13:46 2010 +0200
+++ b/web/views/actions.py Tue Jun 15 18:16:19 2010 +0200
@@ -261,9 +261,14 @@
menu.label_prefix = self._cw._('add')
super(AddRelatedActions, self).fill_menu(box, menu)
+ def redirect_params(self, entity):
+ return {'__redirectpath': entity.rest_path(), # should not be url quoted!
+ '__redirectvid': self._cw.form.get('vid', '')}
+
def actual_actions(self):
entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
eschema = entity.e_schema
+ params = self.redirect_params(entity)
for rschema, teschema, role in self.add_related_schemas(entity):
if rschema.role_rdef(eschema, teschema, role).role_cardinality(role) in '1?':
if entity.related(rschema, role):
@@ -274,7 +279,7 @@
else:
label = 'add %s %s %s %s' % (teschema, rschema, eschema, role)
url = self.linkto_url(entity, rschema, teschema, 'subject')
- yield self.build_action(self._cw._(label), url)
+ yield self.build_action(self._cw._(label), url, **params)
def add_related_schemas(self, entity):
"""this is actually used ui method to generate 'addrelated' actions from
@@ -309,11 +314,9 @@
if teschema.may_have_permission('add', req):
yield rschema, teschema, role
- def linkto_url(self, entity, rtype, etype, target):
+ def linkto_url(self, entity, rtype, etype, target, **kwargs):
return self._cw.build_url('add/%s' % etype,
- __linkto='%s:%s:%s' % (rtype, entity.eid, target),
- __redirectpath=entity.rest_path(), # should not be url quoted!
- __redirectvid=self._cw.form.get('vid', ''))
+ __linkto='%s:%s:%s' % (rtype, entity.eid, target), **kwargs)
class ViewSameCWEType(action.Action):
--- a/web/views/workflow.py Mon Jun 14 12:13:46 2010 +0200
+++ b/web/views/workflow.py Tue Jun 15 18:16:19 2010 +0200
@@ -20,6 +20,7 @@
* IWorkflowable views and forms
* workflow entities views (State, Transition, TrInfo)
"""
+
__docformat__ = "restructuredtext en"
_ = unicode