3.6 api update, cleanup
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 26 Jan 2010 20:30:35 +0100
changeset 4382 6fb02edd05da
parent 4381 62a89969c8b3
child 4383 e62a9efdd90a
3.6 api update, cleanup
web/box.py
web/data/cubicweb.edition.js
web/formfields.py
web/formwidgets.py
web/views/editviews.py
web/views/idownloadable.py
web/views/navigation.py
web/views/primary.py
--- a/web/box.py	Tue Jan 26 20:29:52 2010 +0100
+++ b/web/box.py	Tue Jan 26 20:30:35 2010 +0100
@@ -185,7 +185,7 @@
         """
         role, target = get_role(self), get_target(self)
         args = {role[0] : entity.eid, target[0] : etarget.eid}
-        url = self.user_rql_callback((rql, args))
+        url = self._cw.user_rql_callback((rql, args))
         # for each target, provide a link to edit the relation
         label = u'[<a href="%s">%s</a>] %s' % (xml_escape(url), label,
                                                etarget.view('incontext'))
@@ -219,8 +219,8 @@
             return entity.unrelated(self.rtype, self.etype, get_role(self)).entities()
         # in other cases, use vocabulary functions
         entities = []
-        form = self.vreg['forms'].select('edition', self._cw, rset=self.cw_rset,
-                                         row=self.cw_row or 0)
+        form = self._cw.vreg['forms'].select('edition', self._cw, rset=self.cw_rset,
+                                             row=self.cw_row or 0)
         field = form.field_by_name(self.rtype, get_role(self), entity.e_schema)
         for _, eid in field.choices(form):
             if eid is not None and eid != INTERNAL_FIELD_VALUE:
--- a/web/data/cubicweb.edition.js	Tue Jan 26 20:29:52 2010 +0100
+++ b/web/data/cubicweb.edition.js	Tue Jan 26 20:30:35 2010 +0100
@@ -1,6 +1,6 @@
 /*
  *  :organization: Logilab
- *  :copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+ *  :copyright: 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
  *  :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
  */
 
--- a/web/formfields.py	Tue Jan 26 20:29:52 2010 +0100
+++ b/web/formfields.py	Tue Jan 26 20:30:35 2010 +0100
@@ -668,7 +668,9 @@
     etype = 'Date'
 
     def format_single_value(self, req, value):
-        return value and ustrftime(value, req.property_value(self.format_prop)) or u''
+        if value:
+            return utils.ustrftime(value, req.property_value(self.format_prop))
+        return u''
 
     def render_example(self, req):
         return self.format_single_value(req, datetime.now())
--- a/web/formwidgets.py	Tue Jan 26 20:29:52 2010 +0100
+++ b/web/formwidgets.py	Tue Jan 26 20:30:35 2010 +0100
@@ -1,7 +1,7 @@
 """widget classes for form construction
 
 :organization: Logilab
-:copyright: 2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
+:copyright: 2009-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
 """
--- a/web/views/editviews.py	Tue Jan 26 20:29:52 2010 +0100
+++ b/web/views/editviews.py	Tue Jan 26 20:30:35 2010 +0100
@@ -66,8 +66,8 @@
         # since the latter is mainly there to select relevant items in the combo
         # box, it doesn't give interesting result in this context
         rql, args = entity.unrelated_rql(rtype, etype, role,
-                                   ordermethod='fetch_order',
-                                   vocabconstraints=False)
+                                         ordermethod='fetch_order',
+                                         vocabconstraints=False)
         rset = self._cw.execute(rql, args, tuple(args))
         return rset, 'list', "search-associate-content", True
 
@@ -138,7 +138,6 @@
         execute(rql, {'x': subj, 'y': obj}, ('x', 'y'))
 
 
-
 class GenericRelationsWidget(fw.FieldWidget):
 
     def render(self, form, field, renderer):
@@ -347,6 +346,7 @@
                 xml_escape(url), _('Search for'), eschema.display_name(self._cw))))
         return [o for l, o in sorted(options)]
 
+    # XXX move this out
     def _get_basket_options(self, entity, rschema, role, targettypes):
         options = []
         rtype = rschema.type
--- a/web/views/idownloadable.py	Tue Jan 26 20:29:52 2010 +0100
+++ b/web/views/idownloadable.py	Tue Jan 26 20:30:35 2010 +0100
@@ -68,7 +68,7 @@
 
     def set_request_content_type(self):
         """overriden to set the correct filetype and filename"""
-        entity = self.complete_entity(0)
+        entity = self.cw_rset.complete_entity(0, 0)
         encoding = entity.download_encoding()
         if encoding in BINARY_ENCODINGS:
             contenttype = 'application/%s' % encoding
@@ -80,7 +80,7 @@
                                   encoding=encoding)
 
     def call(self):
-        self.w(self.complete_entity(0).download_data())
+        self.w(self.cw_rset.complete_entity(0, 0).download_data())
 
 
 class DownloadLinkView(EntityView):
--- a/web/views/navigation.py	Tue Jan 26 20:29:52 2010 +0100
+++ b/web/views/navigation.py	Tue Jan 26 20:30:35 2010 +0100
@@ -214,7 +214,7 @@
         nav.clean_params(params)
         # make a link to see them all
         if show_all_option:
-            url = xml_escape(view.build_url(__force_display=1, **params))
+            url = xml_escape(req.build_url(__force_display=1, **params))
             w(u'<span><a href="%s">%s</a></span>\n'
               % (url, req._('show %s results') % len(rset)))
         rset.limit(offset=start, limit=stop-start, inplace=True)
--- a/web/views/primary.py	Tue Jan 26 20:29:52 2010 +0100
+++ b/web/views/primary.py	Tue Jan 26 20:30:35 2010 +0100
@@ -127,7 +127,7 @@
             else:
                 rset = self._relation_rset(entity, rschema, role, dispctrl)
                 if rset:
-                    value = self.view(vid, rset)
+                    value = self._cw.view(vid, rset)
                 else:
                     value = None
             if self.skip_none and (value is None or value == ''):