Merge public heads
authorDenis Laxalde <denis.laxalde@logilab.fr>
Tue, 04 Oct 2016 11:04:34 +0200
changeset 11691 4e3ae4bd3fd5
parent 11690 15715274a631 (diff)
parent 11684 122eacf5210b (current diff)
child 11692 d46e0b3a13cc
Merge public heads
--- a/cubicweb/__pkginfo__.py	Thu Sep 29 11:19:30 2016 +0200
+++ b/cubicweb/__pkginfo__.py	Tue Oct 04 11:04:34 2016 +0200
@@ -43,42 +43,6 @@
     'Programming Language :: JavaScript',
 ]
 
-__depends__ = {
-    'six': '>= 1.4.0',
-    'logilab-common': '>= 1.2.2',
-    'logilab-mtconverter': '>= 0.8.0',
-    'rql': '>= 0.34.0',
-    'yams': '>= 0.44.0',
-    #gettext                    # for xgettext, msgcat, etc...
-    # web dependencies
-    'lxml': '',
-    # XXX graphviz
-    # server dependencies
-    'logilab-database': '>= 1.15.0',
-    'passlib': '',
-    'pytz': '',
-    'Markdown': '',
-    'unittest2': '>= 0.7.0',
-    # pyramid dependencies
-    'pyramid': '>= 1.5.0',
-    'waitress': '>= 0.8.9',
-    'wsgicors': '>= 0.3',
-    'pyramid_multiauth': '',
-    }
-
-__recommends__ = {
-    'docutils': '>= 0.6',
-    'Pillow': '',               # for captcha
-    'pycrypto': '',             # for crypto extensions
-    'fyzz': '>= 0.1.0',         # for sparql
-    'vobject': '>= 0.6.0',      # for ical view
-    'rdflib': None,             #
-    'pyzmq': None,
-    'Twisted': '< 16.0.0',
-    #'Products.FCKeditor':'',
-    #'SimpleTAL':'>= 4.1.6',
-}
-
 scripts = [s for s in glob.glob(join('bin', 'cubicweb-*'))
            if not s.endswith('.bat')]
 include_dirs = [join('test', 'data'),
--- a/cubicweb/pyramid/core.py	Thu Sep 29 11:19:30 2016 +0200
+++ b/cubicweb/pyramid/core.py	Tue Oct 04 11:04:34 2016 +0200
@@ -22,9 +22,6 @@
 log = logging.getLogger(__name__)
 
 
-CW_321 = cubicweb.__pkginfo__.numversion >= (3, 21, 0)
-
-
 class Connection(cwsession.Connection):
     """ A specialised Connection that access the session data through a
     property.
@@ -247,16 +244,10 @@
     if session is None:
         return None
 
-    if CW_321:
-        cnx = session.new_cnx()
+    cnx = session.new_cnx()
 
-        def commit_state(cnx):
-            return cnx.commit_state
-    else:
-        cnx = repoapi.ClientConnection(session)
-
-        def commit_state(cnx):
-            return cnx._cnx.commit_state
+    def commit_state(cnx):
+        return cnx.commit_state
 
     def cleanup(request):
         try:
--- a/doc/book/admin/cubicweb-ctl.rst	Thu Sep 29 11:19:30 2016 +0200
+++ b/doc/book/admin/cubicweb-ctl.rst	Tue Oct 04 11:04:34 2016 +0200
@@ -34,12 +34,9 @@
 
 Create your new cube cube ::
 
-   cubicweb-ctl newcube
+   cubicweb-ctl newcube -d <target directory>
 
-This will create a new cube in
-``/path/to/grshell-cubicweb/cubes/<mycube>`` for a Mercurial
-installation, or in ``/usr/share/cubicweb/cubes`` for a debian
-packages installation.
+This will create a new cube ``<target directory>``.
 
 Create an instance
 -------------------
--- a/doc/book/admin/instance-config.rst	Thu Sep 29 11:19:30 2016 +0200
+++ b/doc/book/admin/instance-config.rst	Tue Oct 04 11:04:34 2016 +0200
@@ -17,6 +17,11 @@
 each option name is prefixed with its own section and followed by its
 default value if necessary, e.g. "`<section>.<option>` [value]."
 
+.. note:: At runtime, configuration options can be overriden by environments
+    variables which name follows the option name with ``-`` replaced by ``_``
+    and a ``CW_`` prefix. For instance ``CW_BASE_URL=https://www.example.com``
+    would override the ``base-url`` configuration option.
+
 .. _`WebServerConfig`:
 
 Configuring the Web server
--- a/doc/book/devrepo/cubes/cc-newcube.rst	Thu Sep 29 11:19:30 2016 +0200
+++ b/doc/book/devrepo/cubes/cc-newcube.rst	Tue Oct 04 11:04:34 2016 +0200
@@ -3,12 +3,12 @@
 
 Let's start by creating the cube environment in which we will develop ::
 
-  cd ~/cubes
+  cd ~/myproject
   # use cubicweb-ctl to generate a template for the cube
   # will ask some questions, most with nice default
   cubicweb-ctl newcube mycube
   # makes the cube source code managed by mercurial
-  cd mycube
+  cd cubicweb-mycube
   hg init
   hg add .
   hg ci
@@ -22,36 +22,3 @@
 This variable is used for the instance packaging (dependencies handled
 by system utility tools such as APT) and to find used cubes when the
 database for the instance is created.
-
-On a Unix system, the available cubes are usually stored in the
-directory :file:`/usr/share/cubicweb/cubes`. If you are using the
-cubicweb mercurial repository (:ref:`SourceInstallation`), the cubes
-are searched in the directory
-:file:`/path/to/cubicweb_toplevel/cubes`. In this configuration
-cubicweb itself ought to be located at
-:file:`/path/to/cubicweb_toplevel/cubicweb`.
-
-.. note::
-
-    Please note that if you do not wish to use default directory for your cubes
-    library, you should set the :envvar:`CW_CUBES_PATH` environment variable to
-    add extra directories where cubes will be search, and you'll then have to use
-    the option `--directory` to specify where you would like to place the source
-    code of your cube:
-
-    ``cubicweb-ctl newcube --directory=/path/to/cubes/library mycube``
-
-
-.. XXX resurrect once live-server is back
-.. Usage of :command:`cubicweb-ctl liveserver`
-.. -------------------------------------------
-
-.. To quickly test a new cube, you can also use the `liveserver` command for cubicweb-ctl
-.. which allows to create an instance in memory (using an SQLite database by
-.. default) and make it accessible through a web server ::
-
-..   cubicweb-ctl live-server mycube
-
-.. or by using an existing database (SQLite or Postgres)::
-
-..   cubicweb-ctl live-server -s myfile_sources mycube
--- a/doc/book/devrepo/cubes/layout.rst	Thu Sep 29 11:19:30 2016 +0200
+++ b/doc/book/devrepo/cubes/layout.rst	Tue Oct 04 11:04:34 2016 +0200
@@ -6,17 +6,46 @@
 Standard structure for a cube
 -----------------------------
 
-A cube is structured as follows:
+A cube named "mycube" is Python package "cubicweb-mycube" structured as
+follows:
 
 ::
 
-  mycube/
+  cubicweb-mycube/
   |
-  |-- data/
-  |   |-- cubes.mycube.css
-  |   |-- cubes.mycube.js
-  |   `-- external_resources
-  |
+  |-- cubicweb_mycube/
+  |   |
+  |   |-- data/
+  |   |   |-- cubes.mycube.css
+  |   |   |-- cubes.mycube.js
+  |   |   `-- external_resources
+  |   |
+  |   |
+  |   |-- entities.py
+  |   |
+  |   |-- i18n/
+  |   |   |-- en.po
+  |   |   |-- es.po
+  |   |   `-- fr.po
+  |   |
+  |   |-- __init__.py
+  |   |
+  |   |
+  |   |-- migration/
+  |   |   |-- postcreate.py
+  |   |   `-- precreate.py
+  |   |
+  |   |-- __pkginfo__.py
+  |   |
+  |   |-- schema.py
+  |   |
+  |   |
+  |   |-- site_cubicweb.py
+  |   |
+  |   |-- hooks.py
+  |   |
+  |   |
+  |   `-- views.py
   |-- debian/
   |   |-- changelog
   |   |-- compat
@@ -24,56 +53,32 @@
   |   |-- copyright
   |   |-- cubicweb-mycube.prerm
   |   `-- rules
-  |
-  |-- entities.py
-  |
-  |-- i18n/
-  |   |-- en.po
-  |   |-- es.po
-  |   `-- fr.po
-  |
-  |-- __init__.py
-  |
   |-- MANIFEST.in
-  |
-  |-- migration/
-  |   |-- postcreate.py
-  |   `-- precreate.py
-  |
-  |-- __pkginfo__.py
-  |
-  |-- schema.py
-  |
   |-- setup.py
-  |
-  |-- site_cubicweb.py
-  |
-  |-- hooks.py
-  |
-  |-- test/
-  |   |-- data/
-  |   |   `-- bootstrap_cubes
-  |   |-- pytestconf.py
-  |   |-- realdb_test_mycube.py
-  |   `-- test_mycube.py
-  |
-  `-- views.py
+  `-- test/
+      |-- data/
+      |   `-- bootstrap_cubes
+      |-- pytestconf.py
+      |-- realdb_test_mycube.py
+      `-- test_mycube.py
 
 
-We can use subpackages instead of python modules for ``views.py``, ``entities.py``,
+We can use subpackages instead of Python modules for ``views.py``, ``entities.py``,
 ``schema.py`` or ``hooks.py``. For example, we could have:
 
 ::
 
-  mycube/
+  cubicweb-mycube/
   |
-  |-- entities.py
-  |-- hooks.py
-  `-- views/
-      |-- __init__.py
-      |-- forms.py
-      |-- primary.py
-      `-- widgets.py
+  |-- cubicweb_mycube/
+  |   |
+      |-- entities.py
+  .   |-- hooks.py
+  .   `-- views/
+  .       |-- __init__.py
+          |-- forms.py
+          |-- primary.py
+          `-- widgets.py
 
 
 where :
@@ -127,6 +132,27 @@
 something defined in the other's schema; on database creation, on something
 created by the other's postcreate, and so on.
 
+The :file:`setup.py` file
+-------------------------
+
+This is standard setuptools based setup module which reads most of its data
+from :file:`__pkginfo__.py`. In the ``setup`` function call, it should also
+include an entry point definition under the ``cubicweb.cubes`` group so that
+CubicWeb can discover cubes (in particular their custom ``cubicweb-ctl``
+commands):
+
+::
+
+    setup(
+      # ...
+      entry_points={
+          'cubicweb.cubes': [
+              'mycube=cubicweb_mycube',
+          ],
+      },
+      # ...
+    )
+
 
 :file:`migration/precreate.py` and :file:`migration/postcreate.py`
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/changes/3.24.rst	Tue Oct 04 11:04:34 2016 +0200
@@ -0,0 +1,15 @@
+3.34 (UNRELEASED)
+=================
+
+New features
+------------
+
+* Various bits of a CubicWeb application configuration can be now be
+  overridden through environments variables matching configuration option
+  names prefixed by ``CW_`` (for instance ``CW_BASE_URL``).
+
+* Cubes are now standard Python packages named as ``cubicweb_<cubename>``.
+  They are not anymore installed in ``<prefix>/share/cubicweb/cubes``. Their
+  discovery by CubicWeb is handled by a new setuptools entry point
+  ``cubicweb.cubes``. A backward compatibility layer is kept for "legacy"
+  cubes.
--- a/requirements/test-misc.txt	Thu Sep 29 11:19:30 2016 +0200
+++ b/requirements/test-misc.txt	Tue Oct 04 11:04:34 2016 +0200
@@ -20,5 +20,11 @@
 ## cubicweb/hooks/test
 psycopg2
 
+## cubicweb/pyramid/test
+pyramid >= 1.5.0
+waitress >= 0.8.9
+wsgicors >= 0.3
+pyramid_multiauth
+
 ## cubicweb/sobject/test
 cubicweb-comment
--- a/setup.py	Thu Sep 29 11:19:30 2016 +0200
+++ b/setup.py	Tue Oct 04 11:04:34 2016 +0200
@@ -50,12 +50,6 @@
     long_description = f.read()
 
 # import optional features
-requires = {}
-for entry in ("__depends__",): # "__recommends__"):
-    requires.update(__pkginfo__.get(entry, {}))
-install_requires = [("%s %s" % (d, v and v or "")).strip()
-                   for d, v in requires.items()]
-
 distname = __pkginfo__['distname']
 scripts = __pkginfo__['scripts']
 include_dirs = __pkginfo__['include_dirs']
@@ -208,7 +202,51 @@
     package_data=package_data,
     scripts=ensure_scripts(scripts),
     data_files=data_files,
-    install_requires=install_requires,
+    install_requires=[
+        'six >= 1.4.0',
+        'logilab-common >= 1.2.2',
+        'logilab-mtconverter >= 0.8.0',
+        'rql >= 0.34.0',
+        'yams >= 0.44.0',
+        'lxml',
+        'logilab-database >= 1.15.0',
+        'passlib',
+        'pytz',
+        'Markdown',
+        'unittest2 >= 0.7.0',
+    ],
+    extra_requires={
+        'captcha': [
+            'Pillow',
+        ],
+        'crypto': [
+            'pycrypto',
+        ],
+        'etwist': [
+            'Twisted < 16.0.0',
+        ],
+        'ext': [
+            'docutils >= 0.6',
+        ],
+        'ical': [
+            'vobject >= 0.6.0',
+        ],
+        'pyramid': [
+            'pyramid >= 1.5.0',
+            'waitress >= 0.8.9',
+            'wsgicors >= 0.3',
+            'pyramid_multiauth',
+        ],
+        'rdf': [
+            'rdflib',
+        ],
+        'sparql': [
+            'fyzz >= 0.1.0',
+        ],
+        'zmq': [
+            'pyzmq',
+        ],
+    },
     cmdclass={'install_lib': MyInstallLib,
               'install_data': MyInstallData},
     zip_safe=False,