backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 05 Mar 2010 12:18:22 +0100
changeset 4812 2eb6a9b33aa5
parent 4808 23df4a120c96 (current diff)
parent 4811 6c3d5f2a4e01 (diff)
child 4813 5a55c223612e
backport stable
--- a/hooks/metadata.py	Thu Mar 04 18:06:03 2010 +0100
+++ b/hooks/metadata.py	Fri Mar 05 12:18:22 2010 +0100
@@ -14,9 +14,8 @@
 from cubicweb.server import hook
 
 
-def eschema_type_eid(session, etype):
+def eschema_eid(session, eschema):
     """get eid of the CWEType entity for the given yams type"""
-    eschema = session.repo.schema.eschema(etype)
     # eschema.eid is None if schema has been readen from the filesystem, not
     # from the database (eg during tests)
     if eschema.eid is None:
@@ -75,7 +74,10 @@
 
 
 class SetIsHook(MetaDataHook):
-    """create a new entity -> set is relation"""
+    """create a new entity -> set is and is_instance_of relations
+
+    those relations are inserted using sql so they are not hookable.
+    """
     __regid__ = 'setis'
     events = ('after_add_entity',)
 
@@ -85,18 +87,14 @@
         session = self._cw
         entity = self.entity
         try:
-            #session.add_relation(entity.eid, 'is',
-            #                     eschema_type_eid(session, entity.__regid__))
             session.system_sql('INSERT INTO is_relation(eid_from,eid_to) VALUES (%s,%s)'
-                           % (entity.eid, eschema_type_eid(session, entity.__regid__)))
+                           % (entity.eid, eschema_eid(session, entity.e_schema)))
         except IndexError:
             # during schema serialization, skip
             return
-        for etype in entity.e_schema.ancestors() + [entity.e_schema]:
-            #session.add_relation(entity.eid, 'is_instance_of',
-            #                     eschema_type_eid(session, etype))
+        for eschema in entity.e_schema.ancestors() + [entity.e_schema]:
             session.system_sql('INSERT INTO is_instance_of_relation(eid_from,eid_to) VALUES (%s,%s)'
-                               % (entity.eid, eschema_type_eid(session, etype)))
+                               % (entity.eid, eschema_eid(session, eschema)))
 
 
 class SetOwnershipHook(MetaDataHook):
--- a/server/sources/native.py	Thu Mar 04 18:06:03 2010 +0100
+++ b/server/sources/native.py	Fri Mar 05 12:18:22 2010 +0100
@@ -208,7 +208,8 @@
         # check full text index availibility
         if self.do_fti:
             if not self.indexer.has_fti_table(pool['system']):
-                self.critical('no text index table')
+                if not repo.config.creating:
+                    self.critical('no text index table')
                 self.do_fti = False
         pool.pool_reset()
         self.repo._free_pool(pool)
--- a/web/views/ibreadcrumbs.py	Thu Mar 04 18:06:03 2010 +0100
+++ b/web/views/ibreadcrumbs.py	Fri Mar 05 12:18:22 2010 +0100
@@ -104,7 +104,7 @@
 class BreadCrumbView(EntityView):
     __regid__ = 'breadcrumbs'
 
-    def cell_call(self, row, col):
+    def cell_call(self, row, col, **kwargs):
         entity = self.cw_rset.get_entity(row, col)
         desc = xml_escape(uilib.cut(entity.dc_description(), 50))
         # XXX remember camember : tags.a autoescapes !
@@ -115,7 +115,7 @@
 class BreadCrumbTextView(EntityView):
     __regid__ = 'breadcrumbtext'
 
-    def cell_call(self, row, col):
+    def cell_call(self, row, col, **kwargs):
         entity = self.cw_rset.get_entity(row, col)
         textsize = self._cw.property_value('navigation.short-line-size')
         self.w(uilib.cut(entity.dc_title(), textsize))