merge
authorKatia Saurfelt <katia.saurfelt@logilab.fr>
Wed, 11 Mar 2009 14:36:26 +0100
changeset 1078 f6aaab4d51e3
parent 1077 fe26a0cda180 (current diff)
parent 1043 7c21ca28327f (diff)
child 1079 452cb76fe07a
merge
--- a/.hgtags	Wed Mar 11 14:34:55 2009 +0100
+++ b/.hgtags	Wed Mar 11 14:36:26 2009 +0100
@@ -18,3 +18,7 @@
 a8e9e53b245d53838a07aa8c76d1bed352692a9f cubicweb-debian-version-3_0_9-1
 a711c7c185d15a1bd22b7eaab46a26b98b74fbf3 cubicweb-version-3_1_0
 dd3efdf58d281286d6f52f7416db349b75b7789c cubicweb-debian-version-3_1_0-1
+ce8094084165419ff1717bdb2f426574bcaaad93 cubicweb-version-3_1_1
+dfaedb0bba88e3a4e931948bb0c6a9587269303f cubicweb-debian-version-3_1_1-1
+a9ba200ab15098704a6255387c558c02488551c6 cubicweb-version-3_1_2
+a823124b812f4fa494bfceb773f3ca1cd00407e8 cubicweb-debian-version-3_1_2-1
--- a/MANIFEST.in	Wed Mar 11 14:34:55 2009 +0100
+++ b/MANIFEST.in	Wed Mar 11 14:36:26 2009 +0100
@@ -25,6 +25,6 @@
 recursive-include web/test/data *.js *.css *.png *.gif *.jpg *.ico external_resources
 recursive-include devtools/test/data *
 
-recursive-include skeleton *.py*.css *.js *.po compat *.in *.tmpl 
+recursive-include skeleton *.py*.css *.js *.po compat *.in *.tmpl
 
 prune misc/cwfs
--- a/__init__.py	Wed Mar 11 14:34:55 2009 +0100
+++ b/__init__.py	Wed Mar 11 14:36:26 2009 +0100
@@ -2,9 +2,9 @@
 relations between entitites.
 
 :organization: Logilab
-:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: General Public License version 2 - http://www.gnu.org/licenses
+:license: Library General Public License version 2 - http://www.gnu.org/licenses
 """
 __docformat__ = "restructuredtext en"
 from cubicweb.__pkginfo__ import version as __version__
--- a/__pkginfo__.py	Wed Mar 11 14:34:55 2009 +0100
+++ b/__pkginfo__.py	Wed Mar 11 14:36:26 2009 +0100
@@ -6,10 +6,10 @@
 distname = "cubicweb"
 modname = "cubicweb"
 
-numversion = (3, 1, 0)
+numversion = (3, 1, 2)
 version = '.'.join(str(num) for num in numversion)
 
-license = 'GPL'
+license = 'LGPL v2'
 copyright = '''Copyright (c) 2003-2009 LOGILAB S.A. (Paris, FRANCE).
 http://www.logilab.fr/ -- mailto:contact@logilab.fr'''
 
--- a/cwconfig.py	Wed Mar 11 14:34:55 2009 +0100
+++ b/cwconfig.py	Wed Mar 11 14:36:26 2009 +0100
@@ -10,7 +10,7 @@
 import sys
 import os
 import logging
-from os.path import exists, join, expanduser, abspath, basename
+from os.path import exists, join, expanduser, abspath, normpath, basename, isdir
 
 from logilab.common.decorators import cached
 from logilab.common.logging_ext import set_log_methods, init_log
@@ -152,7 +152,7 @@
         file(join(CUBES_DIR, '__init__.py'), 'w').close()
     elif exists(join(CW_SOFTWARE_ROOT, '.hg')):
         mode = 'dev'
-        CUBES_DIR = join(CW_SOFTWARE_ROOT, '../cubes')
+        CUBES_DIR = abspath(normpath(join(CW_SOFTWARE_ROOT, '../cubes')))
     else:
         mode = 'installed'
         CUBES_DIR = '/usr/share/cubicweb/cubes/'
@@ -225,7 +225,7 @@
         """
         if cls.mode in ('dev', 'test') and not os.environ.get('APYCOT_ROOT'):
             return join(CW_SOFTWARE_ROOT, 'web')
-        return join(cls.cubes_dir(), 'shared')
+        return cls.cube_dir('shared')
         
     @classmethod
     def i18n_lib_dir(cls):
@@ -236,26 +236,38 @@
 
     @classmethod
     def available_cubes(cls):
-        cubes_dir = cls.cubes_dir()
-        return sorted(cube for cube in os.listdir(cubes_dir)
-                      if os.path.isdir(os.path.join(cubes_dir, cube))
-                      and not cube in ('CVS', '.svn', 'shared', '.hg'))
+        cubes = set()
+        for directory in cls.cubes_search_path():
+            for cube in os.listdir(directory):
+                if isdir(join(directory, cube)) and not cube in ('CVS', '.svn', 'shared', '.hg'):
+                    cubes.add(cube)
+        return sorted(cubes)
     
     @classmethod
-    def cubes_dir(cls):
-        """return the application cubes directory"""
-        return env_path('CW_CUBES', cls.CUBES_DIR, 'cubes')
+    def cubes_search_path(cls):
+        """return the path of directories where cubes should be searched"""
+        path = []
+        try:
+            for directory in os.environ['CW_CUBES_PATH'].split(os.pathsep):
+                directory = abspath(normpath(directory))
+                if exists(directory) and not directory in path:
+                    path.append(directory)
+        except KeyError:
+            pass
+        if not cls.CUBES_DIR in path:
+            path.append(cls.CUBES_DIR)
+        return path
     
     @classmethod
     def cube_dir(cls, cube):
         """return the cube directory for the given cube id,
         raise ConfigurationError if it doesn't exists
         """
-        cube_dir = join(cls.cubes_dir(), cube)
-        if not exists(cube_dir):
-            raise ConfigurationError('no cube %s in %s' % (
-                cube, cls.cubes_dir()))
-        return cube_dir
+        for directory in cls.cubes_search_path():
+            cubedir = join(directory, cube)
+            if exists(cubedir):
+                return cubedir
+        raise ConfigurationError('no cube %s in %s' % (cube, cls.cubes_search_path()))
 
     @classmethod
     def cube_migration_scripts_dir(cls, cube):
@@ -341,12 +353,14 @@
     @classmethod
     def cls_adjust_sys_path(cls):
         """update python path if necessary"""
+        cubes_parent_dir = normpath(join(cls.CUBES_DIR, '..'))
+        if not cubes_parent_dir in sys.path:
+            sys.path.insert(0, cubes_parent_dir)
         try:
-            templdir = abspath(join(cls.cubes_dir(), '..'))
-            if not templdir in sys.path:
-                sys.path.insert(0, templdir)
-        except ConfigurationError:
-            return # cube dir doesn't exists
+            import cubes
+            cubes.__path__ = cls.cubes_search_path()
+        except ImportError:
+            return # cubes dir doesn't exists
 
     @classmethod
     def load_cwctl_plugins(cls):
@@ -358,10 +372,9 @@
             if exists(join(CW_SOFTWARE_ROOT, ctlfile)):
                 load_module_from_file(join(CW_SOFTWARE_ROOT, ctlfile))
                 cls.info('loaded cubicweb-ctl plugin %s', ctlfile)
-        templdir = cls.cubes_dir()
         for cube in cls.available_cubes():
-            pluginfile = join(templdir, cube, 'ecplugin.py')
-            initfile = join(templdir, cube, '__init__.py')
+            pluginfile = join(cls.cube_dir(cube), 'ecplugin.py')
+            initfile = join(cls.cube_dir(cube), '__init__.py')
             if exists(pluginfile):
                 try:
                     __import__('cubes.%s.ecplugin' % cube)
--- a/cwctl.py	Wed Mar 11 14:34:55 2009 +0100
+++ b/cwctl.py	Wed Mar 11 14:36:26 2009 +0100
@@ -173,19 +173,18 @@
                     continue
                 print '   ', line
         print 
+        cubesdirs = ', '.join(CubicWebConfiguration.cubes_search_path())
         try:
-            cubesdir = CubicWebConfiguration.cubes_dir()
             namesize = max(len(x) for x in CubicWebConfiguration.available_cubes())
         except ConfigurationError, ex:
             print 'No cubes available:', ex
         except ValueError:
-            print 'No cubes available in %s' % cubesdir
+            print 'No cubes available in %s' % cubesdirs
         else:
-            print 'Available cubes (%s):' % cubesdir
+            print 'Available cubes (%s):' % cubesdirs
             for cube in CubicWebConfiguration.available_cubes():
                 if cube in ('CVS', '.svn', 'shared', '.hg'):
                     continue
-                templdir = join(cubesdir, cube)
                 try:
                     tinfo = CubicWebConfiguration.cube_pkginfo(cube)
                     tversion = tinfo.version
@@ -198,7 +197,7 @@
                                            or tinfo.__doc__)
                     if shortdesc:
                         print '    '+ '    \n'.join(shortdesc.splitlines())
-                    modes = detect_available_modes(templdir)
+                    modes = detect_available_modes(CubicWebConfiguration.cube_dir(cube))
                     print '    available modes: %s' % ', '.join(modes)
         print
         try:
--- a/debian/changelog	Wed Mar 11 14:34:55 2009 +0100
+++ b/debian/changelog	Wed Mar 11 14:36:26 2009 +0100
@@ -1,3 +1,15 @@
+cubicweb (3.1.2-1) unstable; urgency=low
+
+  * new upstream release
+
+ -- Aurélien Campéas <aurelien.campeas@logilab.fr>  Wed, 10 Mar 2009 12:30:00 +0100
+
+cubicweb (3.1.1-1) unstable; urgency=low
+
+  * new upstream release
+
+ -- Aurélien Campéas <aurelien.campeas@logilab.fr>  Wed, 9 Mar 2009 18:32:00 +0100
+
 cubicweb (3.1.0-1) unstable; urgency=low
 
   * new upstream release
--- a/debian/control	Wed Mar 11 14:34:55 2009 +0100
+++ b/debian/control	Wed Mar 11 14:36:26 2009 +0100
@@ -1,9 +1,10 @@
 Source: cubicweb
 Section: web
 Priority: optional
-Maintainer: Logilab Packaging Team <contact@logilab.fr>
+Maintainer: Logilab S.A. <contact@logilab.fr>
 Uploaders: Sylvain Thenault <sylvain.thenault@logilab.fr>,
-           Julien Jehannet <julien.jehannet@logilab.fr>
+           Julien Jehannet <julien.jehannet@logilab.fr>,
+           Aurélien Campéas <aurelien.campeas@logilab.fr>
 Build-Depends: debhelper (>= 7), python-dev (>=2.4), python-central (>= 0.5)
 Standards-Version: 3.8.0
 Homepage: http://www.cubicweb.org
@@ -54,7 +55,7 @@
  This package provides a twisted based HTTP server to serve
  the adaptative web interface (see cubicweb-web package).
  .
- This package provides only the twisted server part of the library. 
+ This package provides only the twisted server part of the library.
 
 
 Package: cubicweb-web
@@ -105,7 +106,7 @@
 Description: RQL command line client for the CubicWeb framework
  CubicWeb is a semantic web application framework.
  .
- This package provides a RQL (Relation Query Language) command line client using 
+ This package provides a RQL (Relation Query Language) command line client using
  pyro to connect to a repository server.
 
 
--- a/debian/rules	Wed Mar 11 14:34:55 2009 +0100
+++ b/debian/rules	Wed Mar 11 14:36:26 2009 +0100
@@ -48,7 +48,6 @@
 	rm -rf debian/cubicweb-common/usr/lib/${PY_VERSION}/site-packages/cubicweb/common/test
 
 	# cubes directory must be managed as a valid python module
-	ls -l debian/cubicweb-common/usr/share/cubicweb/cubes
 	touch debian/cubicweb-common/usr/share/cubicweb/cubes/__init__.py
 
 %: %.in
--- a/devtools/devctl.py	Wed Mar 11 14:34:55 2009 +0100
+++ b/devtools/devctl.py	Wed Mar 11 14:36:26 2009 +0100
@@ -286,10 +286,10 @@
         """run the command with its specific arguments"""
         CUBEDIR = DevCubeConfiguration.cubes_dir()
         if args:
-            cubes = [join(CUBEDIR, app) for app in args]
+            cubes = [DevCubeConfiguration.cube_dir(cube) for cube in args]
         else:
-            cubes = [join(CUBEDIR, app) for app in listdir(CUBEDIR)
-                         if exists(join(CUBEDIR, app, 'i18n'))]
+            cubes = [DevCubeConfiguration.cube_dir(cube) for cube in DevCubeConfiguration.available_cubes()]
+            cubes = [cubepath for cubepath in cubes if exists(join(cubepath, 'i18n'))]
         update_cubes_catalogs(cubes)
 
 def update_cubes_catalogs(cubes):
--- a/goa/goactl.py	Wed Mar 11 14:34:55 2009 +0100
+++ b/goa/goactl.py	Wed Mar 11 14:36:26 2009 +0100
@@ -211,12 +211,12 @@
         # link every supported components
         packagesdir = join(appldir, 'cubes')
         create_init_file(join(appldir, 'cubes'), 'cubes')
-        cubesdir = CubicWebConfiguration.cubes_dir()
-        for include in ('addressbook','basket', 'blog','classfolders',
-                        'classtags', 'comment', 'file', 'link',
+        for include in ('addressbook','basket', 'blog','folder',
+                        'tag', 'comment', 'file', 'link',
                         'mailinglist', 'person', 'task', 'zone',
                         ):
-            create_symlink(join(cubesdir, include), join(packagesdir, include))
+            create_symlink(CubicWebConfiguration.cube_dir(include),
+                           join(packagesdir, include))
         # generate sample config
         from cubicweb.goa.goaconfig import GAEConfiguration
         from cubicweb.common.migration import MigrationHelper
--- a/test/unittest_cwconfig.py	Wed Mar 11 14:34:55 2009 +0100
+++ b/test/unittest_cwconfig.py	Wed Mar 11 14:36:26 2009 +0100
@@ -1,4 +1,6 @@
+import sys
 import os
+from os.path import dirname, join, abspath
 from tempfile import mktemp
 
 from logilab.common.testlib import TestCase, unittest_main
@@ -69,6 +71,36 @@
                           ['entities', 'web/views', 'sobjects',
                            'file/entities.py', 'file/views', 'file/hooks.py',
                            'email/entities.py', 'email/views', 'email/hooks.py'])
-            
+
+    def test_cubes_path(self):
+        # make sure we don't import the email cube, but the stdlib email package
+        import email
+        self.assertNotEquals(dirname(email.__file__), self.config.CUBES_DIR)
+        os.environ['CW_CUBES_PATH'] = join(dirname(__file__), 'data', 'cubes')
+        self.assertEquals(self.config.cubes_search_path(),
+                          [abspath(join(dirname(__file__), 'data', 'cubes')),
+                           self.config.CUBES_DIR])
+        os.environ['CW_CUBES_PATH'] = '%s%s%s%s%s' % (join(dirname(__file__), 'data', 'cubes'),
+                                                      os.pathsep, self.config.CUBES_DIR,
+                                                      os.pathsep, 'unexistant')
+        # filter out unexistant and duplicates
+        self.assertEquals(self.config.cubes_search_path(),
+                          [abspath(join(dirname(__file__), 'data', 'cubes')),
+                           self.config.CUBES_DIR])
+        self.failUnless('mycube' in self.config.available_cubes())
+        # test cubes python path
+        self.config.adjust_sys_path()
+        import cubes
+        self.assertEquals(cubes.__path__, self.config.cubes_search_path())
+        # this import should succeed once path is adjusted
+        from cubes import mycube
+        self.assertEquals(mycube.__path__, [abspath(join(dirname(__file__), 'data', 'cubes', 'mycube'))])
+        # file cube should be overriden by the one found in data/cubes
+        sys.modules.pop('cubes.file', None)
+        del cubes.file
+        from cubes import file
+        self.assertEquals(file.__path__, [abspath(join(dirname(__file__), 'data', 'cubes', 'file'))])
+                                       
+                          
 if __name__ == '__main__':
     unittest_main()