test_views fixes tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 18 Feb 2009 18:06:41 +0100
branchtls-sprint
changeset 822 e3d8db01f3f5
parent 821 78cc1682c3a4
child 823 cb8ccbef8fa5
test_views fixes
view.py
web/component.py
web/views/actions.py
web/views/basetemplates.py
web/views/euser.py
web/views/wfentities.py
--- a/view.py	Wed Feb 18 17:27:08 2009 +0100
+++ b/view.py	Wed Feb 18 18:06:41 2009 +0100
@@ -458,6 +458,9 @@
         if not xmldecl:
             self._stream.xmldecl = u''
 
+    def linkable(self):
+        return False
+    
 # concrete component base classes #############################################
 
 class ReloadableMixIn(object):
--- a/web/component.py	Wed Feb 18 17:27:08 2009 +0100
+++ b/web/component.py	Wed Feb 18 18:06:41 2009 +0100
@@ -81,12 +81,12 @@
         try:
             return self._page_size
         except AttributeError:
-            if 'page_size' in self.extra_kwargs:
-                page_size = self.extra_kwargs['page_size']
-            elif 'page_size' in self.req.form:
-                page_size = int(self.req.form['page_size'])
-            else:
-                page_size = self.req.property_value(self.page_size_property)
+            page_size = self.extra_kwargs.get('page_size')
+            if page_size is None:
+                if 'page_size' in self.req.form:
+                    page_size = int(self.req.form['page_size'])
+                else:
+                    page_size = self.req.property_value(self.page_size_property)
             self._page_size = page_size
             return page_size
 
--- a/web/views/actions.py	Wed Feb 18 17:27:08 2009 +0100
+++ b/web/views/actions.py	Wed Feb 18 18:06:41 2009 +0100
@@ -130,7 +130,7 @@
 
 class ManagePermissionsAction(Action):
     id = 'managepermission'
-    __select__ = one_line_rset() & match_user_groups('managers')
+    __select__ = one_line_rset() & non_final_entity() & match_user_groups('managers')
 
     title = _('manage permissions')
     category = 'moreactions'
@@ -140,8 +140,10 @@
     def registered(cls, vreg):
         super(ManagePermissionsAction, cls).registered(vreg)
         if 'require_permission' in vreg.schema:
-            cls.__select__ |= relation_possible('require_permission', 'subject', 'EPermission',
-                                                action='add')
+            cls.__select__ = (one_line_rset() & non_final_entity() &
+                              (match_user_groups('managers')
+                               | relation_possible('require_permission', 'subject', 'EPermission',
+                                                   action='add')))
         return super(ManagePermissionsAction, cls).registered(vreg)
     
     def url(self):
--- a/web/views/basetemplates.py	Wed Feb 18 17:27:08 2009 +0100
+++ b/web/views/basetemplates.py	Wed Feb 18 18:06:41 2009 +0100
@@ -11,6 +11,7 @@
 from logilab.mtconverter import html_escape
 
 from cubicweb import NoSelectableObject, ObjectNotFound
+from cubicweb.selectors import match_kwargs
 from cubicweb.view import View, MainTemplate,  NOINDEX, NOFOLLOW
 from cubicweb.utils import make_uid, UStringIO
 from cubicweb.web.views.baseviews import vid_from_rset
@@ -480,8 +481,10 @@
 
 class LogFormTemplate(View):
     id = 'logform'
+    __select__ = match_kwargs('id', 'title')
+    
     title = 'log in'
-
+    
     def call(self, id, klass, title=True, message=True):
         self.req.add_css('cubicweb.login.css')
         self.w(u'<div id="%s" class="%s">' % (id, klass))
--- a/web/views/euser.py	Wed Feb 18 17:27:08 2009 +0100
+++ b/web/views/euser.py	Wed Feb 18 18:06:41 2009 +0100
@@ -59,7 +59,7 @@
     content_type = 'text/xml'
 
     def call(self):
-        self.w('''<?xml version="1.0" encoding="%s"?>
+        self.w(u'''<?xml version="1.0" encoding="%s"?>
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
          xmlns:rdfs="http://www.w3org/2000/01/rdf-schema#"
          xmlns:foaf="http://xmlns.com/foaf/0.1/"> '''% self.req.encoding)
--- a/web/views/wfentities.py	Wed Feb 18 17:27:08 2009 +0100
+++ b/web/views/wfentities.py	Wed Feb 18 18:06:41 2009 +0100
@@ -6,6 +6,8 @@
 """
 __docformat__ = "restructuredtext en"
 
+from logilab.mtconverter import html_escape
+
 from cubicweb.selectors import implements
 from cubicweb.common.view import EntityView