# HG changeset patch # User Sylvain Thénault # Date 1270717457 -7200 # Node ID 955ee1b2475664b773460a6d618f9481f39dc0a9 # Parent 395e1ff018ae311edd3f4b05a4f64fdb6c94de5f [c-c newcube] #1192: simpler cubicweb-ctl newcube, and more * new --layout option, to get 'simple' or 'full' cube * new --licence option to specify license for the cube * added README and sobjects.py template (the later only added in full layout) * fixed python file templates to get proper headers according to the config diff -r 395e1ff018ae -r 955ee1b24756 devtools/devctl.py --- a/devtools/devctl.py Wed Apr 07 14:42:55 2010 +0200 +++ b/devtools/devctl.py Thu Apr 08 11:04:17 2010 +0200 @@ -22,7 +22,8 @@ from cubicweb.__pkginfo__ import version as cubicwebversion from cubicweb import CW_SOFTWARE_ROOT as BASEDIR, BadCommandUsage -from cubicweb.toolsutils import Command, copy_skeleton, underline_title +from cubicweb.toolsutils import (SKEL_EXCLUDE, Command, + copy_skeleton, underline_title) from cubicweb.web.webconfig import WebConfiguration from cubicweb.server.serverconfig import ServerConfiguration @@ -440,12 +441,19 @@ """Create a new cube. - the name of the new cube + the name of the new cube. It should be a valid python module name. """ name = 'newcube' arguments = '' options = ( + ("layout", + {'short': 'L', 'type' : 'choice', 'metavar': '', + 'default': 'simple', 'choices': ('simple', 'full'), + 'help': 'cube layout. You\'ll get a minimal cube with the "simple" \ +layout, and a full featured cube with "full" layout.', + } + ), ("directory", {'short': 'd', 'type' : 'string', 'metavar': '', 'help': 'directory where the new cube should be created', @@ -475,14 +483,28 @@ 'help': 'cube author\'s web site', } ), + ("license", + {'short': 'l', 'type' : 'choice', 'metavar': '', + 'default': 'LGPL', 'choices': ('GPL', 'LGPL', ''), + 'help': 'cube license', + } + ), ) + LICENSES = { + 'LGPL': 'GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses', + 'GPL': 'GNU General Public License, v2.1 - http://www.gnu.org/licenses', + '': 'closed source' + } def run(self, args): + import re from logilab.common.shellutils import ASK if len(args) != 1: raise BadCommandUsage("exactly one argument (cube name) is expected") - cubename, = args + cubename = args[0] + if not re.match('[_A-Za-z][_A-Za-z0-9]*$', cubename): + raise BadCommandUsage("cube name should be a valid python module name") verbose = self.get('verbose') cubesdir = self.get('directory') if not cubesdir: @@ -533,8 +555,14 @@ 'author': self['author'], 'author-email': self['author-email'], 'author-web-site': self['author-web-site'], + 'license': self['license'], + 'long-license': self.LICENSES[self['license']], } - copy_skeleton(skeldir, cubedir, context) + exclude = SKEL_EXCLUDE + if self['layout'] == 'simple': + exclude += ('sobjects.py*', 'precreate.py*', 'realdb_test*', + 'cubes.*', 'external_resources*') + copy_skeleton(skeldir, cubedir, context, exclude=exclude) def _ask_for_dependancies(self): from logilab.common.shellutils import ASK diff -r 395e1ff018ae -r 955ee1b24756 skeleton/README.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skeleton/README.tmpl Thu Apr 08 11:04:17 2010 +0200 @@ -0,0 +1,3 @@ +Summary +------- +%(longdesc)s diff -r 395e1ff018ae -r 955ee1b24756 skeleton/__pkginfo__.py.tmpl --- a/skeleton/__pkginfo__.py.tmpl Wed Apr 07 14:42:55 2010 +0200 +++ b/skeleton/__pkginfo__.py.tmpl Thu Apr 08 11:04:17 2010 +0200 @@ -7,7 +7,7 @@ numversion = (0, 1, 0) version = '.'.join(str(num) for num in numversion) -license = 'LCL' +license = '%(license)s' author = '%(author)s' author_email = '%(author-email)s' @@ -40,6 +40,6 @@ # Note: here, you'll need to add subdirectories if you want # them to be included in the debian package -__depends__ = {'cubicweb': '>= 3.8.0'} +__depends__ = {'cubicweb': '>= %(version)s'} __recommends__ = {} diff -r 395e1ff018ae -r 955ee1b24756 skeleton/data/cubes.CUBENAME.css --- a/skeleton/data/cubes.CUBENAME.css Wed Apr 07 14:42:55 2010 +0200 +++ b/skeleton/data/cubes.CUBENAME.css Thu Apr 08 11:04:17 2010 +0200 @@ -1,1 +1,1 @@ -/* template specific CSS */ +/* cube-specific CSS */ diff -r 395e1ff018ae -r 955ee1b24756 skeleton/data/cubes.CUBENAME.js --- a/skeleton/data/cubes.CUBENAME.js Wed Apr 07 14:42:55 2010 +0200 +++ b/skeleton/data/cubes.CUBENAME.js Thu Apr 08 11:04:17 2010 +0200 @@ -1,1 +1,1 @@ -// This contains template-specific javascript \ No newline at end of file +// This contains cube-specific javascript \ No newline at end of file diff -r 395e1ff018ae -r 955ee1b24756 skeleton/entities.py --- a/skeleton/entities.py Wed Apr 07 14:42:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -"""this contains the cube-specific entities' classes - -:organization: Logilab -:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. -:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr -:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses -""" diff -r 395e1ff018ae -r 955ee1b24756 skeleton/entities.py.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skeleton/entities.py.tmpl Thu Apr 08 11:04:17 2010 +0200 @@ -0,0 +1,7 @@ +"""%(distname)s entity's classes + +:organization: %(author)s +:copyright: %(year)s %(author)s +:contact: %(author-web-site)s -- mailto:%(author-email)s +:license: %(long-license)s +""" diff -r 395e1ff018ae -r 955ee1b24756 skeleton/hooks.py.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skeleton/hooks.py.tmpl Thu Apr 08 11:04:17 2010 +0200 @@ -0,0 +1,7 @@ +"""%(distname)s specific hooks and operations + +:organization: %(author)s +:copyright: %(year)s %(author)s +:contact: %(author-web-site)s -- mailto:%(author-email)s +:license: %(long-license)s +""" diff -r 395e1ff018ae -r 955ee1b24756 skeleton/migration/postcreate.py --- a/skeleton/migration/postcreate.py Wed Apr 07 14:42:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -# postcreate script. You could setup site properties or a workflow here for example -""" - -:organization: Logilab -:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. -:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr -:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses -""" - -# Example of site property change -#set_property('ui.site-title', "") - diff -r 395e1ff018ae -r 955ee1b24756 skeleton/migration/postcreate.py.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skeleton/migration/postcreate.py.tmpl Thu Apr 08 11:04:17 2010 +0200 @@ -0,0 +1,14 @@ +"""%(distname)s postcreate script, executed at instance creation time or when +the cube is added to an existing instance. + +You could setup site properties or a workflow here for example. + +:organization: %(author)s +:copyright: %(year)s %(author)s +:contact: %(author-web-site)s -- mailto:%(author-email)s +:license: %(long-license)s +""" + +# Example of site property change +#set_property('ui.site-title', "") + diff -r 395e1ff018ae -r 955ee1b24756 skeleton/migration/precreate.py --- a/skeleton/migration/precreate.py Wed Apr 07 14:42:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -# Instructions here will be read before reading the schema -""" - -:organization: Logilab -:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. -:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr -:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses -""" -# You could create your own groups here, like in : -# create_entity('CWGroup', name=u'mygroup') diff -r 395e1ff018ae -r 955ee1b24756 skeleton/migration/precreate.py.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skeleton/migration/precreate.py.tmpl Thu Apr 08 11:04:17 2010 +0200 @@ -0,0 +1,10 @@ +"""%(distname)s precreate script, executed at instance creation time or when +the cube is added to an existing instance, before the schema is serialized. + +This is typically to create groups referenced by the cube'schema. + +:organization: %(author)s +:copyright: %(year)s %(author)s +:contact: %(author-web-site)s -- mailto:%(author-email)s +:license: %(long-license)s +""" diff -r 395e1ff018ae -r 955ee1b24756 skeleton/schema.py --- a/skeleton/schema.py Wed Apr 07 14:42:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -# cube's specific schema -""" - -:organization: Logilab -:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. -:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr -:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses -""" diff -r 395e1ff018ae -r 955ee1b24756 skeleton/schema.py.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skeleton/schema.py.tmpl Thu Apr 08 11:04:17 2010 +0200 @@ -0,0 +1,7 @@ +"""%(distname)s schema + +:organization: %(author)s +:copyright: %(year)s %(author)s +:contact: %(author-web-site)s -- mailto:%(author-email)s +:license: %(long-license)s +""" diff -r 395e1ff018ae -r 955ee1b24756 skeleton/setup.py --- a/skeleton/setup.py Wed Apr 07 14:42:55 2010 +0200 +++ b/skeleton/setup.py Thu Apr 08 11:04:17 2010 +0200 @@ -43,6 +43,8 @@ if exists('README'): long_description = file('README').read() +else: + long_description = '' # import optional features import __pkginfo__ diff -r 395e1ff018ae -r 955ee1b24756 skeleton/sobjects.py.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skeleton/sobjects.py.tmpl Thu Apr 08 11:04:17 2010 +0200 @@ -0,0 +1,7 @@ +"""%(distname)s repository side views, usually for notification + +:organization: %(author)s +:copyright: %(year)s %(author)s +:contact: %(author-web-site)s -- mailto:%(author-email)s +:license: %(long-license)s +""" diff -r 395e1ff018ae -r 955ee1b24756 skeleton/views.py --- a/skeleton/views.py Wed Apr 07 14:42:55 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -"""cube-specific forms/views/actions/components - -:organization: Logilab -:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. -:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr -:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses -""" diff -r 395e1ff018ae -r 955ee1b24756 skeleton/views.py.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skeleton/views.py.tmpl Thu Apr 08 11:04:17 2010 +0200 @@ -0,0 +1,7 @@ +"""%(distname)s views/forms/actions/components for web ui + +:organization: %(author)s +:copyright: %(year)s %(author)s +:contact: %(author-web-site)s -- mailto:%(author-email)s +:license: %(long-license)s +""" diff -r 395e1ff018ae -r 955ee1b24756 toolsutils.py --- a/toolsutils.py Wed Apr 07 14:42:55 2010 +0200 +++ b/toolsutils.py Thu Apr 08 11:04:17 2010 +0200 @@ -103,10 +103,9 @@ else: print 'no diff between %s and %s' % (appl_file, ref_file) - +SKEL_EXCLUDE = ('*.py[co]', '*.orig', '*~', '*_flymake.py') def copy_skeleton(skeldir, targetdir, context, - exclude=('*.py[co]', '*.orig', '*~', '*_flymake.py'), - askconfirm=False): + exclude=SKEL_EXCLUDE, askconfirm=False): import shutil from fnmatch import fnmatch skeldir = normpath(skeldir)