merge default heads
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 16 Feb 2011 10:29:47 +0100
changeset 6998 d662dfdfe495
parent 6995 6efb5a5696bd (diff)
parent 6992 38f2e306ad8b (current diff)
child 6999 e73e05ea8705
merge default heads
--- a/__pkginfo__.py	Mon Feb 14 23:18:20 2011 +0100
+++ b/__pkginfo__.py	Wed Feb 16 10:29:47 2011 +0100
@@ -40,7 +40,7 @@
 ]
 
 __depends__ = {
-    'logilab-common': '>= 0.54.0',
+    'logilab-common': '>= 0.55.0',
     'logilab-mtconverter': '>= 0.8.0',
     'rql': '>= 0.28.0',
     'yams': '>= 0.30.4',
--- a/dataimport.py	Mon Feb 14 23:18:20 2011 +0100
+++ b/dataimport.py	Wed Feb 16 10:29:47 2011 +0100
@@ -306,11 +306,18 @@
         self.items.append(item)
         return len(self.items) - 1
 
-    def add(self, type, item):
+    def create_entity(self, etype, **data):
+        data['eid'] =  eid = self._put(etype, data)
+        self.eids[eid] = data
+        self.types.setdefault(etype, []).append(eid)
+        return data
+
+    @deprecated("[3.11] add is deprecated, use create_entity instead")
+    def add(self, etype, item):
         assert isinstance(item, dict), 'item is not a dict but a %s' % type(item)
-        eid = item['eid'] = self._put(type, item)
-        self.eids[eid] = item
-        self.types.setdefault(type, []).append(eid)
+        data = self.create_entity(etype, **item)
+        item['eid'] = data['eid']
+        return item
 
     def relate(self, eid_from, rtype, eid_to, inlined=False):
         """Add new relation"""
@@ -453,8 +460,10 @@
         return entity
 
     def _put(self, type, item):
-        query = ('INSERT %s X: ' % type) + ', '.join('X %s %%(%s)s' % (k, k)
-                                                     for k in item)
+        query = 'INSERT %s X' % type
+        if item:
+            query += ': ' + ', '.join('X %s %%(%s)s' % (k, k)
+                                      for k in item)
         return self.rql(query, item)[0][0]
 
     def relate(self, eid_from, rtype, eid_to, inlined=False):
@@ -686,7 +695,7 @@
         del entity.cw_extra_kwargs
         entity.cw_edited = EditedEntity(entity)
         for attr in self.etype_attrs:
-            entity.cw_edited.attribute_edited(attr, self.generate(entity, attr))
+            entity.cw_edited.edited_attribute(attr, self.generate(entity, attr))
         rels = {}
         for rel in self.etype_rels:
             rels[rel] = self.generate(entity, rel)
@@ -695,7 +704,7 @@
     def init_entity(self, entity):
         entity.eid = self.source.create_eid(self.session)
         for attr in self.entity_attrs:
-            entity.cw_edited.attribute_edited(attr, self.generate(entity, attr))
+            entity.cw_edited.edited_attribute(attr, self.generate(entity, attr))
 
     def generate(self, entity, rtype):
         return getattr(self, 'gen_%s' % rtype)(entity)
--- a/debian/control	Mon Feb 14 23:18:20 2011 +0100
+++ b/debian/control	Wed Feb 16 10:29:47 2011 +0100
@@ -97,7 +97,7 @@
 Package: cubicweb-common
 Architecture: all
 XB-Python-Version: ${python:Versions}
-Depends: ${misc:Depends}, ${python:Depends}, graphviz, gettext, python-logilab-mtconverter (>= 0.8.0), python-logilab-common (>= 0.54.0), python-yams (>= 0.30.4), python-rql (>= 0.28.0), python-lxml
+Depends: ${misc:Depends}, ${python:Depends}, graphviz, gettext, python-logilab-mtconverter (>= 0.8.0), python-logilab-common (>= 0.55.0), python-yams (>= 0.30.4), python-rql (>= 0.28.0), python-lxml
 Recommends: python-simpletal (>= 4.0), python-crypto
 Conflicts: cubicweb-core
 Replaces: cubicweb-core
--- a/sobjects/parsers.py	Mon Feb 14 23:18:20 2011 +0100
+++ b/sobjects/parsers.py	Wed Feb 16 10:29:47 2011 +0100
@@ -56,7 +56,13 @@
 DEFAULT_CONVERTERS['Interval'] = convert_interval
 
 # use a cookie enabled opener to use session cookie if any
-_OPENER = urllib2.build_opener(urllib2.HTTPCookieProcessor(CookieJar()))
+_OPENER = urllib2.build_opener()
+try:
+    from logilab.common import urllib2ext
+    _OPENER.add_handler(urllib2ext.HTTPGssapiAuthHandler())
+except ImportError: # python-kerberos not available
+    pass
+_OPENER.add_handler(urllib2.HTTPCookieProcessor(CookieJar()))
 
 def extract_typed_attrs(eschema, stringdict, converters=DEFAULT_CONVERTERS):
     typeddict = {}
--- a/web/component.py	Mon Feb 14 23:18:20 2011 +0100
+++ b/web/component.py	Wed Feb 16 10:29:47 2011 +0100
@@ -577,6 +577,7 @@
         if mayadd or maydel:
             req.add_js(('jquery.ui.js', 'cubicweb.widgets.js'))
             req.add_js(('cubicweb.ajax.js', 'cubicweb.ajax.box.js'))
+            req.add_css('jquery.ui.css')
         _ = req._
         if related:
             w(u'<table class="ajaxEditRelationTable">')
@@ -597,8 +598,6 @@
         else:
             w(_('no related entity'))
         if mayadd:
-            req.add_js(('jquery.ui.js', 'cubicweb.widgets.js'))
-            req.add_css('jquery.ui.css')
             multiple = self.rdef.role_cardinality(self.role) in '*+'
             w(u'<table><tr><td>')
             jscall = unicode(js.ajaxBoxShowSelector(
--- a/web/data/cubicweb.ajax.box.js	Mon Feb 14 23:18:20 2011 +0100
+++ b/web/data/cubicweb.ajax.box.js	Wed Feb 16 10:29:47 2011 +0100
@@ -37,6 +37,26 @@
     });
 }
 
+/**
+ * .. function:: ajaxBoxShowSelector(boxid, eid, unrelfname,
+ *                                  addfname, msg,
+ *                                  oklabel, cancellabel,
+ *                                  separator=None)
+ *
+ * Display an ajax selector within a box of regid `boxid`, for entity with eid
+ * `eid`.
+ *
+ * Other parameters are:
+ *
+ * * `addfname`, name of the json controller method to call to add a relation
+ *
+ * * `msg`, message to display to the user when a relation has been added
+ *
+ * * `oklabel`/`cancellabel`, OK/cancel buttons label
+ *
+ * * `separator`, items separator if the field is multi-valued (will be
+ *   considered mono-valued when not specified)
+ */
 function ajaxBoxShowSelector(boxid, eid,
                              unrelfname,
                              addfname, msg,
@@ -59,11 +79,11 @@
                     ajaxBoxValidateSelectorInput(boxid, eid, separator, addfname, msg);
                 }
             });
-            $input.cwautocomplete(unrelated, {multiple: true});
+            $input.cwautocomplete(unrelated, {multiple: Boolean(separator)});
             var buttons = DIV({'class' : "sgformbuttons"},
                               A({href : "javascript: noop();",
                                  onclick : cw.utils.strFuncCall('ajaxBoxValidateSelectorInput',
-                                                                  boxid, eid, separator, addfname, msg)},
+                                                                boxid, eid, separator, addfname, msg)},
                                 oklabel),
                               ' / ',
                               A({'href' : "javascript: noop();",