--- a/web/test/unittest_views_pyviews.py Thu Sep 24 20:46:53 2009 +0200
+++ b/web/test/unittest_views_pyviews.py Thu Sep 24 21:20:15 2009 +0200
@@ -4,9 +4,10 @@
class PyViewsTC(CubicWebTC):
def test_pyvaltable(self):
- content = self.vreg['views'].render('pyvaltable', self.request(),
- pyvalue=[[1, 'a'], [2, 'b']],
- headers=['num', 'char'])
+ view = self.vreg['views'].select('pyvaltable', self.request(),
+ pyvalue=[[1, 'a'], [2, 'b']])
+ content = view.render(pyvalue=[[1, 'a'], [2, 'b']],
+ headers=['num', 'char'])
self.assertEquals(content.strip(), '''<table class="listing">
<tr><th>num</th><th>char</th></tr>
<tr><td>1</td><td>a</td></tr>
@@ -14,8 +15,9 @@
</table>''')
def test_pyvallist(self):
- content = self.vreg['views'].render('pyvallist', self.request(),
- pyvalue=[1, 'a'])
+ view = self.vreg['views'].select('pyvallist', self.request(),
+ pyvalue=[1, 'a'])
+ content = view.render(pyvalue=[1, 'a'])
self.assertEquals(content.strip(), '''<ul>
<li>1</li>
<li>a</li>
--- a/web/test/unittest_viewselector.py Thu Sep 24 20:46:53 2009 +0200
+++ b/web/test/unittest_viewselector.py Thu Sep 24 21:20:15 2009 +0200
@@ -19,13 +19,13 @@
from cubes.folder import views as folderviews
-USERACTIONS = [('myprefs', actions.UserPreferencesAction),
- ('myinfos', actions.UserInfoAction),
- ('logout', actions.LogoutAction)]
-SITEACTIONS = [('siteconfig', actions.SiteConfigurationAction),
- ('manage', actions.ManageAction),
- ('schema', schema.ViewSchemaAction),
- ('siteinfo', actions.SiteInfoAction),
+USERACTIONS = [actions.UserPreferencesAction,
+ actions.UserInfoAction,
+ actions.LogoutAction]
+SITEACTIONS = [actions.SiteConfigurationAction,
+ actions.ManageAction,
+ schema.ViewSchemaAction,
+ actions.SiteInfoAction,
]
class ViewSelectorTC(CubicWebTC):
@@ -36,13 +36,6 @@
self.add_entity('EmailAddress', address=u"devel@logilab.fr", alias=u'devel')
self.add_entity('Tag', name=u'x')
- def pactions(self, req, rset):
- resdict = self.vreg['actions'].possible_actions(req, rset)
- for cat, actions in resdict.items():
- resdict[cat] = [(a.id, a.__class__) for a in actions]
- return resdict
-
-
class VRegistryTC(ViewSelectorTC):
"""test the view selector"""
@@ -76,7 +69,7 @@
('manage', startup.ManageView),
('owl', owl.OWLView),
('propertiesform', cwproperties.CWPropertiesForm),
- ('registry', startup.RegistryView),
+ ('registry', debug.RegistryView),
('schema', schema.SchemaView),
('systempropertiesform', cwproperties.SystemCWPropertiesForm),
('tree', folderviews.FolderTreeView),
@@ -229,7 +222,7 @@
def test_possible_actions_none_rset(self):
req = self.request()
- self.assertDictEqual(self.pactions(req, None),
+ self.assertDictEqual(self.pactionsdict(req, None, skipcategories=()),
{'useractions': USERACTIONS,
'siteactions': SITEACTIONS,
@@ -237,7 +230,7 @@
def test_possible_actions_no_entity(self):
req = self.request()
rset = req.execute('Any X WHERE X eid 999999')
- self.assertDictEqual(self.pactions(req, rset),
+ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
{'useractions': USERACTIONS,
'siteactions': SITEACTIONS,
})
@@ -245,41 +238,41 @@
def test_possible_actions_same_type_entities(self):
req = self.request()
rset = req.execute('CWGroup X')
- self.assertDictEqual(self.pactions(req, rset),
+ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
{'useractions': USERACTIONS,
'siteactions': SITEACTIONS,
- 'mainactions': [('muledit', actions.MultipleEditAction)],
- 'moreactions': [('delete', actions.DeleteAction),
- ('addentity', actions.AddNewAction)],
+ 'mainactions': [actions.MultipleEditAction],
+ 'moreactions': [actions.DeleteAction,
+ actions.AddNewAction],
})
def test_possible_actions_different_types_entities(self):
req = self.request()
rset = req.execute('Any X')
- self.assertDictEqual(self.pactions(req, rset),
+ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
{'useractions': USERACTIONS,
'siteactions': SITEACTIONS,
- 'moreactions': [('delete', actions.DeleteAction)],
+ 'moreactions': [actions.DeleteAction],
})
def test_possible_actions_final_entities(self):
req = self.request()
rset = req.execute('Any N, X WHERE X in_group Y, Y name N')
- self.assertDictEqual(self.pactions(req, rset),
+ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
{'useractions': USERACTIONS,
'siteactions': SITEACTIONS})
def test_possible_actions_eetype_cwuser_entity(self):
req = self.request()
rset = req.execute('CWEType X WHERE X name "CWUser"')
- self.assertDictEqual(self.pactions(req, rset),
+ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
{'useractions': USERACTIONS,
'siteactions': SITEACTIONS,
- 'mainactions': [('edit', actions.ModifyAction)],
- 'moreactions': [('managepermission', actions.ManagePermissionsAction),
- ('addrelated', actions.AddRelatedActions),
- ('delete', actions.DeleteAction),
- ('copy', actions.CopyAction),
+ 'mainactions': [actions.ModifyAction],
+ 'moreactions': [actions.ManagePermissionsAction,
+ actions.AddRelatedActions,
+ actions.DeleteAction,
+ actions.CopyAction,
],
})
@@ -472,27 +465,27 @@
def test(self):
req = self.request()
rset = req.execute('CWEType X WHERE X name "CWEType"')
- self.assertDictEqual(self.pactions(req, rset),
+ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
{'useractions': USERACTIONS,
'siteactions': SITEACTIONS,
- 'mainactions': [('edit', actions.ModifyAction)],
- 'moreactions': [('managepermission', actions.ManagePermissionsAction),
- ('addrelated', actions.AddRelatedActions),
- ('delete', actions.DeleteAction),
- ('copy', actions.CopyAction),
- ('testaction', CWETypeRQLAction),
+ 'mainactions': [actions.ModifyAction],
+ 'moreactions': [actions.ManagePermissionsAction,
+ actions.AddRelatedActions,
+ actions.DeleteAction,
+ actions.CopyAction,
+ CWETypeRQLAction,
],
})
req = self.request()
rset = req.execute('CWEType X WHERE X name "CWRType"')
- self.assertDictEqual(self.pactions(req, rset),
+ self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
{'useractions': USERACTIONS,
'siteactions': SITEACTIONS,
- 'mainactions': [('edit', actions.ModifyAction)],
- 'moreactions': [('managepermission', actions.ManagePermissionsAction),
- ('addrelated', actions.AddRelatedActions),
- ('delete', actions.DeleteAction),
- ('copy', actions.CopyAction),
+ 'mainactions': [actions.ModifyAction],
+ 'moreactions': [actions.ManagePermissionsAction,
+ actions.AddRelatedActions,
+ actions.DeleteAction,
+ actions.CopyAction,
],
})
--- a/web/views/autoform.py Thu Sep 24 20:46:53 2009 +0200
+++ b/web/views/autoform.py Thu Sep 24 21:20:15 2009 +0200
@@ -293,7 +293,7 @@
status = u''
label = 'x'
dellink = toggleable_rel_link_func(entity.eid, nodeid, label)
- eview = self.view('oneline', relatedrset, row=row)
+ eview = self._cw.view('oneline', relatedrset, row=row)
related.append((nodeid, dellink, status, eview))
yield (rschema, role, related)
@@ -315,7 +315,7 @@
jscall = "javascript: cancelPendingInsert('%s', '%s', null, %s);" \
% (pendingid, cell, eid)
rset = self._cw.eid_rset(reid)
- eview = self.view('text', rset, row=0)
+ eview = self._cw.view('text', rset, row=0)
# XXX find a clean way to handle baskets
if rset.description[0][0] == 'Basket':
eview = '%s (%s)' % (eview, display_name(self._cw, 'Basket'))
@@ -343,9 +343,9 @@
# display inline-edition view for all existing related entities
for i, relentity in enumerate(related.entities()):
if relentity.has_perm('update'):
- w(self.view('inline-edition', related, row=i, col=0,
- rtype=rschema, role=role, ptype=entity.e_schema,
- peid=entity.eid, i18nctx=i18nctx))
+ w(self._cw.view('inline-edition', related, row=i, col=0,
+ rtype=rschema, role=role, ptype=entity.e_schema,
+ peid=entity.eid, i18nctx=i18nctx))
existant = True
return existant
@@ -363,9 +363,9 @@
Return True if some inlined form are actually displayed
"""
entity = self.edited_entity
- w(self.view('inline-creation', None, etype=targettype,
- peid=entity.eid, ptype=entity.e_schema,
- rtype=rschema, role=role, i18nctx=i18nctx))
+ w(self._cw.view('inline-creation', None, etype=targettype,
+ peid=entity.eid, ptype=entity.e_schema,
+ rtype=rschema, role=role, i18nctx=i18nctx))
def should_display_add_new_relation_link(self, rschema, existant, card):
"""return true if we should add a link to add a new creation form