[ldapfeed] all options of a source should be in the same group, else you get AssertionError on c-c add-source. Closes #2538398
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 18 Dec 2012 12:42:56 +0100
changeset 8708 78a99960286a
parent 8707 28cbd267e96b
child 8711 64a400eea6dd
[ldapfeed] all options of a source should be in the same group, else you get AssertionError on c-c add-source. Closes #2538398
server/serverconfig.py
server/sources/ldapfeed.py
--- a/server/serverconfig.py	Wed Feb 20 16:13:21 2013 +0100
+++ b/server/serverconfig.py	Tue Dec 18 12:42:56 2012 +0100
@@ -82,7 +82,9 @@
     """serialize a repository source configuration as text"""
     stream = StringIO()
     optsbysect = list(sconfig.options_by_section())
-    assert len(optsbysect) == 1, 'all options for a source should be in the same group'
+    assert len(optsbysect) == 1, (
+        'all options for a source should be in the same group, got %s'
+        % [x[0] for x in optsbysect])
     lgconfig.ini_format(stream, optsbysect[0][1], encoding)
     return stream.getvalue()
 
--- a/server/sources/ldapfeed.py	Wed Feb 20 16:13:21 2013 +0100
+++ b/server/sources/ldapfeed.py	Tue Dec 18 12:42:56 2012 +0100
@@ -17,6 +17,7 @@
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 """cubicweb ldap feed source"""
 
+from cubicweb.cwconfig import merge_options
 from cubicweb.server.sources import datafeed
 from cubicweb.server import ldaputils
 
@@ -30,5 +31,7 @@
     support_entities = {'CWUser': False}
     use_cwuri_as_url = False
 
-    options = datafeed.DataFeedSource.options + ldaputils.LDAPSourceMixIn.options
+    options = merge_options(datafeed.DataFeedSource.options
+                            + ldaputils.LDAPSourceMixIn.options,
+                            optgroup='ldap-source')