Remove demo on module

It will be handle by specific modules
This commit is contained in:
Cédric Krier committed 2008-02-26 18:21:28 +01:00
1 parent bb44f45b84
commit 1724794f7b
7 files changed
+24 -57

No files matched your search

-7
View File
@@ -34,7 +34,6 @@ class ConfigManager(object):
'smtp_password': False,
'stop_after_init': False,
'data_path': '/var/lib/trytond',
'without_demo': False,
}
parser = optparse.OptionParser(version=VERSION)
@@ -79,9 +78,6 @@ class ConfigManager(object):
group = optparse.OptionGroup(parser, "Modules related options")
group.add_option("-i", "--init", dest="init",
help="init a module (use \"all\" for all modules)")
group.add_option("--without-demo", dest="without_demo",
help="load demo data for a module " \
"(use \"all\" for all modules)")
group.add_option("-u", "--update", dest="update",
help="update a module (use \"all\" for all modules)")
parser.add_option_group(group)
@@ -162,7 +158,6 @@ class ConfigManager(object):
'verbose',
'debug_mode',
'stop_after_init',
'without_demo',
'netrpc',
'xmlrpc',
'webdav',
@@ -175,8 +170,6 @@ class ConfigManager(object):
for i in opt.init.split(','):
init[i] = 1
self.options['init'] = init
self.options["demo"] = not opt.without_demo \
and self.options['init'] or {}
update = {}
if opt.update:
-1
View File
@@ -236,7 +236,6 @@ CREATE TABLE ir_module_module (
shortdesc character varying(256),
category integer REFERENCES ir_module_category ON DELETE SET NULL,
description text,
demo boolean default False,
primary key(id)
);
ALTER TABLE ir_module_module add constraint name_uniq unique (name);
+3 -17
View File
@@ -147,7 +147,6 @@ class Module(OSV):
('to remove', 'To be removed'),
('to install', 'To be installed'),
], string='State', readonly=True)
demo = fields.Boolean('Demo data')
license = fields.Selection([('GPL-2', 'GPL-2'),
('Other proprietary', 'Other proprietary')], string='License',
readonly=True)
@@ -160,9 +159,6 @@ class Module(OSV):
def default_state(self, cursor, user, context=None):
return 'uninstalled'
def default_demo(self, cursor, user, context=None):
return False
def default_license(self, cursor, user, context=None):
return 'GPL-2'
@@ -242,21 +238,12 @@ class Module(OSV):
parents2 += get_parents(parent, graph)
return parents + parents2
dependencies = get_parents(module.name, graph)
module_dep_ids = self.search(cursor, user, [
module_install_ids = self.search(cursor, user, [
('name', 'in', dependencies),
('state', '=', 'uninstalled'),
], context=context)
demo = True
module_install_ids = [module.id]
for module_dep in self.browse(cursor, user, module_dep_ids,
context=context):
if module_dep.state != 'uninstalled':
if not module_dep.demo:
demo = False
else:
module_install_ids.append(module_dep.id)
self.write(cursor, user, module_install_ids, {
self.write(cursor, user, module_install_ids + [module.id], {
'state': 'to install',
'demo': demo,
}, context=context)
def state_upgrade(self, cursor, user, ids, context=None):
@@ -291,7 +278,6 @@ class Module(OSV):
def button_install_cancel(self, cursor, user, ids, context=None):
self.write(cursor, user, ids, {
'state': 'uninstalled',
'demo': False,
}, context=context)
return True
-2
View File
@@ -28,8 +28,6 @@
<field name="url" widget="url"/>
<label name="license"/>
<field name="license"/>
<label name="demo"/>
<field name="demo" readonly="1"/>
<newline/>
<label name="state"/>
<field name="state" readonly="1"/>
+8 -15
View File
@@ -72,7 +72,7 @@ class Node(Singleton):
node.depth = self.depth + 1
if node not in self.childs:
self.childs.append(node)
for attr in ('init', 'update', 'demo'):
for attr in ('init', 'update'):
if hasattr(self, attr):
setattr(node, attr, True)
self.childs.sort(lambda x, y: cmp(x.name, y.name))
@@ -83,7 +83,7 @@ class Node(Singleton):
def __setattr__(self, name, value):
super(Node, self).__setattr__(name, value)
if name in ('init', 'update', 'demo'):
if name in ('init', 'update'):
for child in self.childs:
setattr(child, name, value)
if name == 'depth':
@@ -143,7 +143,7 @@ def create_graph(module_list, force=None):
graph.add_node(package, deps)
node = Node(package, graph)
node.datas = datas
for kind in ('init', 'update', 'demo'):
for kind in ('init', 'update'):
if (package in CONFIG[kind]) \
or ('all' in CONFIG[kind]) \
or (kind in force):
@@ -187,18 +187,16 @@ def load_module_graph(cursor, graph, lang=None):
wizards = pool_wizard.instanciate(module, pool)
pool_report = pooler.get_pool_report(cursor.dbname)
reports = pool_report.instanciate(module, pool)
cursor.execute('SELECT state, demo FROM ir_module_module WHERE name = %s',
cursor.execute('SELECT state FROM ir_module_module WHERE name = %s',
(module,))
(package_state, package_demo) = (cursor.rowcount and cursor.fetchone()) \
or ('uninstalled', False)
package_state = (cursor.rowcount and cursor.fetchone()[0]) \
or 'uninstalled'
idref = {}
if hasattr(package, 'init') \
or hasattr(package, 'update') \
or (package_state in ('to install', 'to upgrade')):
init_module_objects(cursor, module, modules)
init_module_wizards(cursor, module, wizards)
demo = hasattr(package, 'demo') \
or (package_demo and package_state != 'installed')
for filename in package.datas.get('xml', []):
mode = 'update'
if hasattr(package, 'init') or package_state=='to install':
@@ -226,9 +224,6 @@ def load_module_graph(cursor, graph, lang=None):
translation_obj = pool.get('ir.translation')
translation_obj.translation_import(cursor, 0, lang2, module,
tools.file_open(OPJ(module, filename)))
if demo:
cursor.execute('UPDATE ir_module_module SET demo = %s ' \
'WHERE name = %s', (True, package.name))
package_todo.append(package.name)
cursor.execute("UPDATE ir_module_module SET state = 'installed' " \
"WHERE name = %s", (package.name,))
@@ -276,11 +271,9 @@ def register_classes():
Logger().notify_channel('init', LOG_ERROR,
'Couldn\'t find module %s' % module)
def load_modules(database, force_demo=False, update_module=False, lang=None):
def load_modules(database, update_module=False, lang=None):
cursor = database.cursor()
force = []
if force_demo:
force.append('demo')
if update_module:
cursor.execute("SELECT name FROM ir_module_module " \
"WHERE state IN ('installed', 'to install', " \
@@ -300,7 +293,7 @@ def load_modules(database, force_demo=False, update_module=False, lang=None):
load_module_graph(cursor, graph, lang)
for kind in ('init', 'update', 'demo'):
for kind in ('init', 'update'):
CONFIG[kind] = {}
if update_module:
+11 -13
View File
@@ -6,8 +6,8 @@ _POOL = {}
_POOL_WIZARD = {}
_POOL_REPORT = {}
def get_db_and_pool(db_name, force_demo=False, update_module=False,
wizard=False, report=False, lang=None):
def get_db_and_pool(db_name, update_module=False, wizard=False, report=False,
lang=None):
if db_name in _DB:
database = _DB[db_name]
else:
@@ -36,7 +36,7 @@ def get_db_and_pool(db_name, force_demo=False, update_module=False,
_POOL_REPORT[db_name] = pool_report
from module import load_modules
load_modules(database, force_demo, update_module, lang)
load_modules(database, update_module, lang)
if not update_module:
pool.get('ir.cron').pool_jobs(database.dbname)
@@ -46,12 +46,11 @@ def get_db_and_pool(db_name, force_demo=False, update_module=False,
return database, pool_report
return database, pool
def restart_pool(db_name, force_demo=False, update_module=False, lang=None):
def restart_pool(db_name, update_module=False, lang=None):
del _POOL[db_name]
del _POOL_WIZARD[db_name]
del _POOL_REPORT[db_name]
return get_db_and_pool(db_name, force_demo, update_module=update_module,
lang=lang)
return get_db_and_pool(db_name, update_module=update_module, lang=lang)
def close_db(db_name):
if db_name in _DB:
@@ -73,16 +72,15 @@ def get_db_only(db_name):
def get_db(db_name):
return get_db_and_pool(db_name)[0]
def get_pool(db_name, force_demo=False, update_module=False, lang=None):
pool = get_db_and_pool(db_name, force_demo, update_module, lang=lang)[1]
def get_pool(db_name, update_module=False, lang=None):
pool = get_db_and_pool(db_name, update_module, lang=lang)[1]
return pool
def get_pool_wizard(db_name, force_demo=False, update_module=False, lang=None):
pool = get_db_and_pool(db_name, force_demo, update_module, wizard=True,
def get_pool_wizard(db_name, update_module=False, lang=None):
pool = get_db_and_pool(db_name, update_module, wizard=True,
lang=lang)[1]
return pool
def get_pool_report(db_name, force_demo=False, update_module=False, lang=None):
pool = get_db_and_pool(db_name, force_demo, update_module, report=True,
lang=lang)[1]
def get_pool_report(db_name, update_module=False, lang=None):
pool = get_db_and_pool(db_name, update_module, report=True, lang=lang)[1]
return pool
+2 -2
View File
@@ -23,7 +23,7 @@ class DB(Service):
self.export_method(self.list_lang)
self.export_method(self.change_admin_password)
def create(self, password, db_name, demo, lang):
def create(self, password, db_name, lang):
security.check_super(password)
res = False
@@ -43,7 +43,7 @@ class DB(Service):
cursor.commit()
cursor.close()
cursor = None
pooler.get_pool(db_name, demo, update_module=True, lang=[lang])
pooler.get_pool(db_name, update_module=True, lang=[lang])
cursor = sql_db.db_connect(db_name).cursor()
if lang != 'en_US':
cursor.execute('UPDATE ir_lang ' \