3.6 api update
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 09 Feb 2010 13:13:30 +0100
changeset 27 bd4d1dc13ff0
parent 26 5edfac9f2469
child 28 1ee82b460998
3.6 api update
entities.py
views/__init__.py
views/accounting.py
views/actions.py
--- a/entities.py	Tue Feb 09 13:12:39 2010 +0100
+++ b/entities.py	Tue Feb 09 13:13:30 2010 +0100
@@ -7,7 +7,7 @@
     @property
     def workcase(self):
         rql = 'Any R WHERE E has_lines EL, EL eid %(el)s, E spent_for W, W ref R'
-        rset = self.req.execute(rql, {'el': self.eid})
+        rset = self._cw.execute(rql, {'el': self.eid}, 'el')
         if rset:
             return rset[0][0]
         return None
--- a/views/__init__.py	Tue Feb 09 13:12:39 2010 +0100
+++ b/views/__init__.py	Tue Feb 09 13:13:30 2010 +0100
@@ -1,18 +1,18 @@
 """template-specific forms/views/actions/components"""
 from logilab.common.decorators import monkeypatch
 
-from cubicweb.web import uicfg
-from cubicweb.web.formwidgets import RestrictedAutoCompletionWidget
+from cubicweb.web import uicfg, formwidgets as fw
 from cubicweb.web.views import basecontrollers
 
 _afs = uicfg.autoform_section
-_afs.tag_subject_of(('Expense', 'spent_for', '*'), 'primary')
 _affk = uicfg.autoform_field_kwargs
+_afs.tag_subject_of(('Expense', 'spent_for', '*'), 'main', 'attributes')
+_afs.tag_subject_of(('Expense', 'spent_for', '*'), 'muledit', 'attributes')
 _affk.tag_subject_of(('Expense', 'spent_for', '*'),
-                     {'widget': RestrictedAutoCompletionWidget(autocomplete_initfunc='get_concerned_by')})
+                     {'widget': fw.RestrictedAutoCompletionWidget(autocomplete_initfunc='get_concerned_by')})
 
 
 @monkeypatch(basecontrollers.JSonController)
 @basecontrollers.jsonize
 def js_get_concerned_by(self):
-    return self.req.execute('DISTINCT Any W,R ORDERBY R WHERE W ref R').rows
+    return self._cw.execute('DISTINCT Any W,R ORDERBY R WHERE W ref R').rows
--- a/views/accounting.py	Tue Feb 09 13:12:39 2010 +0100
+++ b/views/accounting.py	Tue Feb 09 13:13:30 2010 +0100
@@ -7,14 +7,14 @@
 __docformat__ = "restructuredtext en"
 
 
-from logilab.mtconverter import html_escape
+from logilab.mtconverter import xml_escape
 
 from cubicweb.selectors import implements
 from cubicweb.view import EntityView
 
 
 class ExpenseAccountingXmlView(EntityView):
-    id = 'accexpense'
+    __regid__ = 'accexpense'
     __select__ = implements('Expense')
 
     title = _('accounting entry view')
@@ -22,12 +22,12 @@
     content_type = 'text/xml'
 
     def cell_call(self, row, col):
-        entity = self.entity(row, col)
+        entity = self.cw_rset.get_entity(row, col)
         self.wview('accentry', entity.related('has_lines'))
 
 
 class ExpenseLineAccountingEntryXmlView(EntityView):
-    id = 'accentry'
+    __regid__ = 'accentry'
     __select__ = implements('ExpenseLine',)
 
     title = _('accounting entry view')
@@ -37,16 +37,16 @@
     def call(self):
         """display a list of entities by calling their <item_vid> view
         """
-        self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding)
+        self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self._cw.encoding)
         self.w(u'<ecritures>\n')
-        for i in xrange(self.rset.rowcount):
+        for i in xrange(self.cw_rset.rowcount):
             self.cell_call(i, 0)
         self.w(u'</ecritures>\n')
 
     def cell_call(self, row, col):
-        entity = self.complete_entity(row, col)
+        entity = self.cw_rset.complete_entity(row, col)
         self.w(u'  <ecriture date="%s">\n' % entity.diem.strftime('%Y-%m-%d'))
-        self.w(u'    <libelle>%s</libelle>\n' % html_escape(entity.dc_long_title()))
+        self.w(u'    <libelle>%s</libelle>\n' % xml_escape(entity.dc_long_title()))
         amount = round(entity.euro_amount(), 2)
         taxes = round(entity.taxes, 2)
         self.w(u'    <credit compte="%s" montant="%.2f" />\n' % (
--- a/views/actions.py	Tue Feb 09 13:12:39 2010 +0100
+++ b/views/actions.py	Tue Feb 09 13:13:30 2010 +0100
@@ -10,11 +10,11 @@
 from cubicweb.web.action import Action
 
 class AccountingAction(Action):
-    id = 'accaction'
+    __regid__ = 'accaction'
     __select__ = implements('Expense')
     title = _('generate accounting entries')
 
     def url(self):
-        entity = self.entity(0, 0)
+        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
         return entity.absolute_url(vid='accexpense')