--- a/appobject.py Sat Aug 01 00:00:29 2009 +0200
+++ b/appobject.py Sat Aug 01 00:01:12 2009 +0200
@@ -10,7 +10,7 @@
from datetime import datetime, timedelta, time
from logilab.common.decorators import classproperty
-from logilab.common.deprecation import obsolete
+from logilab.common.deprecation import deprecated
from rql.nodes import VariableRef, SubQuery
from rql.stmts import Union, Select
@@ -101,7 +101,7 @@
return '%s.%s.%s' % (cls.__registry__, cls.id, propid)
@classproperty
- @obsolete('use __select__ and & or | operators')
+ @deprecated('use __select__ and & or | operators')
def __selectors__(cls):
selector = cls.__select__
if isinstance(selector, AndSelector):
--- a/common/migration.py Sat Aug 01 00:00:29 2009 +0200
+++ b/common/migration.py Sat Aug 01 00:01:12 2009 +0200
@@ -15,6 +15,7 @@
from logilab.common.decorators import cached
from logilab.common.configuration import REQUIRED, read_old_config
+from logilab.common.shellutils import ASK
from cubicweb import ConfigurationError
@@ -69,11 +70,10 @@
ability to show the script's content
"""
while True:
- confirm = raw_input('Execute %r (Y/n/s[how]) ?' % scriptpath)
- confirm = confirm.strip().lower()
- if confirm in ('n', 'no'):
+ answer = ASK.ask('Execute %r ?' % scriptpath, ('Y','n','show'), 'Y')
+ if answer == 'n':
return False
- elif confirm in ('s', 'show'):
+ elif answer == 'show':
stream = open(scriptpath)
scriptcontent = stream.read()
stream.close()
@@ -188,26 +188,24 @@
if `retry` is true the r[etry] answer may return 2
"""
- print question,
- possibleanswers = 'Y/n'
+ possibleanswers = ['Y','n']
if abort:
- possibleanswers += '/a[bort]'
+ possibleanswers.append('abort')
if shell:
- possibleanswers += '/s[hell]'
+ possibleanswers.append('shell')
if retry:
- possibleanswers += '/r[etry]'
+ possibleanswers.append('retry')
try:
- confirm = raw_input('(%s): ' % ( possibleanswers, ))
- answer = confirm.strip().lower()
+ answer = ASK.ask(question, possibleanswers, 'Y')
except (EOFError, KeyboardInterrupt):
answer = 'abort'
- if answer in ('n', 'no'):
+ if answer == 'n':
return False
- if answer in ('r', 'retry'):
+ if answer == 'retry':
return 2
- if answer in ('a', 'abort'):
+ if answer == 'abort':
raise SystemExit(1)
- if shell and answer in ('s', 'shell'):
+ if shell and answer == 'shell':
self.interactive_shell()
return self.confirm(question)
return True
--- a/common/mixins.py Sat Aug 01 00:00:29 2009 +0200
+++ b/common/mixins.py Sat Aug 01 00:01:12 2009 +0200
@@ -8,7 +8,7 @@
"""
__docformat__ = "restructuredtext en"
-from logilab.common.deprecation import obsolete
+from logilab.common.deprecation import deprecated
from logilab.common.decorators import cached
from cubicweb import typed_eid
@@ -242,7 +242,7 @@
# specific vocabulary methods #############################################
- @obsolete('use EntityFieldsForm.subject_in_state_vocabulary')
+ @deprecated('use EntityFieldsForm.subject_in_state_vocabulary')
def subject_in_state_vocabulary(self, rschema, limit=None):
form = self.vreg.select('forms', 'edition', self.req, entity=self)
return form.subject_in_state_vocabulary(rschema, limit)
--- a/cwconfig.py Sat Aug 01 00:00:29 2009 +0200
+++ b/cwconfig.py Sat Aug 01 00:01:12 2009 +0200
@@ -22,7 +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.deprecation import deprecated
from logilab.common.logging_ext import set_log_methods, init_log
from logilab.common.configuration import (Configuration, Method,
ConfigurationMixIn, merge_options)
@@ -866,4 +866,4 @@
# alias to get a configuration instance from an instance id
instance_configuration = CubicWebConfiguration.config_for
-application_configuration = deprecated_function(instance_configuration, 'use instance_configuration')
+application_configuration = deprecated('use instance_configuration')(instance_configuration)
--- a/cwctl.py Sat Aug 01 00:00:29 2009 +0200
+++ b/cwctl.py Sat Aug 01 00:01:12 2009 +0200
@@ -9,10 +9,11 @@
from os.path import exists, join, isfile, isdir
from logilab.common.clcommands import register_commands, pop_arg
+from logilab.common.shellutils import ASK
from cubicweb import ConfigurationError, ExecutionError, BadCommandUsage, underline_title
from cubicweb.cwconfig import CubicWebConfiguration as cwcfg, CONFIGURATIONS
-from cubicweb.toolsutils import Command, main_run, rm, create_dir, confirm
+from cubicweb.toolsutils import Command, main_run, rm, create_dir
def wait_process_end(pid, maxtry=10, waittime=1):
"""wait for a process to actually die"""
--- a/cwvreg.py Sat Aug 01 00:00:29 2009 +0200
+++ b/cwvreg.py Sat Aug 01 00:01:12 2009 +0200
@@ -9,7 +9,7 @@
_ = unicode
from logilab.common.decorators import cached, clear_cache
-from logilab.common.deprecation import obsolete
+from logilab.common.deprecation import deprecated
from rql import RQLHelper
@@ -284,22 +284,22 @@
self.exception('error while trying to select %s view for %s',
vid, rset)
- @obsolete("use .select_object('boxes', ...)")
+ @deprecated("use .select_object('boxes', ...)")
def select_box(self, oid, *args, **kwargs):
"""return the most specific view according to the result set"""
return self.select_object('boxes', oid, *args, **kwargs)
- @obsolete("use .select_object('components', ...)")
+ @deprecated("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', ...)")
+ @deprecated("use .select_object('actions', ...)")
def select_action(self, oid, *args, **kwargs):
"""return the most specific view according to the result set"""
return self.select_object('actions', oid, *args, **kwargs)
- @obsolete("use .select('views', ...)")
+ @deprecated("use .select('views', ...)")
def select_view(self, __vid, req, rset=None, **kwargs):
"""return the most specific view according to the result set"""
return self.select('views', __vid, req, rset=rset, **kwargs)
--- a/devtools/apptest.py Sat Aug 01 00:00:29 2009 +0200
+++ b/devtools/apptest.py Sat Aug 01 00:01:12 2009 +0200
@@ -15,7 +15,7 @@
from logilab.common.pytest import nocoverage
from logilab.common.umessage import message_from_string
-from logilab.common.deprecation import deprecated_function
+from logilab.common.deprecation import deprecated
from cubicweb.devtools import init_test_database, TestServerConfiguration, ApptestConfiguration
from cubicweb.devtools._apptest import TestEnvironment
@@ -234,7 +234,7 @@
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)
+ paddrelactions = deprecated()(pactions_by_cats)
def pactionsdict(self, req, rset, skipcategories=('addrelated', 'siteactions', 'useractions')):
res = {}
--- a/devtools/devctl.py Sat Aug 01 00:00:29 2009 +0200
+++ b/devtools/devctl.py Sat Aug 01 00:01:12 2009 +0200
@@ -17,15 +17,15 @@
from logilab.common import STD_BLACKLIST
from logilab.common.modutils import get_module_files
from logilab.common.textutils import get_csv
+from logilab.common.shellutils import ASK
from logilab.common.clcommands import register_commands
from cubicweb import CW_SOFTWARE_ROOT as BASEDIR, BadCommandUsage, underline_title
from cubicweb.__pkginfo__ import version as cubicwebversion
-from cubicweb.toolsutils import Command, confirm, copy_skeleton
+from cubicweb.toolsutils import Command, copy_skeleton
from cubicweb.web.webconfig import WebConfiguration
from cubicweb.server.serverconfig import ServerConfiguration
-
class DevCubeConfiguration(ServerConfiguration, WebConfiguration):
"""dummy config to get full library schema and entities"""
creating = True
@@ -483,7 +483,7 @@
" Please specify it using the --directory option")
cubesdir = cubespath[0]
if not isdir(cubesdir):
- print "creating cubes directory", cubesdir
+ print "-> creating cubes directory", cubesdir
try:
mkdir(cubesdir)
except OSError, err:
@@ -492,19 +492,20 @@
if exists(cubedir):
self.fail("%s already exists !" % (cubedir))
skeldir = join(BASEDIR, 'skeleton')
+ default_name = 'cubicweb-%s' % cubename.lower()
if verbose:
- distname = raw_input('Debian name for your cube (just type enter to use the cube name): ').strip()
+ distname = raw_input('Debian name for your cube ? [%s]): ' % default_name).strip()
if not distname:
- distname = 'cubicweb-%s' % cubename.lower()
+ distname = default_name
elif not distname.startswith('cubicweb-'):
- if confirm('do you mean cubicweb-%s ?' % distname):
+ if ASK.confirm('Do you mean cubicweb-%s ?' % distname):
distname = 'cubicweb-' + distname
else:
- distname = 'cubicweb-%s' % cubename.lower()
+ distname = default_name
longdesc = shortdesc = raw_input('Enter a short description for your cube: ')
if verbose:
- longdesc = raw_input('Enter a long description (or nothing if you want to reuse the short one): ')
+ longdesc = raw_input('Enter a long description (leave empty to reuse the short one): ')
if verbose:
includes = self._ask_for_dependancies()
if len(includes) == 1:
@@ -529,14 +530,14 @@
def _ask_for_dependancies(self):
includes = []
for stdtype in ServerConfiguration.available_cubes():
- ans = raw_input("Depends on cube %s? (N/y/s(kip)/t(ype)"
- % stdtype).lower().strip()
- if ans == 'y':
+ answer = ASK.ask("Depends on cube %s? " % stdtype,
+ ('N','y','skip','type'), 'N')
+ if answer == 'y':
includes.append(stdtype)
- if ans == 't':
+ if answer == 'type':
includes = get_csv(raw_input('type dependancies: '))
break
- elif ans == 's':
+ elif answer == 'skip':
break
return includes
--- a/doc/book/en/annexes/cookbook.rst Sat Aug 01 00:00:29 2009 +0200
+++ b/doc/book/en/annexes/cookbook.rst Sat Aug 01 00:01:12 2009 +0200
@@ -12,8 +12,9 @@
[XXX distribute this script with cubicweb instead]
Here is a very useful script which enables you to import LDAP users
- into your *CubicWeb* instance by running the following: ::
+ into your *CubicWeb* instance by running the following:
+.. sourcecode:: python
import os
import pwd
@@ -69,7 +70,9 @@
The following script aims at loading data within a script assuming pyro-nsd is
running and your instance is configured with ``pyro-server=yes``, otherwise
- you would not be able to use dbapi. ::
+ you would not be able to use dbapi.
+
+.. sourcecode:: python
from cubicweb import dbapi
--- a/doc/tools/generate_modules.py Sat Aug 01 00:00:29 2009 +0200
+++ b/doc/tools/generate_modules.py Sat Aug 01 00:01:12 2009 +0200
@@ -8,11 +8,15 @@
import sys
-EXCLUDE_DIRS = ('test', 'tests', 'examples', 'data', 'doc', '.hg', 'migration')
+EXCLUDE_DIRS = ('test', 'tests', 'examples', 'data', 'doc', 'dist',
+ '.hg', 'migration')
if __name__ == '__main__':
- from logilab.common.sphinxutils import generate_modules_file
-
- gen = generate_modules_file(sys.argv[1:])
- gen.set_docdir("cubicweb/doc/book/en")
- gen.make(['cubicweb', '/indexer', '/logilab', '/rql', '/yams'], EXCLUDE_DIRS)
+ from logilab.common.sphinxutils import ModuleGenerator
+ cw_gen = ModuleGenerator('cubicweb', '../..')
+ cw_gen.generate("../book/en/annexes/api_cubicweb.rst",
+ EXCLUDE_DIRS + ('cwdesklets', 'misc', 'skel', 'skeleton'))
+ for modname in ('indexer', 'logilab', 'rql', 'yams'):
+ cw_gen = ModuleGenerator(modname, '../../../' + modname)
+ cw_gen.generate("../book/en/annexes/api_%s.rst" % modname,
+ EXCLUDE_DIRS + ('tools',))
--- a/entities/__init__.py Sat Aug 01 00:00:29 2009 +0200
+++ b/entities/__init__.py Sat Aug 01 00:01:12 2009 +0200
@@ -9,7 +9,7 @@
from warnings import warn
-from logilab.common.deprecation import deprecated_function, obsolete
+from logilab.common.deprecation import deprecated
from logilab.common.decorators import cached
from cubicweb import Unauthorized, typed_eid
@@ -239,22 +239,22 @@
wdg = widget(cls.vreg, tschema, rschema, cls, 'object')
return wdg
- @obsolete('use EntityFieldsForm.subject_relation_vocabulary')
+ @deprecated('use EntityFieldsForm.subject_relation_vocabulary')
def subject_relation_vocabulary(self, rtype, limit):
form = self.vreg.select('forms', 'edition', self.req, entity=self)
return form.subject_relation_vocabulary(rtype, limit)
- @obsolete('use EntityFieldsForm.object_relation_vocabulary')
+ @deprecated('use EntityFieldsForm.object_relation_vocabulary')
def object_relation_vocabulary(self, rtype, limit):
form = self.vreg.select('forms', 'edition', self.req, entity=self)
return form.object_relation_vocabulary(rtype, limit)
- @obsolete('use AutomaticEntityForm.[e]relations_by_category')
+ @deprecated('use AutomaticEntityForm.[e]relations_by_category')
def relations_by_category(self, categories=None, permission=None):
from cubicweb.web.views.autoform import AutomaticEntityForm
return AutomaticEntityForm.erelations_by_category(self, categories, permission)
- @obsolete('use AutomaticEntityForm.[e]srelations_by_category')
+ @deprecated('use AutomaticEntityForm.[e]srelations_by_category')
def srelations_by_category(self, categories=None, permission=None):
from cubicweb.web.views.autoform import AutomaticEntityForm
return AutomaticEntityForm.esrelations_by_category(self, categories, permission)
--- a/entity.py Sat Aug 01 00:00:29 2009 +0200
+++ b/entity.py Sat Aug 01 00:01:12 2009 +0200
@@ -12,7 +12,7 @@
from logilab.common import interface
from logilab.common.compat import all
from logilab.common.decorators import cached
-from logilab.common.deprecation import obsolete
+from logilab.common.deprecation import deprecated
from logilab.mtconverter import TransformData, TransformError, xml_escape
from rql.utils import rqlvar_maker
@@ -719,7 +719,7 @@
# generic vocabulary methods ##############################################
- @obsolete('see new form api')
+ @deprecated('see new form api')
def vocabulary(self, rtype, role='subject', limit=None):
"""vocabulary functions must return a list of couples
(label, eid) that will typically be used to fill the
--- a/schema.py Sat Aug 01 00:00:29 2009 +0200
+++ b/schema.py Sat Aug 01 00:01:12 2009 +0200
@@ -14,7 +14,7 @@
from warnings import warn
from logilab.common.decorators import cached, clear_cache, monkeypatch
-from logilab.common.deprecation import obsolete
+from logilab.common.deprecation import deprecated
from logilab.common.compat import any
from yams import BadSchemaDefinition, buildobjs as ybo
@@ -78,7 +78,7 @@
# ensure unicode
# added .lower() in case no translation are available
return unicode(req._(key)).lower()
-__builtins__['display_name'] = obsolete('display_name should be imported from cubicweb.schema')(display_name)
+__builtins__['display_name'] = deprecated('display_name should be imported from cubicweb.schema')(display_name)
def ERSchema_display_name(self, req, form=''):
"""return a internationalized string for the entity/relation type name in
--- a/selectors.py Sat Aug 01 00:00:29 2009 +0200
+++ b/selectors.py Sat Aug 01 00:01:12 2009 +0200
@@ -46,7 +46,7 @@
from warnings import warn
from logilab.common.compat import all
-from logilab.common.deprecation import deprecated_function
+from logilab.common.deprecation import deprecated
from logilab.common.interface import implements as implements_iface
from yams import BASE_TYPES
@@ -976,86 +976,86 @@
# XXX DEPRECATED ##############################################################
-yes_selector = deprecated_function(yes)
-norset_selector = deprecated_function(none_rset)
-rset_selector = deprecated_function(any_rset)
-anyrset_selector = deprecated_function(nonempty_rset)
-emptyrset_selector = deprecated_function(empty_rset)
-onelinerset_selector = deprecated_function(one_line_rset)
-twolinerset_selector = deprecated_function(two_lines_rset)
-twocolrset_selector = deprecated_function(two_cols_rset)
-largerset_selector = deprecated_function(paginated_rset)
-sortedrset_selector = deprecated_function(sorted_rset)
-oneetyperset_selector = deprecated_function(one_etype_rset)
-multitype_selector = deprecated_function(two_etypes_rset)
-anonymous_selector = deprecated_function(anonymous_user)
-not_anonymous_selector = deprecated_function(authenticated_user)
-primaryview_selector = deprecated_function(primary_view)
-contextprop_selector = deprecated_function(match_context_prop)
+yes_selector = deprecated()(yes)
+norset_selector = deprecated()(none_rset)
+rset_selector = deprecated()(any_rset)
+anyrset_selector = deprecated()(nonempty_rset)
+emptyrset_selector = deprecated()(empty_rset)
+onelinerset_selector = deprecated()(one_line_rset)
+twolinerset_selector = deprecated()(two_lines_rset)
+twocolrset_selector = deprecated()(two_cols_rset)
+largerset_selector = deprecated()(paginated_rset)
+sortedrset_selector = deprecated()(sorted_rset)
+oneetyperset_selector = deprecated()(one_etype_rset)
+multitype_selector = deprecated()(two_etypes_rset)
+anonymous_selector = deprecated()(anonymous_user)
+not_anonymous_selector = deprecated()(authenticated_user)
+primaryview_selector = deprecated()(primary_view)
+contextprop_selector = deprecated()(match_context_prop)
+@deprecated('use non_final_entity instead of %s')
def nfentity_selector(cls, req, rset=None, row=None, col=0, **kwargs):
return non_final_entity()(cls, req, rset, row, col)
-nfentity_selector = deprecated_function(nfentity_selector)
+@deprecated('use implements instead of %s')
def implement_interface(cls, req, rset=None, row=None, col=0, **kwargs):
return implements(*cls.accepts_interfaces)(cls, req, rset, row, col)
-_interface_selector = deprecated_function(implement_interface)
-interface_selector = deprecated_function(implement_interface)
-implement_interface = deprecated_function(implement_interface, 'use implements')
+_interface_selector = deprecated()(implement_interface)
+interface_selector = deprecated()(implement_interface)
+@deprecated('use specified_etype_implements instead of %s')
def accept_etype(cls, req, *args, **kwargs):
"""check etype presence in request form *and* accepts conformance"""
return specified_etype_implements(*cls.accepts)(cls, req, *args)
-etype_form_selector = deprecated_function(accept_etype)
-accept_etype = deprecated_function(accept_etype, 'use specified_etype_implements')
+etype_form_selector = accept_etype
+@deprecated('use match_search_state instead of %s')
def searchstate_selector(cls, req, rset=None, row=None, col=0, **kwargs):
return match_search_state(cls.search_states)(cls, req, rset, row, col)
-searchstate_selector = deprecated_function(searchstate_selector)
+@deprecated('use match_user_groups instead of %s')
def match_user_group(cls, req, rset=None, row=None, col=0, **kwargs):
return match_user_groups(*cls.require_groups)(cls, req, rset, row, col, **kwargs)
-in_group_selector = deprecated_function(match_user_group)
-match_user_group = deprecated_function(match_user_group)
+in_group_selector = match_user_group
+@deprecated('use relation_possible instead of %s')
def has_relation(cls, req, rset=None, row=None, col=0, **kwargs):
return relation_possible(cls.rtype, role(cls), cls.etype,
getattr(cls, 'require_permission', 'read'))(cls, req, rset, row, col, **kwargs)
-has_relation = deprecated_function(has_relation)
+@deprecated('use relation_possible instead of %s')
def one_has_relation(cls, req, rset=None, row=None, col=0, **kwargs):
return relation_possible(cls.rtype, role(cls), cls.etype,
getattr(cls, 'require_permission', 'read',
once_is_enough=True))(cls, req, rset, row, col, **kwargs)
-one_has_relation = deprecated_function(one_has_relation, 'use relation_possible selector')
+@deprecated('use implements instead of %s')
def accept_rset(cls, req, rset=None, row=None, col=0, **kwargs):
"""simply delegate to cls.accept_rset method"""
return implements(*cls.accepts)(cls, req, rset, row=row, col=col)
-accept_rset_selector = deprecated_function(accept_rset)
-accept_rset = deprecated_function(accept_rset, 'use implements selector')
+accept_rset_selector = accept_rset
accept = chainall(non_final_entity(), accept_rset, name='accept')
-accept_selector = deprecated_function(accept)
-accept = deprecated_function(accept, 'use implements selector')
+accept = deprecated('use implements selector')(accept)
+accept_selector = deprecated()(accept)
-accept_one = deprecated_function(chainall(one_line_rset, accept,
+accept_one = deprecated()(chainall(one_line_rset, accept,
name='accept_one'))
-accept_one_selector = deprecated_function(accept_one)
+accept_one_selector = deprecated()(accept_one)
def _rql_condition(cls, req, rset=None, row=None, col=0, **kwargs):
if cls.condition:
return rql_condition(cls.condition)(cls, req, rset, row, col)
return 1
-_rqlcondition_selector = deprecated_function(_rql_condition)
+_rqlcondition_selector = deprecated()(_rql_condition)
-rqlcondition_selector = deprecated_function(chainall(non_final_entity(), one_line_rset, _rql_condition,
+rqlcondition_selector = deprecated()(chainall(non_final_entity(), one_line_rset, _rql_condition,
name='rql_condition'))
+@deprecated('use but_etype instead of %s')
def but_etype_selector(cls, req, rset=None, row=None, col=0, **kwargs):
return but_etype(cls.etype)(cls, req, rset, row, col)
-but_etype_selector = deprecated_function(but_etype_selector)
@lltrace
def etype_rtype_selector(cls, req, rset=None, row=None, col=0, **kwargs):
@@ -1070,24 +1070,25 @@
if not (rschema.has_perm(req, perm) or rschema.has_local_role(perm)):
return 0
return 1
-etype_rtype_selector = deprecated_function(etype_rtype_selector)
+etype_rtype_selector = deprecated()(etype_rtype_selector)
-#req_form_params_selector = deprecated_function(match_form_params) # form_params
-#kwargs_selector = deprecated_function(match_kwargs) # expected_kwargs
+#req_form_params_selector = deprecated()(match_form_params) # form_params
+#kwargs_selector = deprecated()(match_kwargs) # expected_kwargs
# compound selectors ##########################################################
searchstate_accept = chainall(nonempty_rset(), accept,
name='searchstate_accept')
-searchstate_accept_selector = deprecated_function(searchstate_accept)
+searchstate_accept_selector = deprecated()(searchstate_accept)
searchstate_accept_one = chainall(one_line_rset, accept, _rql_condition,
name='searchstate_accept_one')
-searchstate_accept_one_selector = deprecated_function(searchstate_accept_one)
+searchstate_accept_one_selector = deprecated()(searchstate_accept_one)
-searchstate_accept = deprecated_function(searchstate_accept)
-searchstate_accept_one = deprecated_function(searchstate_accept_one)
+searchstate_accept = deprecated()(searchstate_accept)
+searchstate_accept_one = deprecated()(searchstate_accept_one)
+# end of deprecation section ##################################################
def unbind_method(selector):
def new_selector(registered):
--- a/server/migractions.py Sat Aug 01 00:00:29 2009 +0200
+++ b/server/migractions.py Sat Aug 01 00:01:12 2009 +0200
@@ -22,7 +22,7 @@
from os.path import join, exists
from datetime import datetime
-from logilab.common.deprecation import deprecated_function, obsolete
+from logilab.common.deprecation import deprecated
from logilab.common.decorators import cached, clear_cache
from logilab.common.adbh import get_adv_func_helper
@@ -199,9 +199,9 @@
'fsschema': self.fs_schema,
'session' : self.session,
'repo' : self.repo,
- 'synchronize_schema': deprecated_function(self.cmd_sync_schema_props_perms),
- 'synchronize_eschema': deprecated_function(self.cmd_sync_schema_props_perms),
- 'synchronize_rschema': deprecated_function(self.cmd_sync_schema_props_perms),
+ 'synchronize_schema': deprecated()(self.cmd_sync_schema_props_perms),
+ 'synchronize_eschema': deprecated()(self.cmd_sync_schema_props_perms),
+ 'synchronize_rschema': deprecated()(self.cmd_sync_schema_props_perms),
})
return context
@@ -838,7 +838,7 @@
if commit:
self.commit()
- @obsolete('use sync_schema_props_perms(ertype, syncprops=False)')
+ @deprecated('use sync_schema_props_perms(ertype, syncprops=False)')
def cmd_synchronize_permissions(self, ertype, commit=True):
self.cmd_sync_schema_props_perms(ertype, syncprops=False, commit=commit)
--- a/server/serverctl.py Sat Aug 01 00:00:29 2009 +0200
+++ b/server/serverctl.py Sat Aug 01 00:01:12 2009 +0200
@@ -12,9 +12,10 @@
from logilab.common.configuration import Configuration
from logilab.common.clcommands import register_commands, cmd_run, pop_arg
+from logilab.common.shellutils import ASK
from cubicweb import AuthenticationError, ExecutionError, ConfigurationError, underline_title
-from cubicweb.toolsutils import Command, CommandHandler, confirm
+from cubicweb.toolsutils import Command, CommandHandler
from cubicweb.server import SOURCE_TYPES
from cubicweb.server.utils import ask_source_config
from cubicweb.server.serverconfig import USER_OPTIONS, ServerConfiguration
@@ -139,7 +140,7 @@
if cube in SOURCE_TYPES:
sourcescfg[cube] = ask_source_config(cube, inputlevel)
print
- while confirm('Enter another source ?', default_is_yes=False):
+ while ASK.confirm('Enter another source ?', default_is_yes=False):
available = sorted(stype for stype in SOURCE_TYPES
if not stype in cubes)
while True:
@@ -169,7 +170,7 @@
config.write_bootstrap_cubes_file(cubes)
def postcreate(self):
- if confirm('Do you want to run db-create to create the system database ?'):
+ if ASK.confirm('Run db-create to create the system database ?'):
verbosity = (self.config.mode == 'installed') and 'y' or 'n'
cmd_run('db-create', self.config.appid, '--verbose=%s' % verbosity)
else:
@@ -187,7 +188,7 @@
source = self.config.sources()['system']
dbname = source['db-name']
helper = get_adv_func_helper(source['db-driver'])
- if confirm('Delete database %s ?' % dbname):
+ if ASK.confirm('Delete database %s ?' % dbname):
user = source['db-user'] or None
cnx = _db_sys_cnx(source, 'DROP DATABASE', user=user)
cursor = cnx.cursor()
@@ -196,7 +197,7 @@
print '-> database %s dropped.' % dbname
# XXX should check we are not connected as user
if user and helper.users_support and \
- confirm('Delete user %s ?' % user, default_is_yes=False):
+ ASK.confirm('Delete user %s ?' % user, default_is_yes=False):
cursor.execute('DROP USER %s' % user)
print '-> user %s dropped.' % user
cnx.commit()
@@ -277,12 +278,12 @@
if helper.users_support:
user = source['db-user']
if not helper.user_exists(cursor, user) and \
- confirm('Create db user %s ?' % user, default_is_yes=False):
+ ASK.confirm('Create db user %s ?' % user, default_is_yes=False):
helper.create_user(source['db-user'], source['db-password'])
print '-> user %s created.' % user
dbname = source['db-name']
if dbname in helper.list_databases(cursor):
- if confirm('Database %s already exists -- do you want to drop it ?' % dbname):
+ if ASK.confirm('Database %s already exists -- do you want to drop it ?' % dbname):
cursor.execute('DROP DATABASE %s' % dbname)
else:
return
@@ -310,7 +311,7 @@
cnx.commit()
print '-> database for instance %s created and necessary extensions installed.' % appid
print
- if confirm('Do you want to run db-init to initialize the system database ?'):
+ if ASK.confirm('Run db-init to initialize the system database ?'):
cmd_run('db-init', config.appid)
else:
print ('-> nevermind, you can do it later with '
@@ -491,7 +492,7 @@
raise ExecutionError('Error while retrieving the dump')
rmcmd = 'ssh -t %s "rm -f /tmp/%s.dump"' % (host, appid)
print rmcmd
- if os.system(rmcmd) and not confirm(
+ if os.system(rmcmd) and not ASK.confirm(
'An error occured while deleting remote dump. Continue anyway?'):
raise ExecutionError('Error while deleting remote dump')
--- a/server/session.py Sat Aug 01 00:00:29 2009 +0200
+++ b/server/session.py Sat Aug 01 00:01:12 2009 +0200
@@ -11,7 +11,7 @@
import threading
from time import time
-from logilab.common.deprecation import obsolete
+from logilab.common.deprecation import deprecated
from rql.nodes import VariableRef, Function, ETYPE_PYOBJ_MAP, etype_from_pyobj
from yams import BASE_TYPES
@@ -484,7 +484,7 @@
description.append(tuple(row_descr))
return description
- @obsolete('use direct access to session.transaction_data')
+ @deprecated('use direct access to session.transaction_data')
def query_data(self, key, default=None, setdefault=False, pop=False):
if setdefault:
assert not pop
@@ -494,7 +494,7 @@
else:
return self.transaction_data.get(key, default)
- @obsolete('use entity_from_eid(eid, etype=None)')
+ @deprecated('use entity_from_eid(eid, etype=None)')
def entity(self, eid):
"""return a result set for the given eid"""
return self.eid_rset(eid).get_entity(0, 0)
--- a/server/sqlutils.py Sat Aug 01 00:00:29 2009 +0200
+++ b/server/sqlutils.py Sat Aug 01 00:01:12 2009 +0200
@@ -200,20 +200,21 @@
cmd = self.dbhelper.backup_command(self.dbname, self.dbhost,
self.dbuser, backupfile,
keepownership=False)
- while True:
- print cmd
- if os.system(cmd):
- print '-> error while backuping the base'
- answer = confirm('Continue anyway?',
- shell=False, abort=False, retry=True)
- if not answer:
- raise SystemExit(1)
- if answer == 1: # 1: continue, 2: retry
- break
+ backupdir = os.path.dirname(backupfile)
+ if not os.path.exists(backupdir):
+ if confirm('%s does not exist. Create it?' % backupdir,
+ abort=False, shell=False):
+ os.mkdir(backupdir)
else:
- print '-> backup file', backupfile
- restrict_perms_to_user(backupfile, self.info)
- break
+ print '-> failed to backup instance'
+ return
+ if os.system(cmd):
+ print '-> error trying to backup with command', cmd
+ if not confirm('Continue anyway?', default_is_yes=False):
+ raise SystemExit(1)
+ else:
+ print '-> backup file', backupfile
+ restrict_perms_to_user(backupfile, self.info)
def restore_from_file(self, backupfile, confirm, drop=True):
for cmd in self.dbhelper.restore_commands(self.dbname, self.dbhost,
@@ -224,9 +225,8 @@
while True:
print cmd
if os.system(cmd):
- print 'error while restoring the base'
- print 'OOOOOPS', confirm
- answer = confirm('continue anyway?',
+ print '-> error while restoring the base'
+ answer = confirm('Continue anyway?',
shell=False, abort=False, retry=True)
if not answer:
raise SystemExit(1)
@@ -234,7 +234,7 @@
break
else:
break
- print 'database restored'
+ print '-> database restored.'
def merge_args(self, args, query_args):
if args is not None:
--- a/test/data/schema.py Sat Aug 01 00:00:29 2009 +0200
+++ b/test/data/schema.py Sat Aug 01 00:01:12 2009 +0200
@@ -5,6 +5,9 @@
: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, String, SubjectRelation, RelationDefinition
+
class Personne(EntityType):
nom = String(required=True)
prenom = String()
--- a/toolsutils.py Sat Aug 01 00:00:29 2009 +0200
+++ b/toolsutils.py Sat Aug 01 00:01:12 2009 +0200
@@ -16,7 +16,7 @@
from logilab.common.clcommands import Command as BaseCommand, \
main_run as base_main_run
from logilab.common.compat import any
-from logilab.common.shellutils import confirm
+from logilab.common.shellutils import ASK
from cubicweb import warning
from cubicweb import ConfigurationError, ExecutionError
@@ -72,7 +72,7 @@
if askconfirm:
print
print diffs
- action = raw_input('replace (N/y/q) ? ').lower()
+ action = ASK.ask('Replace ?', ('N','y','q'), 'N')
else:
action = 'y'
if action == 'y':
@@ -117,7 +117,7 @@
if fname.endswith('.tmpl'):
tfpath = tfpath[:-5]
if not askconfirm or not exists(tfpath) or \
- confirm('%s exists, overwrite?' % tfpath):
+ ASK.confirm('%s exists, overwrite?' % tfpath):
fill_templated_file(fpath, tfpath, context)
print '[generate] %s <-- %s' % (tfpath, fpath)
elif exists(tfpath):
--- a/view.py Sat Aug 01 00:00:29 2009 +0200
+++ b/view.py Sat Aug 01 00:01:12 2009 +0200
@@ -11,7 +11,7 @@
from cStringIO import StringIO
-from logilab.common.deprecation import obsolete
+from logilab.common.deprecation import deprecated
from logilab.mtconverter import xml_escape
from cubicweb import NotAnEntity
@@ -150,7 +150,7 @@
if stream is not None:
return self._stream.getvalue()
- dispatch = obsolete('.dispatch is deprecated, use .render')(render)
+ dispatch = deprecated('.dispatch is deprecated, use .render')(render)
# should default .call() method add a <div classs="section"> around each
# rset item
@@ -229,7 +229,7 @@
self.view(__vid, rset, __fallback_vid, w=self.w, **kwargs)
# XXX Template bw compat
- template = obsolete('.template is deprecated, use .view')(wview)
+ template = deprecated('.template is deprecated, use .view')(wview)
def whead(self, data):
self.req.html_headers.write(data)
--- a/web/__init__.py Sat Aug 01 00:00:29 2009 +0200
+++ b/web/__init__.py Sat Aug 01 00:01:12 2009 +0200
@@ -14,7 +14,7 @@
from datetime import datetime, date, timedelta
from simplejson import dumps
-from logilab.common.deprecation import obsolete
+from logilab.common.deprecation import deprecated
from cubicweb.common.uilib import urlquote
from cubicweb.web._exceptions import *
@@ -65,7 +65,7 @@
return json_dumps(function(*args, **kwargs))
return newfunc
-@obsolete('use req.build_ajax_replace_url() instead')
+@deprecated('use req.build_ajax_replace_url() instead')
def ajax_replace_url(nodeid, rql, vid=None, swap=False, **extraparams):
"""builds a replacePageChunk-like url
>>> ajax_replace_url('foo', 'Person P')
--- a/web/application.py Sat Aug 01 00:00:29 2009 +0200
+++ b/web/application.py Sat Aug 01 00:01:12 2009 +0200
@@ -10,7 +10,7 @@
import sys
from time import clock, time
-from logilab.common.deprecation import obsolete
+from logilab.common.deprecation import deprecated
from rql import BadRQLQuery
@@ -272,7 +272,7 @@
finally:
self._logfile_lock.release()
- @obsolete("use vreg.select('controllers', ...)")
+ @deprecated("use vreg.select('controllers', ...)")
def select_controller(self, oid, req):
try:
return self.vreg.select('controllers', oid, req=req, appli=self)
--- a/web/request.py Sat Aug 01 00:00:29 2009 +0200
+++ b/web/request.py Sat Aug 01 00:01:12 2009 +0200
@@ -18,7 +18,7 @@
from rql.utils import rqlvar_maker
from logilab.common.decorators import cached
-from logilab.common.deprecation import obsolete
+from logilab.common.deprecation import deprecated
from logilab.mtconverter import xml_escape
@@ -630,7 +630,7 @@
auth, ex.__class__.__name__, ex)
return None, None
- @obsolete("use parse_accept_header('Accept-Language')")
+ @deprecated("use parse_accept_header('Accept-Language')")
def header_accept_language(self):
"""returns an ordered list of preferred languages"""
return [value.split('-')[0] for value in
--- a/web/views/navigation.py Sat Aug 01 00:00:29 2009 +0200
+++ b/web/views/navigation.py Sat Aug 01 00:01:12 2009 +0200
@@ -11,7 +11,7 @@
from rql.nodes import VariableRef, Constant
from logilab.mtconverter import xml_escape
-from logilab.common.deprecation import obsolete
+from logilab.common.deprecation import deprecated
from cubicweb.interfaces import IPrevNext
from cubicweb.selectors import (paginated_rset, sorted_rset,
@@ -168,7 +168,7 @@
# monkey patch base View class to add a .pagination(req, rset, w, forcedisplay)
# method to be called on view's result set and printing pages index in the view
from cubicweb.view import View
-View.pagination = obsolete('.pagination is deprecated, use paginate')(limit_rset_using_paged_nav)
+View.pagination = deprecated('.pagination is deprecated, use paginate')(limit_rset_using_paged_nav)
def paginate(view, show_all_option=True, w=None, page_size=None):
limit_rset_using_paged_nav(view, view.req, view.rset, w or view.w,
--- a/web/webctl.py Sat Aug 01 00:00:29 2009 +0200
+++ b/web/webctl.py Sat Aug 01 00:01:12 2009 +0200
@@ -9,8 +9,8 @@
__docformat__ = "restructuredtext en"
from cubicweb import underline_title
-from cubicweb.toolsutils import CommandHandler, confirm
-
+from cubicweb.toolsutils import CommandHandler
+from logilab.common.shellutils import ASK
class WebCreateHandler(CommandHandler):
cmdname = 'create'
@@ -22,7 +22,7 @@
if config.repo_method == 'pyro':
print '\n'+underline_title('Repository server configuration')
config.input_config('pyro-client', inputlevel)
- if confirm('Allow anonymous access ?', False):
+ if ASK.confirm('Allow anonymous access ?', False):
config.global_set_option('anonymous-user', 'anon')
config.global_set_option('anonymous-password', 'anon')