# HG changeset patch # User Adrien Di Mascio # Date 1248808487 -7200 # Node ID 6f8ffaa2a7006883014046f56796ddfaaac6827f # Parent 88595be9087da666a27fa33891b566c832265521# Parent 73c83c14dd2cd39cb0f0cc7d8cc5a3611daf288a backport stable branch changesets diff -r 73c83c14dd2c -r 6f8ffaa2a700 __init__.py --- a/__init__.py Tue Jul 28 21:11:10 2009 +0200 +++ b/__init__.py Tue Jul 28 21:14:47 2009 +0200 @@ -109,11 +109,16 @@ # url generation methods ################################################## - def build_url(self, method, base_url=None, **kwargs): + def build_url(self, *args, **kwargs): """return an absolute URL using params dictionary key/values as URL parameters. Values are automatically URL quoted, and the publishing method to use may be specified or will be guessed. """ + # use *args since we don't want first argument to be "anonymous" to + # avoid potential clash with kwargs + assert len(args) == 1, 'only 0 or 1 non-named-argument expected' + method = args[0] + base_url = kwargs.pop('base_url', None) if base_url is None: base_url = self.base_url() if '_restpath' in kwargs: @@ -193,7 +198,7 @@ # abstract methods to override according to the web front-end ############# def base_url(self): - """return the root url of the application""" + """return the root url of the instance""" raise NotImplementedError def decorate_rset(self, rset): diff -r 73c83c14dd2c -r 6f8ffaa2a700 __pkginfo__.py --- a/__pkginfo__.py Tue Jul 28 21:11:10 2009 +0200 +++ b/__pkginfo__.py Tue Jul 28 21:14:47 2009 +0200 @@ -7,7 +7,7 @@ distname = "cubicweb" modname = "cubicweb" -numversion = (3, 3, 4) +numversion = (3, 4, 0) version = '.'.join(str(num) for num in numversion) license = 'LGPL v2' diff -r 73c83c14dd2c -r 6f8ffaa2a700 appobject.py --- a/appobject.py Tue Jul 28 21:11:10 2009 +0200 +++ b/appobject.py Tue Jul 28 21:14:47 2009 +0200 @@ -40,11 +40,11 @@ At registration time, the following attributes are set on the class: :vreg: - the application's registry + the instance's registry :schema: - the application's schema + the instance's schema :config: - the application's configuration + the instance's configuration At instantiation time, the following attributes are set on the instance: :req: @@ -151,7 +151,8 @@ # try to get page boundaries from the navigation component # XXX we should probably not have a ref to this component here (eg in # cubicweb.common) - nav = self.vreg.select_component('navigation', self.req, self.rset) + nav = self.vreg.select_object('components', 'navigation', self.req, + rset=self.rset) if nav: start, stop = nav.page_boundaries() rql = self._limit_offset_rql(stop - start, start) @@ -189,7 +190,8 @@ def view(self, __vid, rset=None, __fallback_vid=None, **kwargs): """shortcut to self.vreg.view method avoiding to pass self.req""" - return self.vreg.view(__vid, self.req, rset, __fallback_vid, **kwargs) + return self.vreg.render(__vid, self.req, __fallback_vid, rset=rset, + **kwargs) def initialize_varmaker(self): varmaker = self.req.get_page_data('rql_varmaker') @@ -202,11 +204,18 @@ controller = 'view' - def build_url(self, method=None, **kwargs): + def build_url(self, *args, **kwargs): """return an absolute URL using params dictionary key/values as URL parameters. Values are automatically URL quoted, and the publishing method to use may be specified or will be guessed. """ + # use *args since we don't want first argument to be "anonymous" to + # avoid potential clash with kwargs + if args: + assert len(args) == 1, 'only 0 or 1 non-named-argument expected' + method = args[0] + else: + method = None # XXX I (adim) think that if method is passed explicitly, we should # not try to process it and directly call req.build_url() if method is None: @@ -267,7 +276,7 @@ return output.getvalue() def format_date(self, date, date_format=None, time=False): - """return a string for a date time according to application's + """return a string for a date time according to instance's configuration """ if date: @@ -280,7 +289,7 @@ return u'' def format_time(self, time): - """return a string for a time according to application's + """return a string for a time according to instance's configuration """ if time: @@ -288,7 +297,7 @@ return u'' def format_float(self, num): - """return a string for floating point number according to application's + """return a string for floating point number according to instance's configuration """ if num: diff -r 73c83c14dd2c -r 6f8ffaa2a700 common/i18n.py --- a/common/i18n.py Tue Jul 28 21:11:10 2009 +0200 +++ b/common/i18n.py Tue Jul 28 21:14:47 2009 +0200 @@ -73,7 +73,7 @@ pofiles = [pof for pof in pofiles if exists(pof)] mergedpo = join(destdir, '%s_merged.po' % lang) try: - # merge application messages' catalog with the stdlib's one + # merge instance/cubes messages catalogs with the stdlib's one execute('msgcat --use-first --sort-output --strict %s > %s' % (' '.join(pofiles), mergedpo)) # make sure the .mo file is writeable and compile with *msgfmt* diff -r 73c83c14dd2c -r 6f8ffaa2a700 common/mail.py --- a/common/mail.py Tue Jul 28 21:11:10 2009 +0200 +++ b/common/mail.py Tue Jul 28 21:14:47 2009 +0200 @@ -18,7 +18,7 @@ def addrheader(uaddr, uname=None): # even if an email address should be ascii, encode it using utf8 since - # application tests may generate non ascii email address + # automatic tests may generate non ascii email address addr = uaddr.encode('UTF-8') if uname: return '%s <%s>' % (header(uname).encode(), addr) diff -r 73c83c14dd2c -r 6f8ffaa2a700 common/migration.py --- a/common/migration.py Tue Jul 28 21:11:10 2009 +0200 +++ b/common/migration.py Tue Jul 28 21:14:47 2009 +0200 @@ -1,5 +1,4 @@ -"""utility to ease migration of application version to newly installed -version +"""utilities for instances migration :organization: Logilab :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. @@ -11,7 +10,7 @@ import sys import os import logging -from tempfile import mktemp +import tempfile from os.path import exists, join, basename, splitext from logilab.common.decorators import cached @@ -70,7 +69,7 @@ ability to show the script's content """ while True: - confirm = raw_input('** execute %r (Y/n/s[how]) ?' % scriptpath) + confirm = raw_input('Execute %r (Y/n/s[how]) ?' % scriptpath) confirm = confirm.strip().lower() if confirm in ('n', 'no'): return False @@ -153,11 +152,15 @@ migrdir = self.config.cube_migration_scripts_dir(cube) scripts = filter_scripts(self.config, migrdir, fromversion, toversion) if scripts: + prevversion = None for version, script in scripts: + # take care to X.Y.Z_Any.py / X.Y.Z_common.py: we've to call + # cube_upgraded once all script of X.Y.Z have been executed + if prevversion is not None and version != prevversion: + self.cube_upgraded(cube, version) + prevversion = version self.process_script(script) - self.cube_upgraded(cube, version) - if version != toversion: - self.cube_upgraded(cube, toversion) + self.cube_upgraded(cube, toversion) else: self.cube_upgraded(cube, toversion) @@ -169,7 +172,7 @@ def interact(self, args, kwargs, meth): """execute the given method according to user's confirmation""" - msg = 'execute command: %s(%s) ?' % ( + msg = 'Execute command: %s(%s) ?' % ( meth.__name__[4:], ', '.join([repr(arg) for arg in args] + ['%s=%r' % (n,v) for n,v in kwargs.items()])) @@ -337,7 +340,7 @@ configfile = self.config.main_config_file() if self._option_changes: read_old_config(self.config, self._option_changes, configfile) - newconfig = mktemp() + _, newconfig = tempfile.mkstemp() for optdescr in self._option_changes: if optdescr[0] == 'added': optdict = self.config.get_option_def(optdescr[1]) diff -r 73c83c14dd2c -r 6f8ffaa2a700 common/mixins.py --- a/common/mixins.py Tue Jul 28 21:11:10 2009 +0200 +++ b/common/mixins.py Tue Jul 28 21:14:47 2009 +0200 @@ -244,7 +244,7 @@ @obsolete('use EntityFieldsForm.subject_in_state_vocabulary') def subject_in_state_vocabulary(self, rschema, limit=None): - form = self.vreg.select_object('forms', 'edition', self.req, entity=self) + form = self.vreg.select('forms', 'edition', self.req, entity=self) return form.subject_in_state_vocabulary(rschema, limit) diff -r 73c83c14dd2c -r 6f8ffaa2a700 common/mttransforms.py --- a/common/mttransforms.py Tue Jul 28 21:11:10 2009 +0200 +++ b/common/mttransforms.py Tue Jul 28 21:14:47 2009 +0200 @@ -46,8 +46,8 @@ from cubicweb.ext.tal import compile_template except ImportError: HAS_TAL = False - from cubicweb.schema import FormatConstraint - FormatConstraint.need_perm_formats.remove('text/cubicweb-page-template') + from cubicweb import schema + schema.NEED_PERM_FORMATS.remove('text/cubicweb-page-template') else: HAS_TAL = True diff -r 73c83c14dd2c -r 6f8ffaa2a700 common/tags.py --- a/common/tags.py Tue Jul 28 21:11:10 2009 +0200 +++ b/common/tags.py Tue Jul 28 21:14:47 2009 +0200 @@ -7,7 +7,7 @@ """ __docformat__ = "restructuredtext en" -from cubicweb.common.uilib import simple_sgml_tag +from cubicweb.common.uilib import simple_sgml_tag, sgml_attributes class tag(object): def __init__(self, name, escapecontent=True): @@ -38,8 +38,7 @@ if id: attrs['id'] = id attrs['name'] = name - html = [u'' % sgml_attributes(attrs)] html += options html.append(u'') return u'\n'.join(html) diff -r 73c83c14dd2c -r 6f8ffaa2a700 common/uilib.py --- a/common/uilib.py Tue Jul 28 21:11:10 2009 +0200 +++ b/common/uilib.py Tue Jul 28 21:14:47 2009 +0200 @@ -212,10 +212,15 @@ HTML4_EMPTY_TAGS = frozenset(('base', 'meta', 'link', 'hr', 'br', 'param', 'img', 'area', 'input', 'col')) +def sgml_attributes(attrs): + return u' '.join(u'%s="%s"' % (attr, xml_escape(unicode(value))) + for attr, value in sorted(attrs.items()) + if value is not None) + def simple_sgml_tag(tag, content=None, escapecontent=True, **attrs): """generation of a simple sgml tag (eg without children tags) easier - content and attributes will be escaped + content and attri butes will be escaped """ value = u'<%s' % tag if attrs: @@ -223,9 +228,7 @@ attrs['class'] = attrs.pop('klass') except KeyError: pass - value += u' ' + u' '.join(u'%s="%s"' % (attr, xml_escape(unicode(value))) - for attr, value in sorted(attrs.items()) - if value is not None) + value += u' ' + sgml_attributes(attrs) if content: if escapecontent: content = xml_escape(unicode(content)) diff -r 73c83c14dd2c -r 6f8ffaa2a700 cwconfig.py --- a/cwconfig.py Tue Jul 28 21:11:10 2009 +0200 +++ b/cwconfig.py Tue Jul 28 21:14:47 2009 +0200 @@ -22,6 +22,7 @@ from os.path import exists, join, expanduser, abspath, normpath, basename, isdir from logilab.common.decorators import cached +from logilab.common.deprecation import deprecated_function from logilab.common.logging_ext import set_log_methods, init_log from logilab.common.configuration import (Configuration, Method, ConfigurationMixIn, merge_options) @@ -149,7 +150,7 @@ CUBES_DIR = '%(APYCOT_ROOT)s/local/share/cubicweb/cubes/' % os.environ # create __init__ file file(join(CUBES_DIR, '__init__.py'), 'w').close() - elif exists(join(CW_SOFTWARE_ROOT, '.hg')): + elif exists(join(CW_SOFTWARE_ROOT, '.hg')) or os.environ.get('CW_MODE') == 'user': mode = 'dev' CUBES_DIR = abspath(normpath(join(CW_SOFTWARE_ROOT, '../cubes'))) else: @@ -221,7 +222,7 @@ 'group': 'appobjects', 'inputlevel': 2, }), ) - # static and class methods used to get application independant resources ## + # static and class methods used to get instance independant resources ## @staticmethod def cubicweb_version(): @@ -247,7 +248,7 @@ @classmethod def i18n_lib_dir(cls): - """return application's i18n directory""" + """return instance's i18n directory""" if cls.mode in ('dev', 'test') and not os.environ.get('APYCOT_ROOT'): return join(CW_SOFTWARE_ROOT, 'i18n') return join(cls.shared_dir(), 'i18n') @@ -424,7 +425,7 @@ @classmethod def build_vregistry_path(cls, templpath, evobjpath=None, tvobjpath=None): """given a list of directories, return a list of sub files and - directories that should be loaded by the application objects registry. + directories that should be loaded by the instance objects registry. :param evobjpath: optional list of sub-directories (or files without the .py ext) of @@ -539,8 +540,10 @@ # for some commands (creation...) we don't want to initialize gettext set_language = True - # set this to true to avoid false error message while creating an application + # set this to true to avoid false error message while creating an instance creating = False + # set this to true to allow somethings which would'nt be possible + repairing = False options = CubicWebNoAppConfiguration.options + ( ('log-file', @@ -564,7 +567,7 @@ }), ('sender-name', {'type' : 'string', - 'default': Method('default_application_id'), + 'default': Method('default_instance_id'), 'help': 'name used as HELO name for outgoing emails from the \ repository.', 'group': 'email', 'inputlevel': 2, @@ -581,49 +584,49 @@ @classmethod def runtime_dir(cls): """run time directory for pid file...""" - return env_path('CW_RUNTIME', cls.RUNTIME_DIR, 'run time') + return env_path('CW_RUNTIME_DIR', cls.RUNTIME_DIR, 'run time') @classmethod def registry_dir(cls): """return the control directory""" - return env_path('CW_REGISTRY', cls.REGISTRY_DIR, 'registry') + return env_path('CW_INSTANCES_DIR', cls.REGISTRY_DIR, 'registry') @classmethod def instance_data_dir(cls): """return the instance data directory""" - return env_path('CW_INSTANCE_DATA', + return env_path('CW_INSTANCES_DATA_DIR', cls.INSTANCE_DATA_DIR or cls.REGISTRY_DIR, 'additional data') @classmethod def migration_scripts_dir(cls): """cubicweb migration scripts directory""" - return env_path('CW_MIGRATION', cls.MIGRATION_DIR, 'migration') + return env_path('CW_MIGRATION_DIR', cls.MIGRATION_DIR, 'migration') @classmethod def config_for(cls, appid, config=None): - """return a configuration instance for the given application identifier + """return a configuration instance for the given instance identifier """ - config = config or guess_configuration(cls.application_home(appid)) + config = config or guess_configuration(cls.instance_home(appid)) configcls = configuration_cls(config) return configcls(appid) @classmethod def possible_configurations(cls, appid): """return the name of possible configurations for the given - application id + instance id """ - home = cls.application_home(appid) + home = cls.instance_home(appid) return possible_configurations(home) @classmethod - def application_home(cls, appid): - """return the home directory of the application with the given - application id + def instance_home(cls, appid): + """return the home directory of the instance with the given + instance id """ home = join(cls.registry_dir(), appid) if not exists(home): - raise ConfigurationError('no such application %s (check it exists with "cubicweb-ctl list")' % appid) + raise ConfigurationError('no such instance %s (check it exists with "cubicweb-ctl list")' % appid) return home MODES = ('common', 'repository', 'Any', 'web') @@ -637,14 +640,14 @@ # default configuration methods ########################################### - def default_application_id(self): - """return the application identifier, useful for option which need this + def default_instance_id(self): + """return the instance identifier, useful for option which need this as default value """ return self.appid def default_log_file(self): - """return default path to the log file of the application'server""" + """return default path to the log file of the instance'server""" if self.mode == 'dev': basepath = '/tmp/%s-%s' % (basename(self.appid), self.name) path = basepath + '.log' @@ -660,10 +663,10 @@ return '/var/log/cubicweb/%s-%s.log' % (self.appid, self.name) def default_pid_file(self): - """return default path to the pid file of the application'server""" + """return default path to the pid file of the instance'server""" return join(self.runtime_dir(), '%s-%s.pid' % (self.appid, self.name)) - # instance methods used to get application specific resources ############# + # instance methods used to get instance specific resources ############# def __init__(self, appid): self.appid = appid @@ -722,7 +725,7 @@ self._cubes = self.reorder_cubes(list(self._cubes) + cubes) def main_config_file(self): - """return application's control configuration file""" + """return instance's control configuration file""" return join(self.apphome, '%s.conf' % self.name) def save(self): @@ -739,7 +742,7 @@ return md5.new(';'.join(infos)).hexdigest() def load_site_cubicweb(self): - """load (web?) application's specific site_cubicweb file""" + """load instance's specific site_cubicweb file""" for path in reversed([self.apphome] + self.cubes_path()): sitefile = join(path, 'site_cubicweb.py') if exists(sitefile) and not sitefile in self._site_loaded: @@ -762,7 +765,7 @@ self.load_defaults() def load_configuration(self): - """load application's configuration files""" + """load instance's configuration files""" super(CubicWebConfiguration, self).load_configuration() if self.apphome and self.set_language: # init gettext @@ -781,7 +784,7 @@ logging.fileConfig(logconfig) def available_languages(self, *args): - """return available translation for an application, by looking for + """return available translation for an instance, by looking for compiled catalog take *args to be usable as a vocabulary method @@ -861,6 +864,6 @@ set_log_methods(CubicWebConfiguration, logging.getLogger('cubicweb.configuration')) -# alias to get a configuration instance from an application id -application_configuration = CubicWebConfiguration.config_for - +# alias to get a configuration instance from an instance id +instance_configuration = CubicWebConfiguration.config_for +application_configuration = deprecated_function(instance_configuration, 'use instance_configuration') diff -r 73c83c14dd2c -r 6f8ffaa2a700 cwctl.py --- a/cwctl.py Tue Jul 28 21:11:10 2009 +0200 +++ b/cwctl.py Tue Jul 28 21:14:47 2009 +0200 @@ -1,6 +1,6 @@ """%%prog %s [options] %s -CubicWeb main applications controller. +CubicWeb main instances controller. :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses %s""" @@ -45,11 +45,11 @@ return modes -class ApplicationCommand(Command): - """base class for command taking 0 to n application id as arguments - (0 meaning all registered applications) +class InstanceCommand(Command): + """base class for command taking 0 to n instance id as arguments + (0 meaning all registered instances) """ - arguments = '[...]' + arguments = '[...]' options = ( ("force", {'short': 'f', 'action' : 'store_true', @@ -84,7 +84,7 @@ return allinstances def run(self, args): - """run the _method on each argument (a list of application + """run the _method on each argument (a list of instance identifiers) """ if not args: @@ -102,29 +102,29 @@ for appid in args: if askconfirm: print '*'*72 - if not confirm('%s application %r ?' % (self.name, appid)): + if not confirm('%s instance %r ?' % (self.name, appid)): continue self.run_arg(appid) def run_arg(self, appid): - cmdmeth = getattr(self, '%s_application' % self.name) + cmdmeth = getattr(self, '%s_instance' % self.name) try: cmdmeth(appid) except (KeyboardInterrupt, SystemExit): print >> sys.stderr, '%s aborted' % self.name sys.exit(2) # specific error code except (ExecutionError, ConfigurationError), ex: - print >> sys.stderr, 'application %s not %s: %s' % ( + print >> sys.stderr, 'instance %s not %s: %s' % ( appid, self.actionverb, ex) except Exception, ex: import traceback traceback.print_exc() - print >> sys.stderr, 'application %s not %s: %s' % ( + print >> sys.stderr, 'instance %s not %s: %s' % ( appid, self.actionverb, ex) -class ApplicationCommandFork(ApplicationCommand): - """Same as `ApplicationCommand`, but command is forked in a new environment +class InstanceCommandFork(InstanceCommand): + """Same as `InstanceCommand`, but command is forked in a new environment for each argument """ @@ -136,7 +136,7 @@ for appid in args: if askconfirm: print '*'*72 - if not confirm('%s application %r ?' % (self.name, appid)): + if not confirm('%s instance %r ?' % (self.name, appid)): continue if forkcmd: status = system('%s %s' % (forkcmd, appid)) @@ -148,10 +148,9 @@ # base commands ############################################################### class ListCommand(Command): - """List configurations, componants and applications. + """List configurations, cubes and instances. - list available configurations, installed web and server componants, and - registered applications + list available configurations, installed cubes, and registered instances """ name = 'list' options = ( @@ -206,30 +205,30 @@ try: regdir = cwcfg.registry_dir() except ConfigurationError, ex: - print 'No application available:', ex + print 'No instance available:', ex print return instances = list_instances(regdir) if instances: - print 'Available applications (%s):' % regdir + print 'Available instances (%s):' % regdir for appid in instances: modes = cwcfg.possible_configurations(appid) if not modes: - print '* %s (BROKEN application, no configuration found)' % appid + print '* %s (BROKEN instance, no configuration found)' % appid continue print '* %s (%s)' % (appid, ', '.join(modes)) try: config = cwcfg.config_for(appid, modes[0]) except Exception, exc: - print ' (BROKEN application, %s)' % exc + print ' (BROKEN instance, %s)' % exc continue else: - print 'No application available in %s' % regdir + print 'No instance available in %s' % regdir print -class CreateApplicationCommand(Command): - """Create an application from a cube. This is an unified +class CreateInstanceCommand(Command): + """Create an instance from a cube. This is an unified command which can handle web / server / all-in-one installation according to available parts of the software library and of the desired cube. @@ -238,11 +237,11 @@ the name of cube to use (list available cube names using the "list" command). You can use several cubes by separating them using comma (e.g. 'jpl,eemail') - - an identifier for the application to create + + an identifier for the instance to create """ name = 'create' - arguments = ' ' + arguments = ' ' options = ( ("config-level", {'short': 'l', 'type' : 'int', 'metavar': '', @@ -255,7 +254,7 @@ {'short': 'c', 'type' : 'choice', 'metavar': '', 'choices': ('all-in-one', 'repository', 'twisted'), 'default': 'all-in-one', - 'help': 'installation type, telling which part of an application \ + 'help': 'installation type, telling which part of an instance \ should be installed. You can list available configurations using the "list" \ command. Default to "all-in-one", e.g. an installation embedding both the RQL \ repository and the web server.', @@ -285,13 +284,13 @@ print '\navailable cubes:', print ', '.join(cwcfg.available_cubes()) return - # create the registry directory for this application - print '\n'+underline_title('Creating the application %s' % appid) + # create the registry directory for this instance + print '\n'+underline_title('Creating the instance %s' % appid) create_dir(config.apphome) # load site_cubicweb from the cubes dir (if any) config.load_site_cubicweb() # cubicweb-ctl configuration - print '\n'+underline_title('Configuring the application (%s.conf)' % configname) + print '\n'+underline_title('Configuring the instance (%s.conf)' % configname) config.input_config('main', self.config.config_level) # configuration'specific stuff print @@ -311,9 +310,10 @@ 'continue anyway ?'): print 'creation not completed' return - # create the additional data directory for this application + # create the additional data directory for this instance if config.appdatahome != config.apphome: # true in dev mode create_dir(config.appdatahome) + create_dir(join(config.appdatahome, 'backup')) if config['uid']: from logilab.common.shellutils import chown # this directory should be owned by the uid of the server process @@ -323,18 +323,18 @@ helper.postcreate() -class DeleteApplicationCommand(Command): - """Delete an application. Will remove application's files and +class DeleteInstanceCommand(Command): + """Delete an instance. Will remove instance's files and unregister it. """ name = 'delete' - arguments = '' + arguments = '' options = () def run(self, args): """run the command with its specific arguments""" - appid = pop_arg(args, msg="No application specified !") + appid = pop_arg(args, msg="No instance specified !") configs = [cwcfg.config_for(appid, configname) for configname in cwcfg.possible_configurations(appid)] if not configs: @@ -353,16 +353,16 @@ if ex.errno != errno.ENOENT: raise confignames = ', '.join([config.name for config in configs]) - print 'application %s (%s) deleted' % (appid, confignames) + print '-> instance %s (%s) deleted.' % (appid, confignames) -# application commands ######################################################## +# instance commands ######################################################## -class StartApplicationCommand(ApplicationCommand): - """Start the given applications. If no application is given, start them all. +class StartInstanceCommand(InstanceCommand): + """Start the given instances. If no instance is given, start them all. - ... - identifiers of the applications to start. If no application is + ... + identifiers of the instances to start. If no instance is given, start them all. """ name = 'start' @@ -374,7 +374,7 @@ ("force", {'short': 'f', 'action' : 'store_true', 'default': False, - 'help': 'start the application even if it seems to be already \ + 'help': 'start the instance even if it seems to be already \ running.'}), ('profile', {'short': 'P', 'type' : 'string', 'metavar': '', @@ -383,8 +383,8 @@ }), ) - def start_application(self, appid): - """start the application's server""" + def start_instance(self, appid): + """start the instance's server""" # use get() since start may be used from other commands (eg upgrade) # without all options defined debug = self.get('debug') @@ -403,31 +403,31 @@ print "starting server with command :" print command if system(command): - print 'an error occured while starting the application, not started' + print 'an error occured while starting the instance, not started' print return False if not debug: - print 'application %s started' % appid + print '-> instance %s started.' % appid return True -class StopApplicationCommand(ApplicationCommand): - """Stop the given applications. +class StopInstanceCommand(InstanceCommand): + """Stop the given instances. - ... - identifiers of the applications to stop. If no application is + ... + identifiers of the instances to stop. If no instance is given, stop them all. """ name = 'stop' actionverb = 'stopped' def ordered_instances(self): - instances = super(StopApplicationCommand, self).ordered_instances() + instances = super(StopInstanceCommand, self).ordered_instances() instances.reverse() return instances - def stop_application(self, appid): - """stop the application's server""" + def stop_instance(self, appid): + """stop the instance's server""" config = cwcfg.config_for(appid) helper = self.config_helper(config, cmdname='stop') helper.poststop() # do this anyway @@ -458,15 +458,15 @@ except OSError: # already removed by twistd pass - print 'application %s stopped' % appid + print 'instance %s stopped' % appid -class RestartApplicationCommand(StartApplicationCommand, - StopApplicationCommand): - """Restart the given applications. +class RestartInstanceCommand(StartInstanceCommand, + StopInstanceCommand): + """Restart the given instances. - ... - identifiers of the applications to restart. If no application is + ... + identifiers of the instances to restart. If no instance is given, restart them all. """ name = 'restart' @@ -476,18 +476,18 @@ regdir = cwcfg.registry_dir() if not isfile(join(regdir, 'startorder')) or len(args) <= 1: # no specific startorder - super(RestartApplicationCommand, self).run_args(args, askconfirm) + super(RestartInstanceCommand, self).run_args(args, askconfirm) return print ('some specific start order is specified, will first stop all ' - 'applications then restart them.') + 'instances then restart them.') # get instances in startorder stopped = [] for appid in args: if askconfirm: print '*'*72 - if not confirm('%s application %r ?' % (self.name, appid)): + if not confirm('%s instance %r ?' % (self.name, appid)): continue - self.stop_application(appid) + self.stop_instance(appid) stopped.append(appid) forkcmd = [w for w in sys.argv if not w in args] forkcmd[1] = 'start' @@ -497,46 +497,46 @@ if status: sys.exit(status) - def restart_application(self, appid): - self.stop_application(appid) - if self.start_application(appid): - print 'application %s %s' % (appid, self.actionverb) + def restart_instance(self, appid): + self.stop_instance(appid) + if self.start_instance(appid): + print 'instance %s %s' % (appid, self.actionverb) -class ReloadConfigurationCommand(RestartApplicationCommand): - """Reload the given applications. This command is equivalent to a +class ReloadConfigurationCommand(RestartInstanceCommand): + """Reload the given instances. This command is equivalent to a restart for now. - ... - identifiers of the applications to reload. If no application is + ... + identifiers of the instances to reload. If no instance is given, reload them all. """ name = 'reload' - def reload_application(self, appid): - self.restart_application(appid) + def reload_instance(self, appid): + self.restart_instance(appid) -class StatusCommand(ApplicationCommand): - """Display status information about the given applications. +class StatusCommand(InstanceCommand): + """Display status information about the given instances. - ... - identifiers of the applications to status. If no application is - given, get status information about all registered applications. + ... + identifiers of the instances to status. If no instance is + given, get status information about all registered instances. """ name = 'status' options = () @staticmethod - def status_application(appid): - """print running status information for an application""" + def status_instance(appid): + """print running status information for an instance""" for mode in cwcfg.possible_configurations(appid): config = cwcfg.config_for(appid, mode) print '[%s-%s]' % (appid, mode), try: pidf = config['pid-file'] except KeyError: - print 'buggy application, pid file not specified' + print 'buggy instance, pid file not specified' continue if not exists(pidf): print "doesn't seem to be running" @@ -551,22 +551,22 @@ print "running with pid %s" % (pid) -class UpgradeApplicationCommand(ApplicationCommandFork, - StartApplicationCommand, - StopApplicationCommand): - """Upgrade an application after cubicweb and/or component(s) upgrade. +class UpgradeInstanceCommand(InstanceCommandFork, + StartInstanceCommand, + StopInstanceCommand): + """Upgrade an instance after cubicweb and/or component(s) upgrade. For repository update, you will be prompted for a login / password to use to connect to the system database. For some upgrades, the given user should have create or alter table permissions. - ... - identifiers of the applications to upgrade. If no application is + ... + identifiers of the instances to upgrade. If no instance is given, upgrade them all. """ name = 'upgrade' actionverb = 'upgraded' - options = ApplicationCommand.options + ( + options = InstanceCommand.options + ( ('force-componant-version', {'short': 't', 'type' : 'csv', 'metavar': 'cube1=X.Y.Z,cube2=X.Y.Z', 'default': None, @@ -584,7 +584,7 @@ ('nostartstop', {'short': 'n', 'action' : 'store_true', 'default': False, - 'help': 'don\'t try to stop application before migration and to restart it after.'}), + 'help': 'don\'t try to stop instance before migration and to restart it after.'}), ('verbosity', {'short': 'v', 'type' : 'int', 'metavar': '<0..2>', @@ -595,7 +595,7 @@ ('backup-db', {'short': 'b', 'type' : 'yn', 'metavar': '', 'default': None, - 'help': "Backup the application database before upgrade.\n"\ + 'help': "Backup the instance database before upgrade.\n"\ "If the option is ommitted, confirmation will be ask.", }), @@ -610,25 +610,24 @@ ) def ordered_instances(self): - # need this since mro return StopApplicationCommand implementation - return ApplicationCommand.ordered_instances(self) + # need this since mro return StopInstanceCommand implementation + return InstanceCommand.ordered_instances(self) - def upgrade_application(self, appid): + def upgrade_instance(self, appid): + print '\n' + underline_title('Upgrading the instance %s' % appid) from logilab.common.changelog import Version config = cwcfg.config_for(appid) - config.creating = True # notice we're not starting the server + config.repairing = True # notice we're not starting the server config.verbosity = self.config.verbosity try: config.set_sources_mode(self.config.ext_sources or ('migration',)) except AttributeError: # not a server config pass - # get application and installed versions for the server and the componants - print 'getting versions configuration from the repository...' + # get instance and installed versions for the server and the componants mih = config.migration_handler() repo = mih.repo_connect() vcconf = repo.get_versions() - print 'done' if self.config.force_componant_version: packversions = {} for vdef in self.config.force_componant_version: @@ -654,13 +653,13 @@ if cubicwebversion > applcubicwebversion: toupgrade.append(('cubicweb', applcubicwebversion, cubicwebversion)) if not self.config.fs_only and not toupgrade: - print 'no software migration needed for application %s' % appid + print '-> no software migration needed for instance %s.' % appid return for cube, fromversion, toversion in toupgrade: - print '**** %s migration %s -> %s' % (cube, fromversion, toversion) + print '-> migration needed from %s to %s for %s' % (fromversion, toversion, cube) # only stop once we're sure we have something to do if not (cwcfg.mode == 'dev' or self.config.nostartstop): - self.stop_application(appid) + self.stop_instance(appid) # run cubicweb/componants migration scripts mih.migrate(vcconf, reversed(toupgrade), self.config) # rewrite main configuration file @@ -675,15 +674,15 @@ errors = config.i18ncompile(langs) if errors: print '\n'.join(errors) - if not confirm('error while compiling message catalogs, ' + if not confirm('Error while compiling message catalogs, ' 'continue anyway ?'): - print 'migration not completed' + print '-> migration not completed.' return mih.shutdown() print - print 'application migrated' + print '-> instance migrated.' if not (cwcfg.mode == 'dev' or self.config.nostartstop): - self.start_application(appid) + self.start_instance(appid) print @@ -693,11 +692,11 @@ argument may be given corresponding to a file containing commands to execute in batch mode. - - the identifier of the application to connect. + + the identifier of the instance to connect. """ name = 'shell' - arguments = ' [batch command file]' + arguments = ' [batch command file]' options = ( ('system-only', {'short': 'S', 'action' : 'store_true', @@ -717,7 +716,7 @@ ) def run(self, args): - appid = pop_arg(args, 99, msg="No application specified !") + appid = pop_arg(args, 99, msg="No instance specified !") config = cwcfg.config_for(appid) if self.config.ext_sources: assert not self.config.system_only @@ -736,18 +735,18 @@ mih.shutdown() -class RecompileApplicationCatalogsCommand(ApplicationCommand): - """Recompile i18n catalogs for applications. +class RecompileInstanceCatalogsCommand(InstanceCommand): + """Recompile i18n catalogs for instances. - ... - identifiers of the applications to consider. If no application is - given, recompile for all registered applications. + ... + identifiers of the instances to consider. If no instance is + given, recompile for all registered instances. """ name = 'i18ninstance' @staticmethod - def i18ninstance_application(appid): - """recompile application's messages catalogs""" + def i18ninstance_instance(appid): + """recompile instance's messages catalogs""" config = cwcfg.config_for(appid) try: config.bootstrap_cubes() @@ -756,8 +755,8 @@ if ex.errno != errno.ENOENT: raise # bootstrap_cubes files doesn't exist - # set creating to notify this is not a regular start - config.creating = True + # notify this is not a regular start + config.repairing = True # create an in-memory repository, will call config.init_cubes() config.repository() except AttributeError: @@ -791,16 +790,16 @@ print cube register_commands((ListCommand, - CreateApplicationCommand, - DeleteApplicationCommand, - StartApplicationCommand, - StopApplicationCommand, - RestartApplicationCommand, + CreateInstanceCommand, + DeleteInstanceCommand, + StartInstanceCommand, + StopInstanceCommand, + RestartInstanceCommand, ReloadConfigurationCommand, StatusCommand, - UpgradeApplicationCommand, + UpgradeInstanceCommand, ShellCommand, - RecompileApplicationCatalogsCommand, + RecompileInstanceCatalogsCommand, ListInstancesCommand, ListCubesCommand, )) diff -r 73c83c14dd2c -r 6f8ffaa2a700 cwvreg.py --- a/cwvreg.py Tue Jul 28 21:11:10 2009 +0200 +++ b/cwvreg.py Tue Jul 28 21:14:47 2009 +0200 @@ -9,6 +9,7 @@ _ = unicode from logilab.common.decorators import cached, clear_cache +from logilab.common.deprecation import obsolete from rql import RQLHelper @@ -39,7 +40,26 @@ class CubicWebRegistry(VRegistry): - """extend the generic VRegistry with some cubicweb specific stuff""" + """Central registry for the cubicweb instance, extending the generic + VRegistry with some cubicweb specific stuff. + + This is one of the central object in cubicweb instance, coupling + dynamically loaded objects with the schema and the configuration objects. + + It specializes the VRegistry by adding some convenience methods to access to + stored objects. Currently we have the following registries of objects known + by the web instance (library may use some others additional registries): + + * etypes + * views + * components + * actions + * forms + * formrenderers + * controllers, which are directly plugged into the application + object to handle request publishing XXX to merge with views + * contentnavigation XXX to merge with components? to kill? + """ def __init__(self, config, debug=None, initlog=True): if initlog: @@ -71,7 +91,7 @@ self.register_property(key, **propdef) def set_schema(self, schema): - """set application'schema and load application objects""" + """set instance'schema and load application objects""" self.schema = schema clear_cache(self, 'rqlhelper') # now we can load application's web objects @@ -175,7 +195,7 @@ """ etype = str(etype) if etype == 'Any': - return self.select(self.registry_objects('etypes', 'Any'), 'Any') + return self.select('etypes', 'Any', 'Any') eschema = self.schema.eschema(etype) baseschemas = [eschema] + eschema.ancestors() # browse ancestors from most specific to most generic and @@ -186,42 +206,47 @@ except KeyError: btype = str(baseschema) try: - cls = self.select(self.registry_objects('etypes', btype), etype) + cls = self.select('etypes', btype, etype) break except ObjectNotFound: pass else: # no entity class for any of the ancestors, fallback to the default # one - cls = self.select(self.registry_objects('etypes', 'Any'), etype) + cls = self.select('etypes', 'Any', etype) return cls - def render(self, registry, oid, req, **context): - """select an object in a given registry and render it - - - registry: the registry's name - - oid : the view to call - - req : the HTTP request + def render(self, __oid, req, __fallback_oid=None, __registry='views', + rset=None, **kwargs): + """select object, or fallback object if specified and the first one + isn't selectable, then render it """ - objclss = self.registry_objects(registry, oid) try: - rset = context.pop('rset') - except KeyError: - rset = None - selected = self.select(objclss, req, rset, **context) - return selected.render(**context) + obj = self.select(__registry, __oid, req, rset=rset, **kwargs) + except NoSelectableObject: + if __fallback_oid is None: + raise + obj = self.select(__registry, __fallback_oid, req, rset=rset, + **kwargs) + return obj.render(**kwargs) def main_template(self, req, oid='main-template', **context): """display query by calling the given template (default to main), and returning the output as a string instead of requiring the [w]rite method as argument """ - res = self.render('views', oid, req, **context) + res = self.render(oid, req, **context) if isinstance(res, unicode): return res.encode(req.encoding) assert isinstance(res, str) return res + def select_vobject(self, registry, oid, *args, **kwargs): + selected = self.select_object(registry, oid, *args, **kwargs) + if selected and selected.propval('visible'): + return selected + return None + def possible_vobjects(self, registry, *args, **kwargs): """return an ordered list of possible app objects in a given registry, supposing they support the 'visible' and 'order' properties (as most @@ -231,9 +256,9 @@ key=lambda x: x.propval('order')) if x.propval('visible')] - def possible_actions(self, req, rset, **kwargs): + def possible_actions(self, req, rset=None, **kwargs): if rset is None: - actions = self.possible_vobjects('actions', req, rset, **kwargs) + actions = self.possible_vobjects('actions', req, rset=rset, **kwargs) else: actions = rset.possible_actions(**kwargs) # cached implementation result = {} @@ -241,7 +266,7 @@ result.setdefault(action.category, []).append(action) return result - def possible_views(self, req, rset, **kwargs): + def possible_views(self, req, rset=None, **kwargs): """return an iterator on possible views for this result set views returned are classes, not instances @@ -250,50 +275,34 @@ if vid[0] == '_': continue try: - view = self.select(views, req, rset, **kwargs) + view = self.select_best(views, req, rset=rset, **kwargs) if view.linkable(): yield view except NoSelectableObject: continue except Exception: - self.exception('error while trying to list possible %s views for %s', + self.exception('error while trying to select %s view for %s', vid, rset) - def view(self, __vid, req, rset=None, __fallback_vid=None, **kwargs): - """shortcut to self.vreg.render method avoiding to pass self.req""" - try: - view = self.select_view(__vid, req, rset, **kwargs) - except NoSelectableObject: - if __fallback_vid is None: - raise - view = self.select_view(__fallback_vid, req, rset, **kwargs) - return view.render(**kwargs) - + @obsolete("use .select_object('boxes', ...)") def select_box(self, oid, *args, **kwargs): """return the most specific view according to the result set""" - try: - return self.select_object('boxes', oid, *args, **kwargs) - except NoSelectableObject: - return + return self.select_object('boxes', oid, *args, **kwargs) + @obsolete("use .select_object('components', ...)") + def select_component(self, cid, *args, **kwargs): + """return the most specific component according to the result set""" + return self.select_object('components', cid, *args, **kwargs) + + @obsolete("use .select_object('actions', ...)") def select_action(self, oid, *args, **kwargs): """return the most specific view according to the result set""" - try: - return self.select_object('actions', oid, *args, **kwargs) - except NoSelectableObject: - return + return self.select_object('actions', oid, *args, **kwargs) - def select_component(self, cid, *args, **kwargs): - """return the most specific component according to the result set""" - try: - return self.select_object('components', cid, *args, **kwargs) - except (NoSelectableObject, ObjectNotFound): - return - + @obsolete("use .select('views', ...)") def select_view(self, __vid, req, rset=None, **kwargs): """return the most specific view according to the result set""" - views = self.registry_objects('views', __vid) - return self.select(views, req, rset, **kwargs) + return self.select('views', __vid, req, rset=rset, **kwargs) # properties handling ##################################################### @@ -388,7 +397,7 @@ """special registry to be used when an application has to deal with connections to differents repository. This class add some additional wrapper trying to hide buggy class attributes since classes are not designed to be - shared. + shared among multiple registries. """ def etype_class(self, etype): """return an entity class for the given entity type. @@ -401,25 +410,27 @@ usercls.e_schema = self.schema.eschema(etype) return usercls - def select(self, vobjects, *args, **kwargs): + def select_best(self, vobjects, *args, **kwargs): """return an instance of the most specific object according to parameters - raise NoSelectableObject if not object apply + raise NoSelectableObject if no object apply """ - for vobject in vobjects: - vobject.vreg = self - vobject.schema = self.schema - vobject.config = self.config - selected = super(MulCnxCubicWebRegistry, self).select(vobjects, *args, - **kwargs) + for vobjectcls in vobjects: + self._fix_cls_attrs(vobjectcls) + selected = super(MulCnxCubicWebRegistry, self).select_best( + vobjects, *args, **kwargs) # redo the same thing on the instance so it won't use equivalent class # attributes (which may change) - selected.vreg = self - selected.schema = self.schema - selected.config = self.config + self._fix_cls_attrs(selected) return selected + def _fix_cls_attrs(self, vobject): + vobject.vreg = self + vobject.schema = self.schema + vobject.config = self.config + + from datetime import datetime, date, time, timedelta YAMS_TO_PY = { diff -r 73c83c14dd2c -r 6f8ffaa2a700 dbapi.py --- a/dbapi.py Tue Jul 28 21:11:10 2009 +0200 +++ b/dbapi.py Tue Jul 28 21:14:47 2009 +0200 @@ -13,6 +13,7 @@ from logging import getLogger from time import time, clock +from itertools import count from logilab.common.logging_ext import set_log_methods from cubicweb import ETYPE_NAME_MAP, ConnectionError, RequestSessionMixIn @@ -21,6 +22,12 @@ _MARKER = object() +def _fake_property_value(self, name): + try: + return super(dbapi.DBAPIRequest, self).property_value(name) + except KeyError: + return '' + class ConnectionProperties(object): def __init__(self, cnxtype=None, lang=None, close=True, log=False): self.cnxtype = cnxtype or 'pyro' @@ -60,7 +67,7 @@ raise ConnectionError('Could not get repository for %s ' '(not registered in Pyro), ' 'you may have to restart your server-side ' - 'application' % nsid) + 'instance' % nsid) return core.getProxyForURI(uri) def repo_connect(repo, login, password, cnxprops=None): @@ -394,7 +401,8 @@ raise ProgrammingError('Closed connection') return self._repo.get_schema() - def load_vobjects(self, cubes=_MARKER, subpath=None, expand=True, force_reload=None): + def load_vobjects(self, cubes=_MARKER, subpath=None, expand=True, + force_reload=None): config = self.vreg.config if cubes is _MARKER: cubes = self._repo.get_cubes() @@ -422,10 +430,35 @@ hm, config = self._repo.hm, self._repo.config hm.set_schema(hm.schema) # reset structure hm.register_system_hooks(config) - # application specific hooks - if self._repo.config.application_hooks: + # instance specific hooks + if self._repo.config.instance_hooks: hm.register_hooks(config.load_hooks(self.vreg)) + def use_web_compatible_requests(self, baseurl, sitetitle=None): + """monkey patch DBAPIRequest to fake a cw.web.request, so you should + able to call html views using rset from a simple dbapi connection. + + You should call `load_vobjects` at some point to register those views. + """ + from cubicweb.web.request import CubicWebRequestBase as cwrb + DBAPIRequest.build_ajax_replace_url = cwrb.build_ajax_replace_url.im_func + DBAPIRequest.list_form_param = cwrb.list_form_param.im_func + DBAPIRequest.property_value = _fake_property_value + DBAPIRequest.next_tabindex = count().next + DBAPIRequest.form = {} + DBAPIRequest.data = {} + fake = lambda *args, **kwargs: None + DBAPIRequest.relative_path = fake + DBAPIRequest.url = fake + DBAPIRequest.next_tabindex = fake + DBAPIRequest.add_js = fake #cwrb.add_js.im_func + DBAPIRequest.add_css = fake #cwrb.add_css.im_func + # XXX could ask the repo for it's base-url configuration + self.vreg.config.set_option('base-url', baseurl) + # XXX why is this needed? if really needed, could be fetched by a query + if sitetitle is not None: + self.vreg['propertydefs']['ui.site-title'] = {'default': sitetitle} + def source_defs(self): """Return the definition of sources used by the repository. diff -r 73c83c14dd2c -r 6f8ffaa2a700 debian/control --- a/debian/control Tue Jul 28 21:11:10 2009 +0200 +++ b/debian/control Tue Jul 28 21:14:47 2009 +0200 @@ -62,7 +62,7 @@ Architecture: all XB-Python-Version: ${python:Versions} Depends: ${python:Depends}, cubicweb-common (= ${source:Version}), python-simplejson (>= 1.3), python-elementtree -Recommends: python-docutils, python-vobject, fckeditor +Recommends: python-docutils, python-vobject, fckeditor, python-fyzz Description: web interface library for the CubicWeb framework CubicWeb is a semantic web application framework. . @@ -76,8 +76,8 @@ Package: cubicweb-common Architecture: all XB-Python-Version: ${python:Versions} -Depends: ${python:Depends}, graphviz, gettext, python-logilab-mtconverter (>= 0.6.0), python-logilab-common (>= 0.43.0), python-yams (>= 0.23.0), python-rql (>= 0.22.1) -Recommends: python-simpletal (>= 4.0), python-lxml +Depends: ${python:Depends}, graphviz, gettext, python-logilab-mtconverter (>= 0.6.0), python-logilab-common (>= 0.41.0), python-yams (>= 0.23.0), python-rql (>= 0.22.1), python-lxml +Recommends: python-simpletal (>= 4.0) Conflicts: cubicweb-core Replaces: cubicweb-core Description: common library for the CubicWeb framework diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/__init__.py --- a/devtools/__init__.py Tue Jul 28 21:11:10 2009 +0200 +++ b/devtools/__init__.py Tue Jul 28 21:14:47 2009 +0200 @@ -43,7 +43,7 @@ class TestServerConfiguration(ServerConfiguration): mode = 'test' set_language = False - read_application_schema = False + read_instance_schema = False bootstrap_schema = False init_repository = True options = merge_options(ServerConfiguration.options + ( @@ -77,12 +77,12 @@ def apphome(self): if exists(self.appid): return abspath(self.appid) - # application cube test + # cube test return abspath('..') appdatahome = apphome def main_config_file(self): - """return application's control configuration file""" + """return instance's control configuration file""" return join(self.apphome, '%s.conf' % self.name) def instance_md5_version(self): @@ -149,7 +149,7 @@ return ('en', 'fr', 'de') def ext_resources_file(self): - """return application's external resources file""" + """return instance's external resources file""" return join(self.apphome, 'data', 'external_resources') def pyro_enabled(self): @@ -235,14 +235,14 @@ # XXX I'm afraid this test will prevent to run test from a production # environment self._sources = None - # application cube test + # instance cube test if cube is not None: self.apphome = self.cube_dir(cube) elif 'web' in os.getcwd().split(os.sep): # web test self.apphome = join(normpath(join(dirname(__file__), '..')), 'web') else: - # application cube test + # cube test self.apphome = abspath('..') self.sourcefile = sourcefile self.global_set_option('realm', '') diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/_apptest.py --- a/devtools/_apptest.py Tue Jul 28 21:11:10 2009 +0200 +++ b/devtools/_apptest.py Tue Jul 28 21:14:47 2009 +0200 @@ -177,7 +177,7 @@ self.create_request(rql=rql, **optional_args or {})) def check_view(self, rql, vid, optional_args, template='main'): - """checks if vreg.view() raises an exception in this environment + """checks if rendering view raises an exception in this environment If any exception is raised in this method, it will be considered as a TestFailure @@ -186,7 +186,6 @@ template=template, optional_args=optional_args) def call_view(self, vid, rql, template='main', optional_args=None): - """shortcut for self.vreg.view()""" assert template if optional_args is None: optional_args = {} @@ -196,7 +195,7 @@ def call_edit(self, req): """shortcut for self.app.edit()""" - controller = self.app.select_controller('edit', req) + controller = self.vreg.select('controllers', 'edit', req) try: controller.publish() except Redirect: @@ -224,7 +223,7 @@ def iter_possible_actions(self, req, rset): """returns a list of possible vids for """ - for action in self.vreg.possible_vobjects('actions', req, rset): + for action in self.vreg.possible_vobjects('actions', req, rset=rset): yield action class ExistingTestEnvironment(TestEnvironment): diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/apptest.py --- a/devtools/apptest.py Tue Jul 28 21:11:10 2009 +0200 +++ b/devtools/apptest.py Tue Jul 28 21:14:47 2009 +0200 @@ -1,4 +1,4 @@ -"""This module provides misc utilities to test applications +"""This module provides misc utilities to test instances :organization: Logilab :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. @@ -34,6 +34,14 @@ def message(self): return message_from_string(self.msg) + @property + def subject(self): + return self.message.get('Subject') + + @property + def content(self): + return self.message.get_payload(decode=True) + def __repr__(self): return '' % (','.join(self.recipients), self.message.get('Subject')) @@ -51,7 +59,7 @@ def get_versions(self, checkversions=False): - """return the a dictionary containing cubes used by this application + """return the a dictionary containing cubes used by this instance as key with their version as value, including cubicweb version. This is a public method, not requiring a session id. @@ -219,18 +227,18 @@ return sorted((a.id, a.__class__) for a in self.vreg.possible_views(req, rset)) def pactions(self, req, rset, skipcategories=('addrelated', 'siteactions', 'useractions')): - return [(a.id, a.__class__) for a in self.vreg.possible_vobjects('actions', req, rset) + return [(a.id, a.__class__) for a in self.vreg.possible_vobjects('actions', req, rset=rset) if a.category not in skipcategories] def pactions_by_cats(self, req, rset, categories=('addrelated',)): - return [(a.id, a.__class__) for a in self.vreg.possible_vobjects('actions', req, rset) + return [(a.id, a.__class__) for a in self.vreg.possible_vobjects('actions', req, rset=rset) if a.category in categories] paddrelactions = deprecated_function(pactions_by_cats) def pactionsdict(self, req, rset, skipcategories=('addrelated', 'siteactions', 'useractions')): res = {} - for a in self.vreg.possible_vobjects('actions', req, rset): + for a in self.vreg.possible_vobjects('actions', req, rset=rset): if a.category not in skipcategories: res.setdefault(a.category, []).append(a.__class__) return res @@ -241,7 +249,7 @@ dump = simplejson.dumps args = [dump(arg) for arg in args] req = self.request(fname=fname, pageid='123', arg=args) - ctrl = self.env.app.select_controller('json', req) + ctrl = self.vreg.select('controllers', 'json', req) return ctrl.publish(), req # default test setup and teardown ######################################### @@ -286,7 +294,7 @@ def setUp(self): super(ControllerTC, self).setUp() self.req = self.request() - self.ctrl = self.env.app.select_controller('edit', self.req) + self.ctrl = self.vreg.select('controllers', 'edit', self.req) def publish(self, req): assert req is self.ctrl.req @@ -300,7 +308,7 @@ def expect_redirect_publish(self, req=None): if req is not None: - self.ctrl = self.env.app.select_controller('edit', req) + self.ctrl = self.vreg.select('controllers', 'edit', req) else: req = self.req try: @@ -398,7 +406,7 @@ rset.vreg = self.vreg rset.req = self.session # call to set_pool is necessary to avoid pb when using - # application entities for convenience + # instance entities for convenience self.session.set_pool() return rset diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/devctl.py --- a/devtools/devctl.py Tue Jul 28 21:11:10 2009 +0200 +++ b/devtools/devctl.py Tue Jul 28 21:14:47 2009 +0200 @@ -254,14 +254,13 @@ if args: raise BadCommandUsage('Too much arguments') import shutil - from tempfile import mktemp + import tempfile import yams from logilab.common.fileutils import ensure_fs_mode from logilab.common.shellutils import globfind, find, rm from cubicweb.common.i18n import extract_from_tal, execute - tempdir = mktemp() - mkdir(tempdir) - potfiles = [join(I18NDIR, 'entities.pot')] + tempdir = tempdir.mkdtemp() + potfiles = [join(I18NDIR, 'static-messages.pot')] print '-> extract schema messages.' schemapot = join(tempdir, 'schema.pot') potfiles.append(schemapot) @@ -328,8 +327,8 @@ def update_cubes_catalogs(cubes): - toedit = [] for cubedir in cubes: + toedit = [] if not isdir(cubedir): print '-> ignoring %s that is not a directory.' % cubedir continue @@ -338,26 +337,27 @@ except Exception: import traceback traceback.print_exc() - print '-> Error while updating catalogs for cube', cubedir - # instructions pour la suite - print '-> regenerated this cube\'s .po catalogs.' - print '\nYou can now edit the following files:' - print '* ' + '\n* '.join(toedit) - print 'when you are done, run "cubicweb-ctl i18ninstance yourinstance".' + print '-> error while updating catalogs for cube', cubedir + else: + # instructions pour la suite + print '-> regenerated .po catalogs for cube %s.' % cubedir + print '\nYou can now edit the following files:' + print '* ' + '\n* '.join(toedit) + print ('When you are done, run "cubicweb-ctl i18ninstance ' + '" to see changes in your instances.') def update_cube_catalogs(cubedir): import shutil - from tempfile import mktemp + import tempfile from logilab.common.fileutils import ensure_fs_mode from logilab.common.shellutils import find, rm from cubicweb.common.i18n import extract_from_tal, execute toedit = [] cube = basename(normpath(cubedir)) - tempdir = mktemp() - mkdir(tempdir) + tempdir = tempfile.mkdtemp() print underline_title('Updating i18n catalogs for cube %s' % cube) chdir(cubedir) - potfiles = [join('i18n', scfile) for scfile in ('entities.pot',) + potfiles = [join('i18n', scfile) for scfile in ('static-messages.pot',) if exists(join('i18n', scfile))] print '-> extract schema messages' schemapot = join(tempdir, 'schema.pot') diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/fake.py --- a/devtools/fake.py Tue Jul 28 21:11:10 2009 +0200 +++ b/devtools/fake.py Tue Jul 28 21:14:47 2009 +0200 @@ -49,8 +49,7 @@ _registries = { 'controllers' : [Mock(id='view'), Mock(id='login'), Mock(id='logout'), Mock(id='edit')], - 'views' : [Mock(id='primary'), Mock(id='secondary'), - Mock(id='oneline'), Mock(id='list')], + 'views' : [Mock(id='primary'), Mock(id='oneline'), Mock(id='list')], } def registry_objects(self, name, oid=None): @@ -88,12 +87,12 @@ return None def base_url(self): - """return the root url of the application""" + """return the root url of the instance""" return BASE_URL def relative_path(self, includeparams=True): """return the normalized path of the request (ie at least relative - to the application's root, but some other normalization may be needed + to the instance's root, but some other normalization may be needed so that the returned path may be used to compare to generated urls """ if self._url.startswith(BASE_URL): @@ -154,6 +153,25 @@ return self.execute(*args, **kwargs) +# class FakeRequestNoCnx(FakeRequest): +# def get_session_data(self, key, default=None, pop=False): +# """return value associated to `key` in session data""" +# if pop: +# return self._session_data.pop(key, default) +# else: +# return self._session_data.get(key, default) + +# def set_session_data(self, key, value): +# """set value associated to `key` in session data""" +# self._session_data[key] = value + +# def del_session_data(self, key): +# try: +# del self._session_data[key] +# except KeyError: +# pass + + class FakeUser(object): login = 'toto' eid = 0 diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/fill.py --- a/devtools/fill.py Tue Jul 28 21:11:10 2009 +0200 +++ b/devtools/fill.py Tue Jul 28 21:14:47 2009 +0200 @@ -225,7 +225,7 @@ :param etype: the entity's type :type schema: cubicweb.schema.Schema - :param schema: the application schema + :param schema: the instance schema :type entity_num: int :param entity_num: the number of entities to insert @@ -325,7 +325,7 @@ def make_relations_queries(schema, edict, cursor, ignored_relations=(), existingrels=None): """returns a list of generated RQL queries for relations - :param schema: The application schema + :param schema: The instance schema :param e_dict: mapping between etypes and eids diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/pkginfo.py --- a/devtools/pkginfo.py Tue Jul 28 21:11:10 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -"""distutils / __pkginfo__ helpers for cubicweb applications - -:organization: Logilab -:copyright: 2001-2009 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 -""" - -import os -from os.path import isdir, join - - -def get_distutils_datafiles(cube, i18n=True, recursive=False): - """ - :param cube: application cube's name - """ - data_files = [] - data_files += get_basepyfiles(cube) - data_files += get_webdatafiles(cube) - if i18n: - data_files += get_i18nfiles(cube) - data_files += get_viewsfiles(cube, recursive=recursive) - data_files += get_migrationfiles(cube) - data_files += get_schemafiles(cube) - return data_files - - - -## listdir filter funcs ################################################ -def nopyc_and_nodir(fname): - if isdir(fname) or fname.endswith('.pyc') or fname.endswith('~'): - return False - return True - -def no_version_control(fname): - if fname in ('CVS', '.svn', '.hg'): - return False - if fname.endswith('~'): - return False - return True - -def basepy_files(fname): - if fname.endswith('.py') and fname != 'setup.py': - return True - return False - -def chain(*filters): - def newfilter(fname): - for filterfunc in filters: - if not filterfunc(fname): - return False - return True - return newfilter - -def listdir_with_path(path='.', filterfunc=None): - if filterfunc: - return [join(path, fname) for fname in os.listdir(path) if filterfunc(join(path, fname))] - else: - return [join(path, fname) for fname in os.listdir(path)] - - -## data_files helpers ################################################## -CUBES_DIR = join('share', 'cubicweb', 'cubes') - -def get_i18nfiles(cube): - """returns i18n files in a suitable format for distutils's - data_files parameter - """ - i18ndir = join(CUBES_DIR, cube, 'i18n') - potfiles = [(i18ndir, listdir_with_path('i18n', chain(no_version_control, nopyc_and_nodir)))] - return potfiles - - -def get_viewsfiles(cube, recursive=False): - """returns views files in a suitable format for distutils's - data_files parameter - - :param recursive: include views' subdirs recursively if True - """ - if recursive: - datafiles = [] - for dirpath, dirnames, filenames in os.walk('views'): - filenames = [join(dirpath, fname) for fname in filenames - if nopyc_and_nodir(join(dirpath, fname))] - dirpath = join(CUBES_DIR, cube, dirpath) - datafiles.append((dirpath, filenames)) - return datafiles - else: - viewsdir = join(CUBES_DIR, cube, 'views') - return [(viewsdir, - listdir_with_path('views', filterfunc=nopyc_and_nodir))] - - -def get_basepyfiles(cube): - """returns cube's base python scripts (tali18n.py, etc.) - in a suitable format for distutils's data_files parameter - """ - return [(join(CUBES_DIR, cube), - [fname for fname in os.listdir('.') - if fname.endswith('.py') and fname != 'setup.py'])] - - -def get_webdatafiles(cube): - """returns web's data files (css, png, js, etc.) in a suitable - format for distutils's data_files parameter - """ - return [(join(CUBES_DIR, cube, 'data'), - listdir_with_path('data', filterfunc=no_version_control))] - - -def get_migrationfiles(cube): - """returns cube's migration scripts - in a suitable format for distutils's data_files parameter - """ - return [(join(CUBES_DIR, cube, 'migration'), - listdir_with_path('migration', no_version_control))] - - -def get_schemafiles(cube): - """returns cube's schema files - in a suitable format for distutils's data_files parameter - """ - return [(join(CUBES_DIR, cube, 'schema'), - listdir_with_path('schema', no_version_control))] - - diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/stresstester.py --- a/devtools/stresstester.py Tue Jul 28 21:11:10 2009 +0200 +++ b/devtools/stresstester.py Tue Jul 28 21:14:47 2009 +0200 @@ -1,4 +1,4 @@ -""" Usage: %s [OPTIONS] +""" Usage: %s [OPTIONS] Stress test a CubicWeb repository @@ -151,8 +151,8 @@ user = raw_input('login: ') if password is None: password = getpass('password: ') - from cubicweb.cwconfig import application_configuration - config = application_configuration(args[0]) + from cubicweb.cwconfig import instance_configuration + config = instance_configuration(args[0]) # get local access to the repository print "Creating repo", prof_file repo = Repository(config, prof_file) diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/test/data/bootstrap_cubes --- a/devtools/test/data/bootstrap_cubes Tue Jul 28 21:11:10 2009 +0200 +++ b/devtools/test/data/bootstrap_cubes Tue Jul 28 21:14:47 2009 +0200 @@ -1,1 +1,1 @@ -person, comment +person diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/test/data/schema.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/devtools/test/data/schema.py Tue Jul 28 21:14:47 2009 +0200 @@ -0,0 +1,20 @@ +""" + +:organization: Logilab +:copyright: 2001-2009 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 +""" +from yams.buildobjs import EntityType, SubjectRelation, String, Int, Date + +from cubes.person.schema import Person + +Person.add_relation(Date(), 'birthday') + +class Bug(EntityType): + title = String(maxsize=64, required=True, fulltextindexed=True) + severity = String(vocabulary=('important', 'normal', 'minor'), default='normal') + cost = Int() + description = String(maxsize=4096, fulltextindexed=True) + identical_to = SubjectRelation('Bug', symetric=True) + diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/test/data/schema/Bug.sql --- a/devtools/test/data/schema/Bug.sql Tue Jul 28 21:11:10 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -title ivarchar(64) not null -state CHOICE('open', 'rejected', 'validation pending', 'resolved') default 'open' -severity CHOICE('important', 'normal', 'minor') default 'normal' -cost integer -description ivarchar(4096) diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/test/data/schema/Project.sql --- a/devtools/test/data/schema/Project.sql Tue Jul 28 21:11:10 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -name ivarchar(64) not null -summary ivarchar(128) -vcsurl varchar(256) -reporturl varchar(256) -description ivarchar(1024) -url varchar(128) diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/test/data/schema/Story.sql --- a/devtools/test/data/schema/Story.sql Tue Jul 28 21:11:10 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -title ivarchar(64) not null -state CHOICE('open', 'rejected', 'validation pending', 'resolved') default 'open' -priority CHOICE('minor', 'normal', 'important') default 'normal' -cost integer -description ivarchar(4096) diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/test/data/schema/Version.sql --- a/devtools/test/data/schema/Version.sql Tue Jul 28 21:11:10 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -num varchar(16) not null -diem date -status CHOICE('planned', 'dev', 'published') default 'planned' diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/test/data/schema/custom.py --- a/devtools/test/data/schema/custom.py Tue Jul 28 21:11:10 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -""" - -:organization: Logilab -:copyright: 2001-2009 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 -""" -Person = import_erschema('Person') -Person.add_relation(Date(), 'birthday') diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/test/data/schema/relations.rel --- a/devtools/test/data/schema/relations.rel Tue Jul 28 21:11:10 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -Bug concerns Project inline -Story concerns Project inline - -Bug corrected_in Version inline CONSTRAINT E concerns P, X version_of P -Story done_in Version inline CONSTRAINT E concerns P, X version_of P - -Bug identical_to Bug symetric -Bug identical_to Story symetric -Story identical_to Story symetric - -Story depends_on Story -Story depends_on Bug -Bug depends_on Story -Bug depends_on Bug - -Bug see_also Bug symetric -Bug see_also Story symetric -Bug see_also Project symetric -Story see_also Story symetric -Story see_also Project symetric -Project see_also Project symetric - -Project uses Project - -Version version_of Project inline -Version todo_by CWUser - -Comment about Bug inline -Comment about Story inline -Comment about Comment inline - -CWUser interested_in Project - diff -r 73c83c14dd2c -r 6f8ffaa2a700 devtools/testlib.py --- a/devtools/testlib.py Tue Jul 28 21:11:10 2009 +0200 +++ b/devtools/testlib.py Tue Jul 28 21:14:47 2009 +0200 @@ -44,7 +44,7 @@ # compute how many entities by type we need to be able to satisfy relation constraint relmap = {} for rschema in schema.relations(): - if rschema.meta or rschema.is_final(): # skip meta relations + if rschema.is_final(): continue for subj, obj in rschema.iter_rdefs(): card = rschema.rproperty(subj, obj, 'cardinality') @@ -172,7 +172,8 @@ return validator.parse_string(output.strip()) - def view(self, vid, rset, req=None, template='main-template', **kwargs): + def view(self, vid, rset=None, req=None, template='main-template', + **kwargs): """This method tests the view `vid` on `rset` using `template` If no error occured while rendering the view, the HTML is analyzed @@ -183,7 +184,8 @@ """ req = req or rset and rset.req or self.request() req.form['vid'] = vid - view = self.vreg.select_view(vid, req, rset, **kwargs) + kwargs['rset'] = rset + view = self.vreg.select('views', vid, req, **kwargs) # set explicit test description if rset is not None: self.set_description("testing %s, mod=%s (%s)" % ( @@ -194,9 +196,11 @@ if template is None: # raw view testing, no template viewfunc = view.render else: - templateview = self.vreg.select_view(template, req, rset, view=view, **kwargs) kwargs['view'] = view - viewfunc = lambda **k: self.vreg.main_template(req, template, **kwargs) + templateview = self.vreg.select('views', template, req, **kwargs) + viewfunc = lambda **k: self.vreg.main_template(req, template, + **kwargs) + kwargs.pop('rset') return self._test_view(viewfunc, view, template, kwargs) @@ -278,7 +282,7 @@ and not issubclass(view, NotificationView)] if views: try: - view = self.vreg.select(views, req, rset) + view = self.vreg.select_best(views, req, rset=rset) if view.linkable(): yield view else: @@ -291,13 +295,13 @@ def list_actions_for(self, rset): """returns the list of actions that can be applied on `rset`""" req = rset.req - for action in self.vreg.possible_objects('actions', req, rset): + for action in self.vreg.possible_objects('actions', req, rset=rset): yield action def list_boxes_for(self, rset): """returns the list of boxes that can be applied on `rset`""" req = rset.req - for box in self.vreg.possible_objects('boxes', req, rset): + for box in self.vreg.possible_objects('boxes', req, rset=rset): yield box def list_startup_views(self): @@ -383,9 +387,9 @@ requestcls=testclass.requestcls) vreg = env.vreg vreg._selected = {} - orig_select = vreg.__class__.select - def instr_select(self, *args, **kwargs): - selected = orig_select(self, *args, **kwargs) + orig_select_best = vreg.__class__.select_best + def instr_select_best(self, *args, **kwargs): + selected = orig_select_best(self, *args, **kwargs) try: self._selected[selected.__class__] += 1 except KeyError: @@ -393,7 +397,7 @@ except AttributeError: pass # occurs on vreg used to restore database return selected - vreg.__class__.select = instr_select + vreg.__class__.select_best = instr_select_best def print_untested_objects(testclass, skipregs=('hooks', 'etypes')): vreg = testclass._env.vreg diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/Z012-create-instance.en.txt --- a/doc/book/en/Z012-create-instance.en.txt Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/Z012-create-instance.en.txt Tue Jul 28 21:14:47 2009 +0200 @@ -8,14 +8,14 @@ -------------------- A *CubicWeb* instance is a container that -refers to cubes and configuration parameters for your web application. +refers to cubes and configuration parameters for your web instance. Each instance is stored as a directory in ``~/etc/cubicweb.d`` which enables -us to run your application. +us to run your instance. What is a cube? --------------- -Cubes represent data and basic building bricks of your web applications : +Cubes represent data and basic building bricks of your web instances : blogs, person, date, addressbook and a lot more. .. XXX They related to each other by a 'Schema' which is also the PostGres representation. @@ -35,7 +35,7 @@ ------------------------------------ We can create an instance to view our -application in a web browser. :: +instance in a web browser. :: cubicweb-ctl create blog myblog @@ -55,14 +55,14 @@ (:ref:`ConfigurationPostgres`). It is important to distinguish here the user used to access the database and -the user used to login to the cubicweb application. When a *CubicWeb* application +the user used to login to the cubicweb instance. When a *CubicWeb* instance starts, it uses the login/psswd for the database to get the schema and handle low level transaction. But, when ``cubicweb-ctl create`` asks for -a manager login/psswd of *CubicWeb*, it refers to an application user -to administrate your web application. +a manager login/psswd of *CubicWeb*, it refers to an instance user +to administrate your web instance. The configuration files are stored in *~/etc/cubicweb.d/myblog/*. -To launch the web application, you just type :: +To launch the web instance, you just type :: cubicweb-ctl start myblog diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/admin/create-instance.rst --- a/doc/book/en/admin/create-instance.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/admin/create-instance.rst Tue Jul 28 21:14:47 2009 +0200 @@ -7,7 +7,7 @@ ----------------- Now that we created our cube, we can create an instance to view our -application in a web browser. To do so we will use a `all-in-one` +instance in a web browser. To do so we will use a `all-in-one` configuration to simplify things :: cubicweb-ctl create -c all-in-one mycube myinstance @@ -24,12 +24,12 @@ (:ref:`ConfigurationPostgres`). It is important to distinguish here the user used to access the database and the -user used to login to the cubicweb application. When an instance starts, it uses +user used to login to the cubicweb instance. When an instance starts, it uses the login/psswd for the database to get the schema and handle low level transaction. But, when :command:`cubicweb-ctl create` asks for a manager login/psswd of *CubicWeb*, it refers to the user you will use during the -development to administrate your web application. It will be possible, later on, -to use this user to create others users for your final web application. +development to administrate your web instance. It will be possible, later on, +to use this user to create others users for your final web instance. Instance administration diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/admin/gae.rst --- a/doc/book/en/admin/gae.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/admin/gae.rst Tue Jul 28 21:14:47 2009 +0200 @@ -126,14 +126,14 @@ 'cubicweb'". They disappear after the first run of i18ninstance. .. note:: The command myapp/bin/laxctl i18ncube needs to be executed - only if your application is using cubes from cubicweb-apps. + only if your instance is using cubes from cubicweb-apps. Otherwise, please skip it. -You will never need to add new entries in the translation catalog. Instead we would -recommand you to use ``self.req._("msgId")`` in your application code -to flag new message id to add to the catalog, where ``_`` refers to -xgettext that is used to collect new strings to translate. -While running ``laxctl i18ncube``, new string will be added to the catalogs. +You will never need to add new entries in the translation catalog. Instead we +would recommand you to use ``self.req._("msgId")`` in your code to flag new +message id to add to the catalog, where ``_`` refers to xgettext that is used to +collect new strings to translate. While running ``laxctl i18ncube``, new string +will be added to the catalogs. Generating the data directory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -152,18 +152,18 @@ $ python myapp/bin/laxctl genschema -Application configuration +Instance configuration ------------------------- Authentication ~~~~~~~~~~~~~~ -You have the option of using or not google authentication for your application. +You have the option of using or not google authentication for your instance. This has to be define in ``app.conf`` and ``app.yaml``. In ``app.conf`` modify the following variable::   - # does this application rely on google authentication service or not. + # does this instance rely on google authentication service or not. use-google-auth=no In ``app.yaml`` comment the `login: required` set by default in the handler:: @@ -177,7 +177,7 @@ -Quickstart : launch the application +Quickstart : launch the instance ----------------------------------- On Mac OS X platforms, drag that directory on the @@ -189,7 +189,7 @@ Once the local server is started, visit `http://MYAPP_URL/_load `_ and sign in as administrator. This will initialize the repository and enable you to log in into -the application and continue the installation. +the instance and continue the installation. You should be redirected to a page displaying a message `content initialized`. diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/admin/index.rst --- a/doc/book/en/admin/index.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/admin/index.rst Tue Jul 28 21:14:47 2009 +0200 @@ -7,7 +7,7 @@ ------------------------- This part is for installation and administration of the *CubicWeb* framework and -applications based on that framework. +instances based on that framework. .. toctree:: :maxdepth: 1 @@ -25,11 +25,11 @@ RQL logs -------- -You can configure the *CubicWeb* application to keep a log +You can configure the *CubicWeb* instance to keep a log of the queries executed against your database. To do so, -edit the configuration file of your application +edit the configuration file of your instance ``.../etc/cubicweb.d/myapp/all-in-one.conf`` and uncomment the variable ``query-log-file``:: - # web application query log file + # web instance query log file query-log-file=/tmp/rql-myapp.log diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/admin/instance-config.rst --- a/doc/book/en/admin/instance-config.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/admin/instance-config.rst Tue Jul 28 21:14:47 2009 +0200 @@ -6,7 +6,7 @@ While creating an instance, a configuration file is generated in:: - $ (CW_REGISTRY) / / .conf + $ (CW_INSTANCES_DIR) / / .conf For example:: @@ -22,7 +22,7 @@ :`web.auth-model` [cookie]: authentication mode, cookie or http :`web.realm`: - realm of the application in http authentication mode + realm of the instance in http authentication mode :`web.http-session-time` [0]: period of inactivity of an HTTP session before it closes automatically. Duration in seconds, 0 meaning no expiration (or more exactly at the @@ -70,7 +70,7 @@ regular expression matching sites which could be "embedded" in the site (controllers 'embed') :`web.submit-url`: - url where the bugs encountered in the application can be mailed to + url where the bugs encountered in the instance can be mailed to RQL server configuration @@ -92,7 +92,7 @@ ----------------------------------- Web server side: -:`pyro-client.pyro-application-id`: +:`pyro-client.pyro-instance-id`: pyro identifier of RQL server (e.g. the instance name) RQL server side: @@ -107,7 +107,7 @@ hostname hosting pyro server name. If no value is specified, it is located by a request from broadcast :`pyro-name-server.pyro-ns-group` [cubicweb]: - pyro group in which to save the application + pyro group in which to save the instance Configuring e-mail @@ -125,9 +125,9 @@ :`email.smtp-port [25]`: SMTP server port to use for outgoing mail :`email.sender-name`: - name to use for outgoing mail of the application + name to use for outgoing mail of the instance :`email.sender-addr`: - address for outgoing mail of the application + address for outgoing mail of the instance :`email.default dest-addrs`: destination addresses by default, if used by the configuration of the dissemination of the model (separated by commas) diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/admin/setup.rst --- a/doc/book/en/admin/setup.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/admin/setup.rst Tue Jul 28 21:14:47 2009 +0200 @@ -39,7 +39,7 @@ apt-get install cubicweb cubicweb-dev `cubicweb` installs the framework itself, allowing you to create -new applications. +new instances. `cubicweb-dev` installs the development environment allowing you to develop new cubes. @@ -69,6 +69,10 @@ hg fclone http://www.logilab.org/hg/forests/cubicweb See :ref:`MercurialPresentation` for more details about Mercurial. +When cloning a repository, you might be set in a development branch +(the 'default' branch). You should check that the branches of the +repositories are set to 'stable' (using `hg up stable` for each one) +if you do not intend to develop the framework itself. In both cases, make sure you have installed the dependencies (see appendixes for the list). @@ -105,19 +109,20 @@ Add the following lines to either `.bashrc` or `.bash_profile` to configure your development environment :: - export PYTHONPATH=/full/path/to/cubicweb-forest + export PYTHONPATH=/full/path/to/cubicweb-forest -If you installed the debian packages, no configuration is required. -Your new cubes will be placed in `/usr/share/cubicweb/cubes` and -your applications will be placed in `/etc/cubicweb.d`. +If you installed *CubicWeb* with packages, no configuration is required and your +new cubes will be placed in `/usr/share/cubicweb/cubes` and your instances +will be placed in `/etc/cubicweb.d`. -To use others directories then you will have to configure the -following environment variables as follows:: +You may run a system-wide install of *CubicWeb* in "user mode" and use it for +development by setting the following environment variable:: + export CW_MODE=user export CW_CUBES_PATH=~/lib/cubes - export CW_REGISTRY=~/etc/cubicweb.d/ - export CW_INSTANCE_DATA=$CW_REGISTRY - export CW_RUNTIME=/tmp + export CW_INSTANCES_DIR=~/etc/cubicweb.d/ + export CW_INSTANCES_DATA_DIR=$CW_INSTANCES_DIR + export CW_RUNTIME_DIR=/tmp .. note:: The values given above are our suggestions but of course @@ -176,7 +181,7 @@ This login/password will be requested when you will create an instance with `cubicweb-ctl create` to initialize the database of - your application. + your instance. .. note:: The authentication method can be configured in ``pg_hba.conf``. @@ -194,13 +199,17 @@ MySql configuration ``````````````````` -Yout must add the following lines in /etc/mysql/my.cnf file:: +Yout must add the following lines in ``/etc/mysql/my.cnf`` file:: transaction-isolation = READ-COMMITTED default-storage-engine=INNODB default-character-set=utf8 max_allowed_packet = 128M +.. note:: + It is unclear whether mysql supports indexed string of arbitrary lenght or + not. + Pyro configuration ------------------ diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/admin/site-config.rst --- a/doc/book/en/admin/site-config.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/admin/site-config.rst Tue Jul 28 21:14:47 2009 +0200 @@ -5,7 +5,7 @@ .. image:: ../images/lax-book.03-site-config-panel.en.png -This panel allows you to configure the appearance of your application site. +This panel allows you to configure the appearance of your instance site. Six menus are available and we will go through each of them to explain how to use them. @@ -65,9 +65,9 @@ Boxes ~~~~~ -The application has already a pre-defined set of boxes you can use right away. +The instance has already a pre-defined set of boxes you can use right away. This configuration section allows you to place those boxes where you want in the -application interface to customize it. +instance interface to customize it. The available boxes are : @@ -82,7 +82,7 @@ * search box : search box * startup views box : box listing the configuration options available for - the application site, such as `Preferences` and `Site Configuration` + the instance site, such as `Preferences` and `Site Configuration` Components ~~~~~~~~~~ diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/annexes/cookbook.rst --- a/doc/book/en/annexes/cookbook.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/annexes/cookbook.rst Tue Jul 28 21:14:47 2009 +0200 @@ -10,7 +10,7 @@ * How to import LDAP users in *CubicWeb*? Here is a very useful script which enables you to import LDAP users - into your *CubicWeb* application by running the following: :: + into your *CubicWeb* instance by running the following: :: import os @@ -66,7 +66,7 @@ * How to load data from a script? The following script aims at loading data within a script assuming pyro-nsd is - running and your application is configured with ``pyro-server=yes``, otherwise + running and your instance is configured with ``pyro-server=yes``, otherwise you would not be able to use dbapi. :: from cubicweb import dbapi diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/annexes/cubicweb-ctl.rst --- a/doc/book/en/annexes/cubicweb-ctl.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/annexes/cubicweb-ctl.rst Tue Jul 28 21:14:47 2009 +0200 @@ -26,8 +26,8 @@ ------------------------ * ``newcube``, create a new cube on the file system based on the name - given in the parameters. This command create a cube from an application - skeleton that includes default files required for debian packaging. + given in the parameters. This command create a cube from a skeleton + that includes default files required for debian packaging. Command to create an instance @@ -69,7 +69,7 @@ * ``db-check``, checks data integrity of an instance. If the automatic correction is activated, it is recommanded to create a dump before this operation. * ``schema-sync``, synchronizes the persistent schema of an instance with - the application schema. It is recommanded to create a dump before this operation. + the instance schema. It is recommanded to create a dump before this operation. Commands to maintain i18n catalogs ---------------------------------- diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/annexes/faq.rst --- a/doc/book/en/annexes/faq.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/annexes/faq.rst Tue Jul 28 21:14:47 2009 +0200 @@ -39,11 +39,10 @@ When doing development, you need a real language and template languages are not real languages. - Using Python enables developing applications for which code is - easier to maintain with real functions/classes/contexts - without the need of learning a new dialect. By using Python, - we use standard OOP techniques and this is a key factor in a - robust application. + Using Python instead of a template langage for describing the user interface + makes it to maintain with real functions/classes/contexts without the need of + learning a new dialect. By using Python, we use standard OOP techniques and + this is a key factor in a robust application. Why do you use the LGPL license to prevent me from doing X ? ------------------------------------------------------------ @@ -141,7 +140,7 @@ ------------------------------------------------ While modifying the description of an entity, you get an error message in - the application `Error while publishing ...` for Rest text and plain text. + the instance `Error while publishing ...` for Rest text and plain text. The server returns a traceback like as follows :: 2008-10-06 15:05:08 - (cubicweb.rest) ERROR: error while publishing ReST text @@ -188,11 +187,8 @@ It depends on what has been modified in the schema. - * Update of an attribute permissions and properties: - ``synchronize_eschema('MyEntity')``. - - * Update of a relation permissions and properties: - ``synchronize_rschema('MyRelation')``. + * Update the permissions and properties of an entity or a relation: + ``sync_schema_props_perms('MyEntityOrRelation')``. * Add an attribute: ``add_attribute('MyEntityType', 'myattr')``. @@ -225,14 +221,14 @@ decribed above. -How to change the application logo ? +How to change the instance logo ? ------------------------------------ There are two ways of changing the logo. 1. The easiest way to use a different logo is to replace the existing ``logo.png`` in ``myapp/data`` by your prefered icon and refresh. - By default all application will look for a ``logo.png`` to be + By default all instance will look for a ``logo.png`` to be rendered in the logo section. .. image:: ../images/lax-book.06-main-template-logo.en.png @@ -270,7 +266,7 @@ user-attrs-map=gecos:email,uid:login Any change applied to configuration file requires to restart your - application. + instance. I get NoSelectableObject exceptions, how do I debug selectors ? --------------------------------------------------------------- @@ -316,14 +312,14 @@ If you have PostgreSQL set up to accept kerberos authentication, you can set the db-host, db-name and db-user parameters in the `sources` configuration file while leaving the password blank. It should be enough for your - application to connect to postgresql with a kerberos ticket. + instance to connect to postgresql with a kerberos ticket. How to load data from a script ? -------------------------------- The following script aims at loading data within a script assuming pyro-nsd is - running and your application is configured with ``pyro-server=yes``, otherwise + running and your instance is configured with ``pyro-server=yes``, otherwise you would not be able to use dbapi. :: from cubicweb import dbapi @@ -337,7 +333,7 @@ What is the CubicWeb datatype corresponding to GAE datastore's UserProperty ? ----------------------------------------------------------------------------- - If you take a look at your application schema and + If you take a look at your instance schema and click on "display detailed view of metadata" you will see that there is a Euser entity in there. That's the one that is modeling users. The thing that corresponds to a UserProperty is a relationship between @@ -367,3 +363,12 @@ $ psql mydb mydb=> update cw_cwuser set cw_upassword='qHO8282QN5Utg' where cw_login='joe'; UPDATE 1 + +I've just created a user in a group and it doesn't work ! +--------------------------------------------------------- + +You are probably getting errors such as :: + + remove {'PR': 'Project', 'C': 'CWUser'} from solutions since your_user has no read access to cost + +This is because you have to put your user in the "users" group. The user has to be in both groups. diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/annexes/rql/intro.rst --- a/doc/book/en/annexes/rql/intro.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/annexes/rql/intro.rst Tue Jul 28 21:14:47 2009 +0200 @@ -5,41 +5,38 @@ Goals of RQL ~~~~~~~~~~~~ -The goal is to have a language emphasizing the way of browsing -relations. As such, attributes will be regarded as cases of -special relations (in terms of implementation, the language -user should see virtually no difference between an attribute and a +The goal is to have a language emphasizing the way of browsing relations. As +such, attributes will be regarded as cases of special relations (in terms of +implementation, the user should see no difference between an attribute and a relation). -RQL is inspired by SQL but is the highest level. A knowledge of the -*CubicWeb* schema defining the application is necessary. - Comparison with existing languages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SQL ``` -RQL builds on the features of SQL but is at a higher level -(the current implementation of RQL generates SQL). For that it is limited -to the way of browsing relations and introduces variables. -The user does not need to know the model underlying SQL, but the *CubicWeb* -schema defining the application. + +RQL may remind of SQL but works at a higher abstraction level (the *CubicWeb* +framework generates SQL from RQL to fetch data from relation databases). RQL is +focused on browsing relations. The user needs only to know about the *CubicWeb* +data model he is querying, but not about the underlying SQL model. + +Sparql +`````` + +The query language most similar to RQL is SPARQL_, defined by the W3C to serve +for the semantic web. Versa ````` -We should look in more detail, but here are already some ideas for -the moment ... Versa_ is the language most similar to what we wanted -to do, but the model underlying data being RDF, there is some -number of things such as namespaces or handling of the RDF types which -does not interest us. On the functionality level, Versa_ is very comprehensive -including through many functions of conversion and basic types manipulation, -which may need to be guided at one time or another. -Finally, the syntax is a little esoteric. -Sparql -`````` -The query language most similar to RQL is SPARQL_, defined by the W3C to serve -for the semantic web. +We should look in more detail, but here are already some ideas for the moment +... Versa_ is the language most similar to what we wanted to do, but the model +underlying data being RDF, there is some number of things such as namespaces or +handling of the RDF types which does not interest us. On the functionality +level, Versa_ is very comprehensive including through many functions of +conversion and basic types manipulation, which may need to be guided at one time +or another. Finally, the syntax is a little esoteric. The different types of queries diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/development/cubes/available-cubes.rst --- a/doc/book/en/development/cubes/available-cubes.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/development/cubes/available-cubes.rst Tue Jul 28 21:14:47 2009 +0200 @@ -2,7 +2,7 @@ Available cubes --------------- -An application is based on several basic cubes. In the set of available +An instance is based on several basic cubes. In the set of available basic cubes we can find for example : Base entity types diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/development/cubes/layout.rst --- a/doc/book/en/development/cubes/layout.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/development/cubes/layout.rst Tue Jul 28 21:14:47 2009 +0200 @@ -80,7 +80,7 @@ * ``entities`` contains the entities definition (server side and web interface) * ``sobjects`` contains hooks and/or views notifications (server side only) * ``views`` contains the web interface components (web interface only) -* ``test`` contains tests related to the application (not installed) +* ``test`` contains tests related to the cube (not installed) * ``i18n`` contains message catalogs for supported languages (server side and web interface) * ``data`` contains data files for static content (images, css, javascripts) diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/development/datamodel/baseschema.rst --- a/doc/book/en/development/datamodel/baseschema.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/development/datamodel/baseschema.rst Tue Jul 28 21:14:47 2009 +0200 @@ -3,7 +3,7 @@ ---------------------------------- The library defines a set of entity schemas that are required by the system -or commonly used in *CubicWeb* applications. +or commonly used in *CubicWeb* instances. Entity types used to store the schema @@ -18,7 +18,7 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * `CWUser`, system users * `CWGroup`, users groups -* `CWPermission`, used to configure the security of the application +* `CWPermission`, used to configure the security of the instance Entity types used to manage workflows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -29,10 +29,10 @@ Other entity types ~~~~~~~~~~~~~~~~~~ * `CWCache` -* `CWProperty`, used to configure the application +* `CWProperty`, used to configure the instance * `EmailAddress`, email address, used by the system to send notifications to the users and also used by others optionnals schemas * `Bookmark`, an entity type used to allow a user to customize his links within - the application + the instance diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/development/datamodel/define-workflows.rst --- a/doc/book/en/development/datamodel/define-workflows.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/development/datamodel/define-workflows.rst Tue Jul 28 21:14:47 2009 +0200 @@ -20,7 +20,7 @@ ----------------- We want to create a workflow to control the quality of the BlogEntry -submitted on your application. When a BlogEntry is created by a user +submitted on your instance. When a BlogEntry is created by a user its state should be `submitted`. To be visible to all, it has to be in the state `published`. To move it from `submitted` to `published`, we need a transition that we can call `approve_blogentry`. diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/development/datamodel/definition.rst --- a/doc/book/en/development/datamodel/definition.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/development/datamodel/definition.rst Tue Jul 28 21:14:47 2009 +0200 @@ -3,7 +3,7 @@ Yams *schema* ------------- -The **schema** is the core piece of a *CubicWeb* application as it defines +The **schema** is the core piece of a *CubicWeb* instance as it defines the handled data model. It is based on entity types that are either already defined in the *CubicWeb* standard library; or more specific types, that *CubicWeb* expects to find in one or more Python files under the directory @@ -24,9 +24,8 @@ They are implicitely imported (as well as the special the function "_" for translation :ref:`internationalization`). -The instance schema of an application is defined on all appobjects by a .schema -class attribute set on registration. It's an instance of -:class:`yams.schema.Schema`. +The instance schema is defined on all appobjects by a .schema class attribute set +on registration. It's an instance of :class:`yams.schema.Schema`. Entity type ~~~~~~~~~~~ diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/development/devcore/appobject.rst --- a/doc/book/en/development/devcore/appobject.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/development/devcore/appobject.rst Tue Jul 28 21:14:47 2009 +0200 @@ -19,9 +19,9 @@ At the recording, the following attributes are dynamically added to the *subclasses*: -* `vreg`, the `vregistry` of the application -* `schema`, the application schema -* `config`, the application configuration +* `vreg`, the `vregistry` of the instance +* `schema`, the instance schema +* `config`, the instance configuration We also find on instances, the following attributes: @@ -36,7 +36,7 @@ can be specified through the special parameter `method` (the connection is theoretically done automatically :). - * `datadir_url()`, returns the directory of the application data + * `datadir_url()`, returns the directory of the instance data (contains static files such as images, css, js...) * `base_url()`, shortcut to `req.base_url()` @@ -57,9 +57,9 @@ :Data formatting: * `format_date(date, date_format=None, time=False)` returns a string for a - mx date time according to application's configuration + mx date time according to instance's configuration * `format_time(time)` returns a string for a mx date time according to - application's configuration + instance's configuration :And more...: diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/development/devweb/internationalization.rst --- a/doc/book/en/development/devweb/internationalization.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/development/devweb/internationalization.rst Tue Jul 28 21:14:47 2009 +0200 @@ -16,7 +16,7 @@ * in your Python code and cubicweb-tal templates : mark translatable strings -* in your application : handle the translation catalog +* in your instance : handle the translation catalog String internationalization ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -66,16 +66,18 @@ .. note:: We dont need to mark the translation strings of entities/relations - used by a particular application's schema as they are generated + used by a particular instance's schema as they are generated automatically. +If you need to add messages on top of those that can be found in the source, +you can create a file named `i18n/static-messages.pot`. Handle the translation catalog ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Once the internationalization is done in your application's code, you need -to populate and update the translation catalog. Cubicweb provides the -following commands for this purpose: +Once the internationalization is done in your code, you need to populate and +update the translation catalog. Cubicweb provides the following commands for this +purpose: * `i18ncubicweb` updates Cubicweb framework's translation @@ -83,28 +85,28 @@ need to use this command. * `i18ncube` updates the translation catalogs of *one particular - component* (or of all components). After this command is + cube* (or of all cubes). After this command is executed you must update the translation files *.po* in the "i18n" directory of your template. This command will of course not remove existing translations still in use. * `i18ninstance` recompile the translation catalogs of *one particular instance* (or of all instances) after the translation catalogs of - its components have been updated. This command is automatically + its cubes have been updated. This command is automatically called every time you create or update your instance. The compiled catalogs (*.mo*) are stored in the i18n//LC_MESSAGES of - application where `lang` is the language identifier ('en' or 'fr' + instance where `lang` is the language identifier ('en' or 'fr' for exemple). Example ``````` -You have added and/or modified some translation strings in your application -(after creating a new view or modifying the application's schema for exemple). +You have added and/or modified some translation strings in your cube +(after creating a new view or modifying the cube's schema for exemple). To update the translation catalogs you need to do: -1. `cubicweb-ctl i18ncube ` -2. Edit the /xxx.po files and add missing translations (empty `msgstr`) +1. `cubicweb-ctl i18ncube ` +2. Edit the /i18n/xxx.po files and add missing translations (empty `msgstr`) 3. `hg ci -m "updated i18n catalogs"` -4. `cubicweb-ctl i18ninstance ` +4. `cubicweb-ctl i18ninstance ` diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/development/entityclasses/data-as-objects.rst --- a/doc/book/en/development/entityclasses/data-as-objects.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/development/entityclasses/data-as-objects.rst Tue Jul 28 21:14:47 2009 +0200 @@ -61,10 +61,10 @@ Tne :class:`AnyEntity` class ---------------------------- -To provide a specific behavior for each entity, we have to define -a class inheriting from `cubicweb.entities.AnyEntity`. In general, we -define this class in a module of `mycube.entities` package of an application -so that it will be available on both server and client side. +To provide a specific behavior for each entity, we have to define a class +inheriting from `cubicweb.entities.AnyEntity`. In general, we define this class +in `mycube.entities` module (or in a submodule if we want to split code among +multiple files) so that it will be available on both server and client side. The class `AnyEntity` is loaded dynamically from the class `Entity` (`cubciweb.entity`). We define a sub-class to add methods or to diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/development/index.rst --- a/doc/book/en/development/index.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/development/index.rst Tue Jul 28 21:14:47 2009 +0200 @@ -18,3 +18,4 @@ testing/index migration/index webstdlib/index + profiling/index diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/development/migration/index.rst --- a/doc/book/en/development/migration/index.rst Tue Jul 28 21:11:10 2009 +0200 +++ b/doc/book/en/development/migration/index.rst Tue Jul 28 21:14:47 2009 +0200 @@ -5,19 +5,19 @@ Migration ========= -One of the main concept in *CubicWeb* is to create incremental applications. -For this purpose, multiple actions are provided to facilitate the improvement -of an application, and in particular to handle the changes to be applied -to the data model, without loosing existing data. +One of the main design goals of *CubicWeb* was to support iterative and agile +development. For this purpose, multiple actions are provided to facilitate the +improvement of an instance, and in particular to handle the changes to be +applied to the data model, without loosing existing data. -The current version of an application model is provided in the file +The current version of a cube (and of cubicweb itself) is provided in the file `__pkginfo__.py` as a tuple of 3 integers. Migration scripts management ---------------------------- Migration scripts has to be located in the directory `migration` of your -application and named accordingly: +cube and named accordingly: :: @@ -67,11 +67,8 @@ * `interactive_mode`, boolean indicating that the script is executed in an interactive mode or not -* `appltemplversion`, application model version of the instance - -* `templversion`, installed application model version - -* `cubicwebversion`, installed cubicweb version +* `versions_map`, dictionary of migrated versions (key are cubes + names, including 'cubicweb', values are (from version, to version) * `confirm(question)`, function asking the user and returning true if the user answers yes, false otherwise (always returns true in @@ -84,16 +81,14 @@ * `checkpoint`, request confirming and executing a "commit" at checking point -* `repo_schema`, instance persisting schema (e.g. instance schema of the - current migration) +* `schema`, instance schema (readen from the database) -* `newschema`, installed schema on the file system (e.g. schema of +* `fsschema`, installed schema on the file system (e.g. schema of the updated model and cubicweb) -* `sqlcursor`, SQL cursor for very rare cases where it is really - necessary or beneficial to go through the sql +* `repo`, repository object -* `repo`, repository object +* `session`, repository session object Schema migration @@ -134,18 +129,12 @@ * `drop_relation_definition(subjtype, rtype, objtype, commit=True)`, removes a relation definition. -* `synchronize_permissions(ertype, commit=True)`, synchronizes permissions on - an entity type or relation type. - -* `synchronize_rschema(rtype, commit=True)`, synchronizes properties and permissions - on a relation type. - -* `synchronize_eschema(etype, commit=True)`, synchronizes properties and persmissions - on an entity type. - -* `synchronize_schema(commit=True)`, synchronizes the persisting schema with the - updated schema (but without adding or removing new entity types, relations types - or even relations definitions). +* `sync_schema_props_perms(ertype=None, syncperms=True, + syncprops=True, syncrdefs=True, commit=True)`, + synchronizes properties and/or permissions on: + * the whole schema if ertype is None + * an entity or relation type schema if ertype is a string + * a relation definition if ertype is a 3-uple (subject, relation, object) * `change_relation_props(subjtype, rtype, objtype, commit=True, **kwargs)`, changes properties of a relation definition by using the named parameters of the properties @@ -204,7 +193,7 @@ accomplished otherwise or to repair damaged databases during interactive session. They are available in `repository` scripts: -* `sqlexec(sql, args=None, ask_confirm=True)`, executes an arbitrary SQL query +* `sql(sql, args=None, ask_confirm=True)`, executes an arbitrary SQL query on the system source * `add_entity_type_table(etype, commit=True)` * `add_relation_type_table(rtype, commit=True)` * `uninline_relation(rtype, commit=True)` diff -r 73c83c14dd2c -r 6f8ffaa2a700 doc/book/en/development/profiling/index.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/book/en/development/profiling/index.rst Tue Jul 28 21:14:47 2009 +0200 @@ -0,0 +1,54 @@ +Profiling and performance +========================= + +If you feel that one of your pages takes more time than it should to be +generated, chances are that you're making too many RQL queries. Obviously, +there are other reasons but experience tends to show this is the first thing to +track down. Luckily, CubicWeb provides a configuration option to log RQL +queries. In your ``all-in-one.conf`` file, set the **query-log-file** option:: + + # web application query log file + query-log-file=~/myapp-rql.log + +Then restart your application, reload your page and stop your application. +The file ``myapp-rql.log`` now contains the list of RQL queries that were +executed during your test. It's a simple text file containing lines such as:: + + Any A WHERE X eid %(x)s, X lastname A {'x': 448} -- (0.002 sec, 0.010 CPU sec) + Any A WHERE X eid %(x)s, X firstname A {'x': 447} -- (0.002 sec, 0.000 CPU sec) + +The structure of each line is:: + + --