Browse Source

Switch to explicitly wrapping nilmdb objects in a serializer_proxy

This is quite a bit simpler than the class decorator method, so it
may be more reliable.
tags/nilmdb-1.2
Jim Paris 9 years ago
parent
commit
dfbbe23512
5 changed files with 12 additions and 9 deletions
  1. +3
    -2
      nilmdb/scripts/nilmdb_server.py
  2. +0
    -1
      nilmdb/server/nilmdb.py
  3. +1
    -1
      tests/test_client.py
  4. +4
    -3
      tests/test_cmdline.py
  5. +4
    -2
      tests/test_nilmdb.py

+ 3
- 2
nilmdb/scripts/nilmdb_server.py View File

@@ -33,8 +33,9 @@ def main():

args = parser.parse_args()

# Create database object
db = nilmdb.server.NilmDB(args.database)
# Create database object. Needs to be serialized before passing
# to the Server.
db = nilmdb.utils.serializer_proxy(NilmDB, args.database)

# Configure the server
if args.quiet:


+ 0
- 1
nilmdb/server/nilmdb.py View File

@@ -73,7 +73,6 @@ _sql_schema_updates = {
""",
}

@nilmdb.utils.serialized()
@nilmdb.utils.must_close()
class NilmDB(object):
verbose = 0


+ 1
- 1
tests/test_client.py View File

@@ -31,7 +31,7 @@ def setup_module():
recursive_unlink(testdb)

# Start web app on a custom port
test_db = nilmdb.NilmDB(testdb, sync = False)
test_db = nilmdb.utils.serializer_proxy(nilmdb.NilmDB, testdb, sync = False)
test_server = nilmdb.Server(test_db, host = "127.0.0.1",
port = 12380, stoppable = False,
fast_shutdown = True,


+ 4
- 3
tests/test_cmdline.py View File

@@ -27,9 +27,10 @@ testdb = "tests/cmdline-testdb"
def server_start(max_results = None, bulkdata_args = {}):
global test_server, test_db
# Start web app on a custom port
test_db = nilmdb.NilmDB(testdb, sync = False,
max_results = max_results,
bulkdata_args = bulkdata_args)
test_db = nilmdb.utils.serializer_proxy(nilmdb.NilmDB,
testdb, sync = False,
max_results = max_results,
bulkdata_args = bulkdata_args)
test_server = nilmdb.Server(test_db, host = "127.0.0.1",
port = 12380, stoppable = False,
fast_shutdown = True,


+ 4
- 2
tests/test_nilmdb.py View File

@@ -104,7 +104,8 @@ class Test00Nilmdb(object): # named 00 so it runs first

class TestBlockingServer(object):
def setUp(self):
self.db = nilmdb.NilmDB(testdb, sync=False)
self.db = nilmdb.utils.serializer_proxy(nilmdb.NilmDB,
testdb, sync=False)

def tearDown(self):
self.db.close()
@@ -140,7 +141,8 @@ class TestServer(object):

def setUp(self):
# Start web app on a custom port
self.db = nilmdb.NilmDB(testdb, sync=False)
self.db = nilmdb.utils.serializer_proxy(
nilmdb.NilmDB, testdb, sync=False)
self.server = nilmdb.Server(self.db, host = "127.0.0.1",
port = 12380, stoppable = False)
self.server.start(blocking = False)


Loading…
Cancel
Save