changeset 1312:1a2c41efc382

sqla store: use same method as sqlite store to append ::tablename, fix tests/docs
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 25 Mar 2012 03:07:21 +0200
parents bc7d15a2a06c
children 4ce43f664d82
files MoinMoin/storage/stores/_tests/test_sqla.py MoinMoin/storage/stores/sqla.py docs/admin/configure.rst
diffstat 3 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/storage/stores/_tests/test_sqla.py	Sun Mar 25 01:03:11 2012 +0100
+++ b/MoinMoin/storage/stores/_tests/test_sqla.py	Sun Mar 25 03:07:21 2012 +0200
@@ -30,6 +30,6 @@
 
 @pytest.mark.multi(Store=[BytesStore, FileStore])
 def test_from_uri(tmpdir, Store):
-    store = Store.from_uri("sqlite://%s/test_base" % tmpdir)
-    assert store.db_uri == "sqlite://%s/test_base" % tmpdir
+    store = Store.from_uri("sqlite://%s::test_base" % tmpdir)
+    assert store.db_uri == "sqlite://%s" % tmpdir
     assert store.table_name == "test_base"
--- a/MoinMoin/storage/stores/sqla.py	Sun Mar 25 01:03:11 2012 +0100
+++ b/MoinMoin/storage/stores/sqla.py	Sun Mar 25 03:07:21 2012 +0200
@@ -33,11 +33,8 @@
         :param cls: Class to create
         :param uri: The database uri that we pass on to SQLAlchemy.
         """
-
-        params = [uri]
-        if '/' in uri.rsplit("//")[-1]:
-            table_name = uri.rsplit("/")[-1]
-            params.append(table_name)
+        params = uri.split("::") # using "::" to support windows pathnames that
+                                 # may include ":" after the drive letter.
         return cls(*params)
 
     def __init__(self, db_uri=None, table_name='store', verbose=False):
--- a/docs/admin/configure.rst	Sun Mar 25 01:03:11 2012 +0100
+++ b/docs/admin/configure.rst	Sun Mar 25 03:07:21 2012 +0200
@@ -1131,6 +1131,8 @@
 Features:
 
 * stores data into an (SQL) database / table
+* can either use 1 database per store or 1 table per store (you need to
+  give different table names then)
 * uses slqalchemy (without the ORM) for database abstraction
 * supports multiple types of databases. For example:
  
@@ -1141,11 +1143,16 @@
 
 `uri` for `create_simple_mapping` looks like e.g.::
 
-    stores:sqla:sqlite:////srv/mywiki/data/mywiki_%(nsname)s.db
-    stores:sqla:mysql://myuser:mypassword@localhost/mywiki_%(nsname)s
-    stores:sqla:postgres://myuser:mypassword@localhost/mywiki_%(nsname)s
+    stores:sqla:sqlite:////srv/mywiki/data/mywiki_%(nsname)s_%(kind).db
+    stores:sqla:sqlite:////srv/mywiki/data/mywiki_%(nsname)s.db::%(kind)s
+    stores:sqla:mysql://myuser:mypassword@localhost/mywiki_%(nsname)s::%(kind)s
+    stores:sqla:postgres://myuser:mypassword@localhost/mywiki_%(nsname)s::%(kind)s
 
-Please see the sqlalchemy docs about the part after `sqla:`.
+The uri part after "sqla:" is like::
+
+    DBURI::TABLENAME
+
+Please see the sqlalchemy docs about the DBURI part.
 
 Grant 'myuser' (his password: 'mypassword') full access to these databases.
 
@@ -1163,9 +1170,9 @@
  
 `uri` for `create_simple_mapping` looks like e.g.::
 
-    stores:sqlite:/srv/mywiki/data/mywiki_%(nsname)s.db
-    stores:sqlite:/srv/mywiki/data/mywiki.db::%(nsname)s
-    stores:sqlite:/srv/mywiki/data/mywiki.db::%(nsname)s::1
+    stores:sqlite:/srv/mywiki/data/mywiki_%(nsname)s_%(kind)s.db
+    stores:sqlite:/srv/mywiki/data/mywiki_%(nsname)s.db::%(kind)s
+    stores:sqlite:/srv/mywiki/data/mywiki_%(nsname)s.db::%(kind)s::1
 
 The uri part after "sqlite:" is like::