merge tls-sprint
authorsylvain.thenault@logilab.fr
Thu, 30 Apr 2009 13:08:11 +0200
branchtls-sprint
changeset 1602 3cca95459779
parent 1584 323eed40a2b7 (diff)
parent 1601 171afa270086 (current diff)
child 1603 56217e741939
merge
--- a/common/mttransforms.py	Thu Apr 30 12:57:23 2009 +0200
+++ b/common/mttransforms.py	Thu Apr 30 13:08:11 2009 +0200
@@ -11,7 +11,7 @@
 from logilab.mtconverter.engine import TransformEngine
 from logilab.mtconverter.transform import Transform
 from logilab.mtconverter import (register_base_transforms,
-                                 register_pil_transforms, 
+                                 register_pil_transforms,
                                  register_pygments_transforms)
 
 from cubicweb.common.uilib import rest_publish, html_publish
@@ -31,7 +31,7 @@
     output = 'text/html'
     def _convert(self, trdata):
         return html_publish(trdata.appobject, trdata.data)
-    
+
 
 # Instantiate and configure the transformation engine
 
@@ -47,10 +47,10 @@
     HAS_TAL = False
     from cubicweb.schema import FormatConstraint
     FormatConstraint.need_perm_formats.remove('text/cubicweb-page-template')
-    
+
 else:
     HAS_TAL = True
-    
+
     class ept_to_html(Transform):
         inputs = ('text/cubicweb-page-template',)
         output = 'text/html'
@@ -65,7 +65,7 @@
     HAS_PIL_TRANSFORMS = True
 else:
     HAS_PIL_TRANSFORMS = False
-    
+
 try:
     from logilab.mtconverter.transforms import pygmentstransforms
     for mt in ('text/plain',) + HTML_MIMETYPES:
@@ -84,9 +84,9 @@
             return origconvert(self, trdata)
         cls._convert = _convert
     patch_convert(pygmentstransforms.PygmentsHTMLTransform)
-    
+
     HAS_PYGMENTS_TRANSFORMS = True
 except ImportError:
     HAS_PYGMENTS_TRANSFORMS = False
-    
+
 register_base_transforms(ENGINE, verb=False)
--- a/common/uilib.py	Thu Apr 30 12:57:23 2009 +0200
+++ b/common/uilib.py	Thu Apr 30 13:08:11 2009 +0200
@@ -41,7 +41,7 @@
         # don't translate empty value if you don't want strange results
         if props is not None and value and props.get('internationalizable'):
             return req._(value)
-        
+
         return value
     if attrtype == 'Date':
         return ustrftime(value, req.property_value('ui.date-format'))
@@ -63,12 +63,12 @@
 # text publishing #############################################################
 
 try:
-    from cubicweb.common.rest import rest_publish # pylint: disable-msg=W0611
+    from cubicweb.ext.rest import rest_publish # pylint: disable-msg=W0611
 except ImportError:
     def rest_publish(entity, data):
         """default behaviour if docutils was not found"""
-        return data
-    
+        return html_escape(data)
+
 TAG_PROG = re.compile(r'</?.*?>', re.U)
 def remove_html_tags(text):
     """Removes HTML tags from text
@@ -201,7 +201,7 @@
     return text[:length] + u'...'
 
 
-    
+
 # HTML generation helper functions ############################################
 
 def simple_sgml_tag(tag, content=None, **attrs):
@@ -246,7 +246,7 @@
     >>> ajax_replace_url('foo', 'Person P', 'oneline', name='bar', age=12)
     "javascript: replacePageChunk('foo', 'Person%20P', 'oneline', {'age':12, 'name':'bar'});"
     >>> ajax_replace_url('foo', 'Person P', name='bar', age=12)
-    "javascript: replacePageChunk('foo', 'Person%20P', 'null', {'age':12, 'name':'bar'});"    
+    "javascript: replacePageChunk('foo', 'Person%20P', 'null', {'age':12, 'name':'bar'});"
     """
     params = [repr(nodeid), repr(urlquote(rql))]
     if extraparams and not vid:
@@ -315,7 +315,7 @@
         else:
             for child in path[-1].children:
                 build_matrix(path[:] + [child], matrix)
-        
+
     matrix = []
     build_matrix([tree], matrix)
 
@@ -347,9 +347,9 @@
             if link_type == 0 and i > 0 and links[i-1][j] in (1, 2, 3):
                 link_type = 2
             links[-1].append(link_type)
-    
+
 
-    # We can now generate the HTML code for the <table> 
+    # We can now generate the HTML code for the <table>
     s = u'<table class="tree">\n'
     if caption:
         s += '<caption>%s</caption>\n' % caption
@@ -369,7 +369,7 @@
                 s += '<td rowspan="2">&nbsp;</td>'
             s += '<td class="tree_cell_%d_1">&nbsp;</td>' % link_cell
             s += '<td class="tree_cell_%d_2">&nbsp;</td>' % link_cell
-                
+
         cell = line[-1]
         if cell:
             if cell.id == selected_node:
@@ -459,7 +459,7 @@
                            (boxid, ''.join(html_info)))
             tcbk = tcbk.tb_next
         except Exception:
-            pass # doesn't really matter if we have no context info    
+            pass # doesn't really matter if we have no context info
     strings.append(u'</div>')
     return '\n'.join(strings)
 
@@ -467,7 +467,7 @@
 
 class UnicodeCSVWriter:
     """proxies calls to csv.writer.writerow to be able to deal with unicode"""
-    
+
     def __init__(self, wfunc, encoding, **kwargs):
         self.writer = csv.writer(self, **kwargs)
         self.wfunc = wfunc
--- a/entity.py	Thu Apr 30 12:57:23 2009 +0200
+++ b/entity.py	Thu Apr 30 13:08:11 2009 +0200
@@ -127,6 +127,7 @@
                     if wdgname == 'StringWidget':
                         wdgname = 'TextInput'
                     widget = getattr(formwidgets, wdgname)
+                    assert hasattr(widget, 'render')
                     AutomaticEntityForm.rwidgets.tag_relation(
                         widget, (etype, rtype, '*'), 'subject')
         return super(_metaentity, mcs).__new__(mcs, name, bases, classdict)
--- a/web/views/primary.py	Thu Apr 30 12:57:23 2009 +0200
+++ b/web/views/primary.py	Thu Apr 30 13:08:11 2009 +0200
@@ -234,12 +234,11 @@
         return rset
 
     def _render_relation(self, rset, displayinfo, defaultvid, showlabel):
-        self.w('<div class="section">')
+        self.w(u'<div class="section">')
         if showlabel:
-            label = self.req._(displayinfo['label'])
-            self.w('<h4>%s</h4>' % label)
+            self.w(u'<h4>%s</h4>' % self.req._(displayinfo['label']))
         self.wview(displayinfo.get('vid', defaultvid), rset)
-        self.w('</div>')
+        self.w(u'</div>')
 
     def _render_attribute(self, rschema, value, role='subject'):
         if rschema.is_final():
--- a/web/views/schema.py	Thu Apr 30 12:57:23 2009 +0200
+++ b/web/views/schema.py	Thu Apr 30 13:08:11 2009 +0200
@@ -15,17 +15,17 @@
 from cubicweb.schemaviewer import SchemaViewer
 from cubicweb.view import EntityView, StartupView
 from cubicweb.common import tags, uilib
-from cubicweb.web import uicfg, action
+from cubicweb.web import uicfg, formwidgets, action
 from cubicweb.web.views import TmpFileViewMixin, primary, baseviews
 
 
 uicfg.rcategories.tag_relation('primary', ('CWPermission', 'require_group', '*'), 'subject')
-uicfg.rcategories.tag_relation('generated', ('EEtype', 'final', '*'), 'subject')
-uicfg.rcategories.tag_relation('generated', ('ERtype', 'final', '*'), 'subject')
+uicfg.rcategories.tag_attribute('generated', 'EEtype', 'final')
+uicfg.rcategories.tag_attribute('generated', 'ERtype', 'final')
 uicfg.rinlined.tag_relation(True, ('CWRelation', 'relation_type', '*'), 'subject')
 uicfg.rinlined.tag_relation(True, ('CWRelation', 'from_entity', '*'), 'subject')
 uicfg.rinlined.tag_relation(True, ('CWRelation', 'to_entity', '*'), 'subject')
-uicfg.rwidgets.tag_relation('StringWidget', ('RQLExpression', 'expression', '*'), 'subject')
+uicfg.rwidgets.tag_attribute(formwidgets.TextInput, 'RQLExpression', 'expression')
 
 uicfg.rmode.tag_relation('create', ('*', 'state_of', 'CWEType'), 'object')
 uicfg.rmode.tag_relation('create', ('*', 'transition_of', 'CWEType'), 'object')