[devtools] Handle i18ncube command for "cubes as packages"
And add a test so that both layouts are tested.
Move the test cube into a package.
Related to #13001466.
--- a/.hgignore Tue Jun 07 18:21:13 2016 +0200
+++ b/.hgignore Wed Jun 08 21:59:34 2016 +0200
@@ -16,7 +16,7 @@
.*/data.*/database/.*
.*/data/ldapdb/.*
.*/data/uicache/
-.*/data/cubes/.*/i18n/.*\.po
+.*/data/libpython/cubicweb_.*/i18n/.*\.po
^doc/html/
^doc/doctrees/
^doc/book/en/devweb/js_api/
--- a/cubicweb/devtools/devctl.py Tue Jun 07 18:21:13 2016 +0200
+++ b/cubicweb/devtools/devctl.py Wed Jun 08 21:59:34 2016 +0200
@@ -115,6 +115,8 @@
from cubicweb.cwvreg import CWRegistryStore
if cubedir:
cube = osp.split(cubedir)[-1]
+ if cube.startswith('cubicweb_'):
+ cube = cube[len('cubicweb_'):]
config = DevConfiguration(cube)
depcubes = list(config._cubes)
depcubes.remove(cube)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/devtools/test/data/cubes/i18ntestcube Wed Jun 08 21:59:34 2016 +0200
@@ -0,0 +1,1 @@
+../libpython/cubicweb_i18ntestcube/
\ No newline at end of file
--- a/cubicweb/devtools/test/data/cubes/i18ntestcube/__pkginfo__.py Tue Jun 07 18:21:13 2016 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-# pylint: disable=W0622
-"""cubicweb i18n test cube application packaging information"""
-
-modname = 'i18ntestcube'
-distname = 'cubicweb-i18ntestcube'
-
-numversion = (0, 1, 0)
-version = '.'.join(str(num) for num in numversion)
-
-license = 'LGPL'
-author = 'LOGILAB S.A. (Paris, FRANCE)'
-author_email = 'contact@logilab.fr'
-description = 'forum'
-web = 'http://www.cubicweb.org/project/%s' % distname
-
-__depends__ = {'cubicweb': '>= 3.16.4',
- }
-__recommends__ = {}
--- a/cubicweb/devtools/test/data/cubes/i18ntestcube/i18n/en.po.ref Tue Jun 07 18:21:13 2016 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,182 +0,0 @@
-msgid ""
-msgstr ""
-"Project-Id-Version: cubicweb 3.16.5\n"
-"PO-Revision-Date: 2008-03-28 18:14+0100\n"
-"Last-Translator: Logilab Team <contact@logilab.fr>\n"
-"Language-Team: fr <contact@logilab.fr>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: cubicweb-devtools\n"
-"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-
-# schema pot file, generated on 2013-07-12 16:18:12
-#
-# singular and plural forms for each entity type
-# subject and object forms for each relation type
-# (no object form for final or symmetric relation types)
-msgid "Forum"
-msgstr ""
-
-msgid "Forum_plural"
-msgstr ""
-
-msgid "This Forum"
-msgstr ""
-
-msgid "This Forum:"
-msgstr ""
-
-msgid "New Forum"
-msgstr ""
-
-msgctxt "inlined:Forum.in_forum.object"
-msgid "add a ForumThread"
-msgstr ""
-
-msgctxt "inlined:Forum.in_forum.object"
-msgid "ForumThread"
-msgstr ""
-
-msgid "add ForumThread in_forum Forum object"
-msgstr ""
-
-msgid "add a Forum"
-msgstr ""
-
-msgid "add a ForumThread"
-msgstr ""
-
-msgid "creating ForumThread (ForumThread in_forum Forum %(linkto)s)"
-msgstr ""
-
-msgid "ForumThread"
-msgstr ""
-
-msgid "ForumThread_plural"
-msgstr ""
-
-msgid "This ForumThread"
-msgstr ""
-
-msgid "This ForumThread:"
-msgstr ""
-
-msgid "New ForumThread"
-msgstr ""
-
-msgid "content"
-msgstr ""
-
-msgctxt "ForumThread"
-msgid "content"
-msgstr ""
-
-msgid "content_format"
-msgstr ""
-
-msgctxt "ForumThread"
-msgid "content_format"
-msgstr ""
-
-msgctxt "Forum"
-msgid "description"
-msgstr ""
-
-msgctxt "Forum"
-msgid "description_format"
-msgstr ""
-
-msgid "in_forum"
-msgstr ""
-
-msgctxt "ForumThread"
-msgid "in_forum"
-msgstr ""
-
-msgctxt "Forum"
-msgid "in_forum_object"
-msgstr ""
-
-msgid "in_forum_object"
-msgstr ""
-
-msgid "interested_in"
-msgstr ""
-
-msgctxt "CWUser"
-msgid "interested_in"
-msgstr ""
-
-msgctxt "ForumThread"
-msgid "interested_in_object"
-msgstr ""
-
-msgctxt "Forum"
-msgid "interested_in_object"
-msgstr ""
-
-msgid "interested_in_object"
-msgstr ""
-
-msgid "nosy_list"
-msgstr ""
-
-msgctxt "ForumThread"
-msgid "nosy_list"
-msgstr ""
-
-msgctxt "Forum"
-msgid "nosy_list"
-msgstr ""
-
-msgctxt "CWUser"
-msgid "nosy_list_object"
-msgstr ""
-
-msgid "nosy_list_object"
-msgstr ""
-
-msgctxt "ForumThread"
-msgid "title"
-msgstr ""
-
-msgid "topic"
-msgstr ""
-
-msgctxt "Forum"
-msgid "topic"
-msgstr ""
-
-msgid "Topic"
-msgstr ""
-
-msgid "Description"
-msgstr ""
-
-msgid "Number of threads"
-msgstr ""
-
-msgid "Last activity"
-msgstr ""
-
-msgid ""
-"a long\n"
-"tranlated line\n"
-"hop."
-msgstr ""
-
-msgid "Subject"
-msgstr ""
-
-msgid "Created"
-msgstr ""
-
-msgid "Answers"
-msgstr ""
-
-msgid "Last answered"
-msgstr ""
-
-msgid "This forum does not have any thread yet."
-msgstr ""
--- a/cubicweb/devtools/test/data/cubes/i18ntestcube/schema.py Tue Jun 07 18:21:13 2016 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-# -*- coding: utf-8 -*-
-# copyright 2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
-# contact http://www.logilab.fr -- mailto:contact@logilab.fr
-#
-# This program is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 2.1 of the License, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-
-"""cubicweb-forum schema"""
-
-from yams.buildobjs import (String, RichString, EntityType,
- RelationDefinition, SubjectRelation)
-from yams.reader import context
-
-class Forum(EntityType):
- topic = String(maxsize=50, required=True, unique=True)
- description = RichString()
-
-class ForumThread(EntityType):
- __permissions__ = {
- 'read': ('managers', 'users'),
- 'add': ('managers', 'users'),
- 'update': ('managers', 'owners'),
- 'delete': ('managers', 'owners')
- }
- title = String(required=True, fulltextindexed=True, maxsize=256)
- content = RichString(required=True, fulltextindexed=True)
- in_forum = SubjectRelation('Forum', cardinality='1*', inlined=True,
- composite='object')
-class interested_in(RelationDefinition):
- subject = 'CWUser'
- object = ('ForumThread', 'Forum')
-
-class nosy_list(RelationDefinition):
- subject = ('Forum', 'ForumThread')
- object = 'CWUser'
--- a/cubicweb/devtools/test/data/cubes/i18ntestcube/views.py Tue Jun 07 18:21:13 2016 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-# copyright 2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
-# contact http://www.logilab.fr -- mailto:contact@logilab.fr
-#
-# This program is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 2.1 of the License, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License along
-# with this program. If not, see <http://www.gnu.org/licenses/>.
-
-"""cubicweb-forum views/forms/actions/components for web ui"""
-
-from cubicweb import view
-from cubicweb.predicates import is_instance
-from cubicweb.web.views import primary, baseviews, uicfg
-from cubicweb.web.views.uicfg import autoform_section as afs
-
-class MyAFS(uicfg.AutoformSectionRelationTags):
- __select__ = is_instance('ForumThread')
-
-_myafs = MyAFS()
-
-_myafs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined')
-
-afs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined')
-
-
-class ForumSameETypeListView(baseviews.SameETypeListView):
- __select__ = baseviews.SameETypeListView.__select__ & is_instance('Forum')
-
- def call(self, **kwargs):
- _ = self._cw._
- _('Topic'), _('Description')
- _('Number of threads'), _('Last activity')
- _('''a long
-tranlated line
-hop.''')
-
-
-class ForumLastActivity(view.EntityView):
- __regid__ = 'forum_last_activity'
- __select__ = view.EntityView.__select__ & is_instance('Forum')
-
-
-class ForumPrimaryView(primary.PrimaryView):
- __select__ = primary.PrimaryView.__select__ & is_instance('Forum')
-
- def render_entity_attributes(self, entity):
- _ = self._cw._
- _('Subject'), _('Created'), _('Answers'),
- _('Last answered')
- _('This forum does not have any thread yet.')
-
-class ForumThreadPrimaryView(primary.PrimaryView):
- __select__ = primary.PrimaryView.__select__ & is_instance('ForumThread')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/devtools/test/data/libpython/cubicweb_i18ntestcube/__pkginfo__.py Wed Jun 08 21:59:34 2016 +0200
@@ -0,0 +1,18 @@
+# pylint: disable=W0622
+"""cubicweb i18n test cube application packaging information"""
+
+modname = 'i18ntestcube'
+distname = 'cubicweb-i18ntestcube'
+
+numversion = (0, 1, 0)
+version = '.'.join(str(num) for num in numversion)
+
+license = 'LGPL'
+author = 'LOGILAB S.A. (Paris, FRANCE)'
+author_email = 'contact@logilab.fr'
+description = 'forum'
+web = 'http://www.cubicweb.org/project/%s' % distname
+
+__depends__ = {'cubicweb': '>= 3.16.4',
+ }
+__recommends__ = {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/devtools/test/data/libpython/cubicweb_i18ntestcube/i18n/en.po.ref Wed Jun 08 21:59:34 2016 +0200
@@ -0,0 +1,182 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: cubicweb 3.16.5\n"
+"PO-Revision-Date: 2008-03-28 18:14+0100\n"
+"Last-Translator: Logilab Team <contact@logilab.fr>\n"
+"Language-Team: fr <contact@logilab.fr>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: cubicweb-devtools\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+# schema pot file, generated on 2013-07-12 16:18:12
+#
+# singular and plural forms for each entity type
+# subject and object forms for each relation type
+# (no object form for final or symmetric relation types)
+msgid "Forum"
+msgstr ""
+
+msgid "Forum_plural"
+msgstr ""
+
+msgid "This Forum"
+msgstr ""
+
+msgid "This Forum:"
+msgstr ""
+
+msgid "New Forum"
+msgstr ""
+
+msgctxt "inlined:Forum.in_forum.object"
+msgid "add a ForumThread"
+msgstr ""
+
+msgctxt "inlined:Forum.in_forum.object"
+msgid "ForumThread"
+msgstr ""
+
+msgid "add ForumThread in_forum Forum object"
+msgstr ""
+
+msgid "add a Forum"
+msgstr ""
+
+msgid "add a ForumThread"
+msgstr ""
+
+msgid "creating ForumThread (ForumThread in_forum Forum %(linkto)s)"
+msgstr ""
+
+msgid "ForumThread"
+msgstr ""
+
+msgid "ForumThread_plural"
+msgstr ""
+
+msgid "This ForumThread"
+msgstr ""
+
+msgid "This ForumThread:"
+msgstr ""
+
+msgid "New ForumThread"
+msgstr ""
+
+msgid "content"
+msgstr ""
+
+msgctxt "ForumThread"
+msgid "content"
+msgstr ""
+
+msgid "content_format"
+msgstr ""
+
+msgctxt "ForumThread"
+msgid "content_format"
+msgstr ""
+
+msgctxt "Forum"
+msgid "description"
+msgstr ""
+
+msgctxt "Forum"
+msgid "description_format"
+msgstr ""
+
+msgid "in_forum"
+msgstr ""
+
+msgctxt "ForumThread"
+msgid "in_forum"
+msgstr ""
+
+msgctxt "Forum"
+msgid "in_forum_object"
+msgstr ""
+
+msgid "in_forum_object"
+msgstr ""
+
+msgid "interested_in"
+msgstr ""
+
+msgctxt "CWUser"
+msgid "interested_in"
+msgstr ""
+
+msgctxt "ForumThread"
+msgid "interested_in_object"
+msgstr ""
+
+msgctxt "Forum"
+msgid "interested_in_object"
+msgstr ""
+
+msgid "interested_in_object"
+msgstr ""
+
+msgid "nosy_list"
+msgstr ""
+
+msgctxt "ForumThread"
+msgid "nosy_list"
+msgstr ""
+
+msgctxt "Forum"
+msgid "nosy_list"
+msgstr ""
+
+msgctxt "CWUser"
+msgid "nosy_list_object"
+msgstr ""
+
+msgid "nosy_list_object"
+msgstr ""
+
+msgctxt "ForumThread"
+msgid "title"
+msgstr ""
+
+msgid "topic"
+msgstr ""
+
+msgctxt "Forum"
+msgid "topic"
+msgstr ""
+
+msgid "Topic"
+msgstr ""
+
+msgid "Description"
+msgstr ""
+
+msgid "Number of threads"
+msgstr ""
+
+msgid "Last activity"
+msgstr ""
+
+msgid ""
+"a long\n"
+"tranlated line\n"
+"hop."
+msgstr ""
+
+msgid "Subject"
+msgstr ""
+
+msgid "Created"
+msgstr ""
+
+msgid "Answers"
+msgstr ""
+
+msgid "Last answered"
+msgstr ""
+
+msgid "This forum does not have any thread yet."
+msgstr ""
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/devtools/test/data/libpython/cubicweb_i18ntestcube/schema.py Wed Jun 08 21:59:34 2016 +0200
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+# copyright 2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# contact http://www.logilab.fr -- mailto:contact@logilab.fr
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 2.1 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""cubicweb-forum schema"""
+
+from yams.buildobjs import (String, RichString, EntityType,
+ RelationDefinition, SubjectRelation)
+from yams.reader import context
+
+class Forum(EntityType):
+ topic = String(maxsize=50, required=True, unique=True)
+ description = RichString()
+
+class ForumThread(EntityType):
+ __permissions__ = {
+ 'read': ('managers', 'users'),
+ 'add': ('managers', 'users'),
+ 'update': ('managers', 'owners'),
+ 'delete': ('managers', 'owners')
+ }
+ title = String(required=True, fulltextindexed=True, maxsize=256)
+ content = RichString(required=True, fulltextindexed=True)
+ in_forum = SubjectRelation('Forum', cardinality='1*', inlined=True,
+ composite='object')
+class interested_in(RelationDefinition):
+ subject = 'CWUser'
+ object = ('ForumThread', 'Forum')
+
+class nosy_list(RelationDefinition):
+ subject = ('Forum', 'ForumThread')
+ object = 'CWUser'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/devtools/test/data/libpython/cubicweb_i18ntestcube/views.py Wed Jun 08 21:59:34 2016 +0200
@@ -0,0 +1,61 @@
+# copyright 2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# contact http://www.logilab.fr -- mailto:contact@logilab.fr
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 2.1 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""cubicweb-forum views/forms/actions/components for web ui"""
+
+from cubicweb import view
+from cubicweb.predicates import is_instance
+from cubicweb.web.views import primary, baseviews, uicfg
+from cubicweb.web.views.uicfg import autoform_section as afs
+
+class MyAFS(uicfg.AutoformSectionRelationTags):
+ __select__ = is_instance('ForumThread')
+
+_myafs = MyAFS()
+
+_myafs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined')
+
+afs.tag_object_of(('*', 'in_forum', 'Forum'), 'main', 'inlined')
+
+
+class ForumSameETypeListView(baseviews.SameETypeListView):
+ __select__ = baseviews.SameETypeListView.__select__ & is_instance('Forum')
+
+ def call(self, **kwargs):
+ _ = self._cw._
+ _('Topic'), _('Description')
+ _('Number of threads'), _('Last activity')
+ _('''a long
+tranlated line
+hop.''')
+
+
+class ForumLastActivity(view.EntityView):
+ __regid__ = 'forum_last_activity'
+ __select__ = view.EntityView.__select__ & is_instance('Forum')
+
+
+class ForumPrimaryView(primary.PrimaryView):
+ __select__ = primary.PrimaryView.__select__ & is_instance('Forum')
+
+ def render_entity_attributes(self, entity):
+ _ = self._cw._
+ _('Subject'), _('Created'), _('Answers'),
+ _('Last answered')
+ _('This forum does not have any thread yet.')
+
+class ForumThreadPrimaryView(primary.PrimaryView):
+ __select__ = primary.PrimaryView.__select__ & is_instance('ForumThread')
--- a/cubicweb/devtools/test/unittest_i18n.py Tue Jun 07 18:21:13 2016 +0200
+++ b/cubicweb/devtools/test/unittest_i18n.py Wed Jun 08 21:59:34 2016 +0200
@@ -57,19 +57,33 @@
def test_i18ncube(self):
env = os.environ.copy()
+ if 'PYTHONPATH' in env:
+ env['PYTHONPATH'] += os.pathsep
+ else:
+ env['PYTHONPATH'] = ''
+ env['PYTHONPATH'] += osp.join(DATADIR, 'libpython')
+ cubedir = osp.join(DATADIR, 'libpython', 'cubicweb_i18ntestcube')
+ self._check(cubedir, env)
+
+ def test_i18ncube_legacy_layout(self):
+ env = os.environ.copy()
env['CW_CUBES_PATH'] = osp.join(DATADIR, 'cubes')
if 'PYTHONPATH' in env:
env['PYTHONPATH'] += os.pathsep
else:
env['PYTHONPATH'] = ''
env['PYTHONPATH'] += DATADIR
+ cubedir = osp.join(DATADIR, 'cubes', 'i18ntestcube')
+ self._check(cubedir, env)
+
+ def _check(self, cubedir, env):
cmd = [sys.executable, '-m', 'cubicweb', 'i18ncube', 'i18ntestcube']
proc = Popen(cmd, env=env, stdout=PIPE, stderr=STDOUT)
stdout, _ = proc.communicate()
- self.assertEqual(proc.returncode, 0, msg=stdout)
- cube = osp.join(DATADIR, 'cubes', 'i18ntestcube')
- msgs = load_po(osp.join(cube, 'i18n', 'en.po.ref'))
- newmsgs = load_po(osp.join(cube, 'i18n', 'en.po'))
+ msg = stdout.decode(sys.getdefaultencoding(), errors='replace')
+ self.assertEqual(proc.returncode, 0, msg=msg)
+ msgs = load_po(osp.join(cubedir, 'i18n', 'en.po.ref'))
+ newmsgs = load_po(osp.join(cubedir, 'i18n', 'en.po'))
self.assertEqual(msgs, newmsgs)