backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 10 May 2010 16:59:32 +0200
changeset 5508 6718ba5db0eb
parent 5493 c323ff08ad35 (current diff)
parent 5507 3604c1c78295 (diff)
child 5510 d3e155cab542
backport stable
cwctl.py
dbapi.py
etwist/server.py
migration.py
selectors.py
web/application.py
web/request.py
web/views/tableview.py
web/webconfig.py
--- a/bin/cubicweb-ctl.bat	Thu May 06 14:29:07 2010 +0200
+++ b/bin/cubicweb-ctl.bat	Mon May 10 16:59:32 2010 +0200
@@ -8,8 +8,8 @@
 """
 # -------------------- Python section --------------------
 import sys
-from os.path import join, dirname
-sys.path.insert(0, join(dirname(__file__), '..', '..'))
+from os.path import join, dirname, normpath
+sys.path.insert(0, normpath(join(dirname(__file__), '..', '..')))
 from cubicweb.cwctl import run
 run(sys.argv[1:])
 
--- a/cwctl.py	Thu May 06 14:29:07 2010 +0200
+++ b/cwctl.py	Mon May 10 16:59:32 2010 +0200
@@ -285,7 +285,7 @@
                     print 'is not installed, but required by %s' % ' '.join(cfgpb.reverse_constraints[cube])
                 else:
                     print '* cube %s version %s is installed, but version %s is required by (%s)' % (
-                        cube, cfgpb.cubes[cube].version, version, ', '.join(cfgpb.reverse_constraints[cube]))
+                        cube, cfgpb.cubes[cube], version, ', '.join(cfgpb.reverse_constraints[cube]))
 
 class CreateInstanceCommand(Command):
     """Create an instance from a cube. This is an unified
--- a/dbapi.py	Thu May 06 14:29:07 2010 +0200
+++ b/dbapi.py	Mon May 10 16:59:32 2010 +0200
@@ -28,6 +28,7 @@
 from time import time, clock
 from itertools import count
 from warnings import warn
+from os.path import join
 
 from logilab.common.logging_ext import set_log_methods
 from logilab.common.decorators import monkeypatch
@@ -550,7 +551,7 @@
         if 'views' in subpath:
             esubpath = list(subpath)
             esubpath.remove('views')
-            esubpath.append('web/views')
+            esubpath.append(join('web', 'views'))
         cubes = reversed([config.cube_dir(p) for p in cubes])
         vpath = config.build_vregistry_path(cubes, evobjpath=esubpath,
                                             tvobjpath=subpath)
--- a/etwist/server.py	Thu May 06 14:29:07 2010 +0200
+++ b/etwist/server.py	Mon May 10 16:59:32 2010 +0200
@@ -38,7 +38,7 @@
 from twisted.web import static, resource
 from twisted.web.server import NOT_DONE_YET
 
-from simplejson import dumps
+from cubicweb.web import dumps
 
 from logilab.common.decorators import monkeypatch
 
--- a/etwist/service.py	Thu May 06 14:29:07 2010 +0200
+++ b/etwist/service.py	Mon May 10 16:59:32 2010 +0200
@@ -26,8 +26,7 @@
     sys.exit(3)
 
 
-from cubicweb.etwist.server import (CubicWebRootResource, reactor, server,
-                                    parsePOSTData, channel)
+from cubicweb.etwist.server import (CubicWebRootResource, reactor, server)
 
 import logging
 from logging import getLogger, handlers
@@ -39,7 +38,7 @@
     for var in env_vars:
         if var not in env:
             raise Exception('The environment variables %s must be set.' % \
-                            ', '.join(env_vars))            
+                            ', '.join(env_vars))
     if not env.get('USERNAME'):
         env['USERNAME'] = 'cubicweb'
 
@@ -53,7 +52,6 @@
         cwcfg.load_cwctl_plugins()
         logger = getLogger('cubicweb')
         set_log_methods(CubicWebRootResource, logger)
-        server.parsePOSTData = parsePOSTData
 
     def SvcStop(self):
         self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
@@ -78,7 +76,7 @@
             # serve it via standard HTTP on port set in the configuration
             port = config['port'] or 8080
             logger.info('listening on port %s' % port)
-            reactor.listenTCP(port, channel.HTTPFactory(website))
+            reactor.listenTCP(port, website)
             root_resource.init_publisher()
             root_resource.start_service()
             logger.info('instance started on %s', root_resource.base_url)
--- a/migration.py	Thu May 06 14:29:07 2010 +0200
+++ b/migration.py	Mon May 10 16:59:32 2010 +0200
@@ -391,7 +391,7 @@
                 if optdict.get('default') is REQUIRED:
                     self.config.input_option(optdescr[1], optdict)
         self.config.generate_config(open(newconfig, 'w'))
-        show_diffs(configfile, newconfig, ask_confirm=self.confirm is not yes)
+        show_diffs(configfile, newconfig, askconfirm=self.confirm is not yes)
         os.close(fd)
         if exists(newconfig):
             os.unlink(newconfig)
--- a/selectors.py	Thu May 06 14:29:07 2010 +0200
+++ b/selectors.py	Mon May 10 16:59:32 2010 +0200
@@ -689,6 +689,16 @@
         return rset and self.match_expected(len(rset.column_types(col))) or 0
 
 
+@objectify_selector
+def logged_user_in_rset(cls, req, rset=None, row=None, col=0, **kwargs):
+    """Return positive score if the result set at the specified row / col
+    contains the eid of the logged user.
+    """
+    if rset is None:
+        return 0
+    return req.user.eid == rset[row or 0][col]
+
+
 # entity selectors #############################################################
 
 class non_final_entity(EClassSelector):
@@ -1052,7 +1062,7 @@
 
 @objectify_selector
 @lltrace
-def no_cnx(cls, req, rset, *args, **kwargs):
+def no_cnx(cls, req, **kwargs):
     """Return 1 if the web session has no connection set. This occurs when
     anonymous access is not allowed and user isn't authenticated.
 
--- a/web/application.py	Thu May 06 14:29:07 2010 +0200
+++ b/web/application.py	Mon May 10 16:59:32 2010 +0200
@@ -270,7 +270,7 @@
         """logout from the instance by cleaning the session and raising
         `AuthenticationError`
         """
-        self.session_manager.close_session(req.cnx)
+        self.session_manager.close_session(req.session)
         req.remove_cookie(req.get_cookie(), self.SESSION_VAR)
         raise LogOut(url=goto_url)
 
--- a/web/data/cubicweb.ajax.js	Thu May 06 14:29:07 2010 +0200
+++ b/web/data/cubicweb.ajax.js	Mon May 10 16:59:32 2010 +0200
@@ -60,7 +60,7 @@
     //    returned several 'root' nodes and we need to keep the wrapper
     //    created by getDomFromResponse()
     if (response.childNodes.length == 1 &&
-	response.getAttribute('cubicweb:type') == 'cwResponseWrapper') {
+        response.getAttribute('cubicweb:type') == 'cwResponseWrapper') {
         return response.firstChild;
     }
     return response;
@@ -286,6 +286,7 @@
         if (node) {
             // make sure the component is visible
             removeElementClass(node, "hidden");
+            domnode = preprocessAjaxLoad(node, domnode);
             swapDOM(node, domnode);
             postAjaxLoad(domnode);
         }
--- a/web/formfields.py	Thu May 06 14:29:07 2010 +0200
+++ b/web/formfields.py	Mon May 10 16:59:32 2010 +0200
@@ -724,7 +724,10 @@
             # will try to remove already attached file if any
             raise UnmodifiedField()
         # value is a 2-uple (filename, stream)
-        filename, stream = value
+        try:
+            filename, stream = value
+        except ValueError:
+            raise UnmodifiedField()
         # XXX avoid in memory loading of posted files. Requires Binary handling changes...
         value = Binary(stream.read())
         if not value.getvalue(): # usually an unexistant file
--- a/web/htmlwidgets.py	Thu May 06 14:29:07 2010 +0200
+++ b/web/htmlwidgets.py	Mon May 10 16:59:32 2010 +0200
@@ -326,7 +326,7 @@
         self.w(u'<tr class="header">')
         for column in self.columns:
             attrs = ('%s="%s"' % (name, value) for name, value in column.cell_attrs.iteritems())
-            self.w(u'<th %s>%s</th>' % (' '.join(attrs), column.name))
+            self.w(u'<th %s>%s</th>' % (' '.join(attrs), column.name or u''))
         self.w(u'</tr>')
         self.w(u'</thead><tbody>')
         for rowindex in xrange(len(self.model.get_rows())):
--- a/web/request.py	Thu May 06 14:29:07 2010 +0200
+++ b/web/request.py	Mon May 10 16:59:32 2010 +0200
@@ -372,7 +372,7 @@
                 ret = func(req, *args)
             except TypeError:
                 from warnings import warn
-                warn('user callback should now take request as argument')
+                warn('[3.2] user callback should now take request as argument')
                 ret = func(*args)
             self.unregister_callback(self.pageid, cbname)
             return ret
--- a/web/views/cwproperties.py	Thu May 06 14:29:07 2010 +0200
+++ b/web/views/cwproperties.py	Mon May 10 16:59:32 2010 +0200
@@ -27,12 +27,14 @@
 
 from cubicweb import UnknownProperty
 from cubicweb.selectors import (one_line_rset, none_rset, implements,
-                                match_user_groups, objectify_selector)
+                                match_user_groups, objectify_selector,
+                                logged_user_in_rset)
 from cubicweb.view import StartupView
 from cubicweb.web import uicfg, stdmsgs
 from cubicweb.web.form import FormViewMixIn
 from cubicweb.web.formfields import FIELDS, StringField
-from cubicweb.web.formwidgets import Select, TextInput, Button, SubmitButton, FieldWidget
+from cubicweb.web.formwidgets import (Select, TextInput, Button, SubmitButton,
+                                      FieldWidget)
 from cubicweb.web.views import primary, formrenderers
 
 uicfg.primaryview_section.tag_object_of(('*', 'for_user', '*'), 'hidden')
@@ -233,17 +235,12 @@
         return subform
 
 
-@objectify_selector
-def is_user_prefs(cls, req, rset=None, row=None, col=0, **kwargs):
-    return req.user.eid == rset[row or 0][col]
-
-
 class CWPropertiesForm(SystemCWPropertiesForm):
     """user's preferences properties edition form"""
     __regid__ = 'propertiesform'
     __select__ = (
         (none_rset() & match_user_groups('users','managers'))
-        | (one_line_rset() & match_user_groups('users') & is_user_prefs())
+        | (one_line_rset() & match_user_groups('users') & logged_user_in_rset())
         | (one_line_rset() & match_user_groups('managers') & implements('CWUser'))
         )
 
--- a/web/views/tableview.py	Thu May 06 14:29:07 2010 +0200
+++ b/web/views/tableview.py	Mon May 10 16:59:32 2010 +0200
@@ -224,7 +224,7 @@
             # compute column header
             if headers is not None:
                 label = headers[displaycols.index(colindex)]
-            if colindex == mainindex:
+            if colindex == mainindex and label is not None:
                 label += ' (%s)' % self.cw_rset.rowcount
             column = TableColumn(label, colindex)
             coltype = self.cw_rset.description[0][colindex]
@@ -287,8 +287,7 @@
         """
         etype, val = self.cw_rset.description[row][col], self.cw_rset[row][col]
         if val is not None and not self._cw.vreg.schema.eschema(etype).final:
-            e = self.cw_rset.get_entity(row, col)
-            e.view(cellvid or 'outofcontext', w=self.w)
+            self.wview(cellvid or 'outofcontext', self.cw_rset, row=row, col=col)
         elif val is None:
             # This is usually caused by a left outer join and in that case,
             # regular views will most certainly fail if they don't have
--- a/web/webconfig.py	Thu May 06 14:29:07 2010 +0200
+++ b/web/webconfig.py	Mon May 10 16:59:32 2010 +0200
@@ -77,7 +77,7 @@
     """the WebConfiguration is a singleton object handling instance's
     configuration and preferences
     """
-    cubicweb_appobject_path = CubicWebConfiguration.cubicweb_appobject_path | set(['web/views'])
+    cubicweb_appobject_path = CubicWebConfiguration.cubicweb_appobject_path | set([join('web', 'views')])
     cube_appobject_path = CubicWebConfiguration.cube_appobject_path | set(['views'])
     uiprops = {'FCKEDITOR_PATH': ''}