Manage default values of trytond configuration
This commit is contained in:
1 parent
a67700145b
commit
cb0714cf43
6 files changed
+20
-9
No files matched your search
@@ -1,2 +1,4 @@
|
||||
* Manage default values of trytond configuration
|
||||
|
||||
Version 1.8.0 - 2010-12-24
|
||||
* Initial release
|
||||
@@ -21,6 +21,8 @@ Configuration to connect to a sqlite memory database using trytond as module.
|
||||
>>> config = config.set_trytond(':memory:', database_type='sqlite')
|
||||
|
||||
When connecting to a database that doesn't exist, Proteus will create it.
|
||||
If no database name was given, then Proteus will generate one. It will choose
|
||||
':memory': for 'sqlite' type otherwise `'test_%' % int(time.time())`.
|
||||
|
||||
Installing a module
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
+12
-5
@@ -10,6 +10,7 @@ import threading
|
||||
from decimal import Decimal
|
||||
from types import NoneType
|
||||
import datetime
|
||||
import time
|
||||
|
||||
def dump_decimal(self, value, write):
|
||||
write("<value><double>")
|
||||
@@ -93,21 +94,27 @@ class TrytondProxy(object):
|
||||
class TrytondConfig(Config):
|
||||
'Configuration for trytond'
|
||||
|
||||
def __init__(self, database_name, user, database_type, language='en_US',
|
||||
password=''):
|
||||
def __init__(self, database_name=None, user='admin', database_type=None,
|
||||
language='en_US', password=''):
|
||||
super(TrytondConfig, self).__init__()
|
||||
from trytond.config import CONFIG
|
||||
CONFIG['db_type'] = database_type
|
||||
CONFIG.parse()
|
||||
if database_type is not None:
|
||||
CONFIG['db_type'] = database_type
|
||||
from trytond.modules import register_classes
|
||||
from trytond.pool import Pool
|
||||
from trytond.backend import Database
|
||||
from trytond.protocols.dispatcher import create
|
||||
from trytond.cache import Cache
|
||||
from trytond.transaction import Transaction
|
||||
self.database_type = CONFIG['db_type']
|
||||
if database_name is None:
|
||||
if self.database_type == 'sqlite':
|
||||
database_name = ':memory:'
|
||||
else:
|
||||
database_name = 'test_%s' % int(time.time())
|
||||
self.database_name = database_name
|
||||
self._user = user
|
||||
self.database_type = database_type
|
||||
|
||||
register_classes()
|
||||
|
||||
@@ -151,7 +158,7 @@ class TrytondConfig(Config):
|
||||
proxy = self.get_proxy(name, type=type)
|
||||
return [x for x in proxy._object._rpc]
|
||||
|
||||
def set_trytond(database_name, user='admin', database_type='postgresql',
|
||||
def set_trytond(database_name=None, user='admin', database_type=None,
|
||||
language='en_US', password=''):
|
||||
'Set trytond package as backend'
|
||||
_CONFIG.current = TrytondConfig(database_name, user, database_type,
|
||||
|
||||
@@ -7,7 +7,7 @@ import proteus.config
|
||||
class TestConfig(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
proteus.config.set_trytond(':memory:', database_type='sqlite')
|
||||
proteus.config.set_trytond(database_type='sqlite')
|
||||
|
||||
def test_proxy(self):
|
||||
config = proteus.config.get_config()
|
||||
@@ -22,7 +22,7 @@ class TestConfig(TestCase):
|
||||
|
||||
def test_trytond_config_eq(self):
|
||||
config1 = proteus.config.get_config()
|
||||
proteus.config.set_trytond(':memory:', database_type='sqlite')
|
||||
proteus.config.set_trytond(database_type='sqlite')
|
||||
config2 = proteus.config.get_config()
|
||||
self.assertEqual(config1, config2)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from proteus import config, Model
|
||||
class TestModel(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
config.set_trytond(':memory:', database_type='sqlite')
|
||||
config.set_trytond(database_type='sqlite')
|
||||
|
||||
def test_class_cache(self):
|
||||
User1 = Model.get('res.user')
|
||||
|
||||
@@ -7,7 +7,7 @@ from proteus import config, Wizard, Model
|
||||
class TestWizard(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
config.set_trytond(':memory:', database_type='sqlite')
|
||||
config.set_trytond(database_type='sqlite')
|
||||
|
||||
def test_translation_clean(self):
|
||||
translation_clean = Wizard('ir.translation.clean')
|
||||
|
||||
Reference in new issue
Block a user