# HG changeset patch # User Sylvain Thénault <sylvain.thenault@logilab.fr> # Date 1265717610 -3600 # Tue Feb 09 13:13:30 2010 +0100 # Node ID bd4d1dc13ff08c7c8939261beb9df24e3cbe9210 # Parent 5edfac9f2469a73d90e892fc4922411a5b963cf0 3.6 api update diff --git a/entities.py b/entities.py --- a/entities.py +++ b/entities.py @@ -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 diff --git a/views/__init__.py b/views/__init__.py --- a/views/__init__.py +++ b/views/__init__.py @@ -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 diff --git a/views/accounting.py b/views/accounting.py --- a/views/accounting.py +++ b/views/accounting.py @@ -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' % ( diff --git a/views/actions.py b/views/actions.py --- a/views/actions.py +++ b/views/actions.py @@ -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')