--- a/common/test/data/bootstrap_cubes Wed Feb 18 01:21:25 2009 +0100
+++ b/common/test/data/bootstrap_cubes Wed Feb 18 01:25:51 2009 +0100
@@ -1,1 +1,1 @@
-file, tag
+
--- a/common/test/data/schema/relations.rel Wed Feb 18 01:21:25 2009 +0100
+++ b/common/test/data/schema/relations.rel Wed Feb 18 01:25:51 2009 +0100
@@ -9,8 +9,5 @@
Note ecrit_par Personne inline CONSTRAINT E concerns P, X version_of P
Personne connait Personne symetric
-Tag tags Note
-Tag tags Personne
-
Affaire liee_a Societe
Affaire liee_a Personne
--- a/schema.py Wed Feb 18 01:21:25 2009 +0100
+++ b/schema.py Wed Feb 18 01:25:51 2009 +0100
@@ -976,7 +976,7 @@
def vocabulary(self, entity=None):
if entity and entity.req.user.has_permission(PERM_USE_TEMPLATE_FORMAT):
- return self.regular_formats + self.need_perm_formats
+ return self.regular_formats + tuple(self.need_perm_formats)
return self.regular_formats
def __str__(self):
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/bootstrap_cubes Wed Feb 18 01:25:51 2009 +0100
@@ -0,0 +1,1 @@
+file, tag
--- a/test/data/bootstrap_packages Wed Feb 18 01:21:25 2009 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/entities.py Wed Feb 18 01:25:51 2009 +0100
@@ -0,0 +1,15 @@
+from cubicweb.entities import AnyEntity, fetch_config
+
+class Personne(AnyEntity):
+ """customized class forne Person entities"""
+ id = 'Personne'
+ fetch_attrs, fetch_order = fetch_config(['nom', 'prenom'])
+ rest_attr = 'nom'
+
+
+class Societe(AnyEntity):
+ id = 'Societe'
+ fetch_attrs = ('nom',)
+
+class Note(AnyEntity):
+ id = 'Note'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/schema.py Wed Feb 18 01:25:51 2009 +0100
@@ -0,0 +1,27 @@
+class Personne(EntityType):
+ nom = String()
+ prenom = String()
+ type = String()
+ travaille = SubjectRelation('Societe')
+ evaluee = SubjectRelation(('Note', 'Personne'))
+ connait = SubjectRelation('Personne', symetric=True)
+
+class Societe(EntityType):
+ nom = String()
+ evaluee = SubjectRelation('Note')
+
+class Note(EntityType):
+ type = String()
+ ecrit_par = SubjectRelation('Personne')
+
+class SubNote(Note):
+ __specializes_schema__ = True
+ descr = String()
+
+class tags(RelationDefinition):
+ subject = 'Tag'
+ object = ('Personne', 'Note')
+
+class evaluee(RelationDefinition):
+ subject = 'EUser'
+ object = 'Note'
--- a/test/unittest_entity.py Wed Feb 18 01:21:25 2009 +0100
+++ b/test/unittest_entity.py Wed Feb 18 01:25:51 2009 +0100
@@ -16,7 +16,7 @@
## embed=False)
def test_boolean_value(self):
- e = self.etype_instance('Tag')
+ e = self.etype_instance('EUser')
self.failUnless(e)
def test_yams_inheritance(self):
@@ -27,7 +27,7 @@
self.assertIs(e.__class__, e2.__class__)
def test_has_eid(self):
- e = self.etype_instance('Tag')
+ e = self.etype_instance('EUser')
self.assertEquals(e.eid, None)
self.assertEquals(e.has_eid(), False)
e.eid = 'X'
@@ -167,16 +167,17 @@
def test_related_rql(self):
from cubicweb.entities import fetch_config
Personne = self.vreg.etype_class('Personne')
- Societe = self.vreg.etype_class('Societe')
- Personne.fetch_attrs, Personne.fetch_order = fetch_config(('nom', 'prenom', 'sexe'))
- Societe.fetch_attrs, Societe.fetch_order = fetch_config(('nom', 'web'))
- aff = self.add_entity('Affaire', sujet=u'my subject', ref=u'the ref')
- self.assertEquals(aff.related_rql('liee_a'),
- 'Any X,AA,AB ORDERBY AA ASC WHERE E eid %(x)s, E liee_a X, '
- 'X nom AA, X modification_date AB')
- Societe.fetch_attrs = ('web',)
- self.assertEquals(aff.related_rql('liee_a'),
- 'Any X ORDERBY Z DESC WHERE X modification_date Z, E eid %(x)s, E liee_a X')
+ Note = self.vreg.etype_class('Note')
+ Personne.fetch_attrs, Personne.fetch_order = fetch_config(('nom', 'type'))
+ Note.fetch_attrs, Note.fetch_order = fetch_config(('type',))
+ aff = self.add_entity('Personne', nom=u'pouet')
+ self.assertEquals(aff.related_rql('evaluee'),
+ 'Any X,AA,AB ORDERBY AA ASC WHERE E eid %(x)s, E evaluee X, '
+ 'X type AA, X modification_date AB')
+ Personne.fetch_attrs, Personne.fetch_order = fetch_config(('nom', ))
+ # XXX
+ self.assertEquals(aff.related_rql('evaluee'),
+ 'Any X,AA ORDERBY Z DESC WHERE X modification_date Z, E eid %(x)s, E evaluee X, X modification_date AA')
def test_entity_unrelated(self):
p = self.add_entity('Personne', nom=u'di mascio', prenom=u'adrien')
@@ -265,6 +266,7 @@
('owned_by', 'object'),
('bookmarked_by', 'object')])
e = self.etype_instance('Personne')
+ print rbc(e.relations_by_category('primary'))
self.assertListEquals(rbc(e.relations_by_category('primary')),
[('nom', 'subject'), ('eid', 'subject')])
self.assertListEquals(rbc(e.relations_by_category('secondary')),
@@ -386,12 +388,10 @@
def test_entity_formatted_attrs(self):
- e = self.etype_instance('Note')
+ e = self.etype_instance('EUser')
self.assertEquals(e.formatted_attrs(), [])
e = self.etype_instance('File')
self.assertEquals(e.formatted_attrs(), ['description'])
- e = self.etype_instance('AnotherNote')
- self.assertEquals(e.formatted_attrs(), ['descr', 'descr2'])
def test_fulltextindex(self):
--- a/test/unittest_vregistry.py Wed Feb 18 01:21:25 2009 +0100
+++ b/test/unittest_vregistry.py Wed Feb 18 01:25:51 2009 +0100
@@ -33,11 +33,13 @@
# check loading baseviews after idownloadable isn't kicking interface based views
self.assertEquals(len(self.vreg['views']['primary']), 2)
- def test_autoselectors(self):
+ def test___selectors__compat(self):
myselector1 = lambda *args: 1
myselector2 = lambda *args: 1
class AnAppObject(VObject):
- __select__ = myselector1() & myselector2()
+ __selectors__ = (myselector1, myselector2)
+ AnAppObject.build___select__()
+ self.assertEquals(AnAppObject.__select__(AnAppObject), 2)
self.assertEquals(AnAppObject.__select__(), 2)
def test_properties(self):
--- a/vregistry.py Wed Feb 18 01:21:25 2009 +0100
+++ b/vregistry.py Wed Feb 18 01:25:51 2009 +0100
@@ -112,7 +112,7 @@
may be the right hook to create an instance for example). By
default the vobject is returned without any transformation.
"""
- cls.__select__ = cls.build___select__()
+ cls.build___select__()
return cls
@classmethod
@@ -146,10 +146,11 @@
if len(selectors) == 1:
# micro optimization: don't bother with AndSelector if there's
# only one selector
- return _instantiate_selector(selectors[0])
- return AndSelector(_instantiate_selector(selector)
- for selector in selectors)
- return cls.__select__
+ select = _instantiate_selector(selectors[0])
+ else:
+ select = AndSelector(*[_instantiate_selector(selector)
+ for selector in selectors])
+ cls.__select__ = select
class VRegistry(object):
--- a/web/component.py Wed Feb 18 01:21:25 2009 +0100
+++ b/web/component.py Wed Feb 18 01:25:51 2009 +0100
@@ -7,14 +7,14 @@
__docformat__ = "restructuredtext en"
from logilab.common.deprecation import class_renamed
+from logilab.mtconverter import html_escape
+from cubicweb.utils import merge_dicts
+from cubicweb.view import View, Component
from cubicweb.selectors import (
paginated_rset, one_line_rset, primary_view, match_context_prop,
condition_compat, accepts_compat, has_relation_compat)
-from cubicweb.common.utils import merge_dicts
-from cubicweb.common.view import View, Component
from cubicweb.common.registerers import accepts_registerer
-from cubicweb.common.uilib import html_escape
_ = unicode