Bladeren bron

Closes #76: Tracim working with sqlite

Bastien Sevajol (Algoo) 7 jaren geleden
bovenliggende
commit
df7eccb573
6 gewijzigde bestanden met toevoegingen van 27 en 10 verwijderingen
  1. 4 0
      .travis.yml
  2. 10 2
      README.md
  3. 3 3
      tracim/test.ini
  4. 5 2
      tracim/tracim/controllers/admin/workspace.py
  5. 2 1
      tracim/tracim/lib/userworkspace.py
  6. 3 2
      tracim/tracim/tests/__init__.py

+ 4 - 0
.travis.yml Bestand weergeven

@@ -5,6 +5,7 @@ python: "3.4"
5 5
 env:
6 6
   - DB=postgres
7 7
   - DB=mysql
8
+  - DB=sqlite
8 9
 
9 10
 addons:
10 11
   postgresql: "9.3"
@@ -27,6 +28,9 @@ before_script:
27 28
   - sh -c "if [ '$DB' = 'mysql' ]; then cd ${TRAVIS_BUILD_DIR}/tracim && sed -i \"s/<replace_database_uri_here>/mysql+oursql:\/\/root@localhost\/tracim_test/\" development.ini; fi"
28 29
   - sh -c "if [ '$DB' = 'mysql' ]; then pip install https://launchpad.net/oursql/py3k/py3k-0.9.4/+download/oursql-0.9.4.zip; fi"
29 30
 
31
+  - sh -c "if [ '$DB' = 'sqlite' ]; then cd ${TRAVIS_BUILD_DIR}/tracim && sed -i \"s/\(sqlalchemy.url *= *\).*/\sqlite:\/\/\/tracim_test.sqlite/\" test.ini; fi"
32
+  - sh -c "if [ '$DB' = 'sqlite' ]; then cd ${TRAVIS_BUILD_DIR}/tracim && sed -i \"s/<replace_database_uri_here>/sqlite:\/\/\/tracim.sqlite/\" development.ini; fi"
33
+
30 34
   - cd ${TRAVIS_BUILD_DIR}/tracim && gearbox setup-app --debug
31 35
 
32 36
 # command to run tests

+ 10 - 2
README.md Bestand weergeven

@@ -69,7 +69,7 @@ Tracim is a web application:
69 69
 
70 70
 * developed with python >=3.4.
71 71
 * based on the [TurboGears](http://www.turbogears.org/) web framework.
72
-* relying on [PostgreSQL](http://www.postgresql.org/) or [MySQL](https://www.mysql.fr/) as the storage engine.
72
+* relying on [PostgreSQL](http://www.postgresql.org/) or [MySQL](https://www.mysql.fr/) or [sqlite](https://www.sqlite.org/) as the storage engine.
73 73
 
74 74
 The user interface is based on the following resources and technologies:
75 75
 
@@ -125,6 +125,10 @@ Or if you want to use MySQL as database engine
125 125
 
126 126
     apt-get install mysql-server mysql-client libmysqlclient-dev
127 127
 
128
+Or if you want to use SQLite as database engine
129
+
130
+    apt-get install sqlite3
131
+
128 132
 ## Installation ##
129 133
 
130 134
 ### Get the source ###
@@ -263,7 +267,7 @@ You can now quit mysql prompt:
263 267
 At this point, you have :
264 268
 
265 269
 * an installation of Tracim with its dedicated python3-ready virtualenv
266
-* a PostgreSQL/MySQL server and dedicated database
270
+* a PostgreSQL/MySQL server and dedicated database (if you don't use sqlite)
267 271
 
268 272
 What you have to do now is to configure the application and to initialize the database content.
269 273
 
@@ -283,6 +287,10 @@ There is an example value for MySQL below (please refer to Configuration/databas
283 287
 
284 288
     sqlalchemy.url = mysql+oursql://tracimuser:tracimpassword@127.0.0.1/tracimdb
285 289
 
290
+There is an example value for SQLite below :
291
+
292
+    sqlalchemy.url = sqlite:///tracimdb.sqlite
293
+
286 294
 #### Listening port
287 295
 
288 296
 Default configuration is to listen on port 8080. If you want to adapt this to your environment, edit the .ini file and setup the port you want:

+ 3 - 3
tracim/test.ini Bestand weergeven

@@ -19,7 +19,7 @@ host = 127.0.0.1
19 19
 port = 8080
20 20
 
21 21
 [app:main]
22
-sqlalchemy.url = postgresql://postgres:dummy@127.0.0.1:5432/tracim_test?client_encoding=utf8
22
+sqlalchemy.url = sqlite:///tracim_test.sqlite
23 23
 use = config:development.ini
24 24
 
25 25
 [app:main_without_authn]
@@ -27,7 +27,7 @@ use = main
27 27
 skip_authentication = True
28 28
 
29 29
 [app:ldap]
30
-sqlalchemy.url = postgresql://postgres:dummy@127.0.0.1:5432/tracim_test?client_encoding=utf8
30
+sqlalchemy.url = sqlite:///tracim_test.sqlite
31 31
 auth_type = ldap
32 32
 ldap_url = ldap://localhost:3333
33 33
 ldap_base_dn = dc=directory,dc=fsf,dc=org
@@ -40,7 +40,7 @@ ldap_group_enabled = False
40 40
 use = config:development.ini
41 41
 
42 42
 [app:radicale]
43
-sqlalchemy.url = postgresql://postgres:dummy@127.0.0.1:5432/tracim_test?client_encoding=utf8
43
+sqlalchemy.url = sqlite:///tracim_test.sqlite
44 44
 
45 45
 use = config:development.ini
46 46
 

+ 5 - 2
tracim/tracim/controllers/admin/workspace.py Bestand weergeven

@@ -10,6 +10,7 @@ from tracim.controllers import TIMRestPathContextSetup
10 10
 
11 11
 from tracim.lib import CST
12 12
 from tracim.lib.base import BaseController
13
+from tracim.lib.helpers import on_off_to_boolean
13 14
 from tracim.lib.user import UserApi
14 15
 from tracim.lib.userworkspace import RoleApi
15 16
 from tracim.lib.content import ContentApi
@@ -191,10 +192,11 @@ class WorkspaceRestController(TIMRestController, BaseController):
191 192
         return dict(result = dictified_workspace, fake_api = fake_api)
192 193
 
193 194
     @tg.expose()
194
-    def post(self, name, description, calendar_enabled=False):
195
+    def post(self, name, description, calendar_enabled: str='off'):
195 196
         # FIXME - Check user profile
196 197
         user = tmpl_context.current_user
197 198
         workspace_api_controller = WorkspaceApi(user)
199
+        calendar_enabled = on_off_to_boolean(calendar_enabled)
198 200
 
199 201
         workspace = workspace_api_controller.create_workspace(name, description)
200 202
         workspace.calendar_enabled = calendar_enabled
@@ -215,9 +217,10 @@ class WorkspaceRestController(TIMRestController, BaseController):
215 217
         return DictLikeClass(result = dictified_workspace)
216 218
 
217 219
     @tg.expose('tracim.templates.workspace.edit')
218
-    def put(self, id, name, description, calendar_enabled=False):
220
+    def put(self, id, name, description, calendar_enabled: str='off'):
219 221
         user = tmpl_context.current_user
220 222
         workspace_api_controller = WorkspaceApi(user)
223
+        calendar_enabled = on_off_to_boolean(calendar_enabled)
221 224
 
222 225
         workspace = workspace_api_controller.get_one(id)
223 226
         workspace.label = name

+ 2 - 1
tracim/tracim/lib/userworkspace.py Bestand weergeven

@@ -92,7 +92,8 @@ class RoleApi(object):
92 92
         role.workspace = workspace
93 93
         role.role = role_level
94 94
         if with_notif is not None:
95
-            role.do_notify = with_notif
95
+            from tracim.lib.helpers import on_off_to_boolean
96
+            role.do_notify = on_off_to_boolean(with_notif)
96 97
         if flush:
97 98
             DBSession.flush()
98 99
         return role

+ 3 - 2
tracim/tracim/tests/__init__.py Bestand weergeven

@@ -135,8 +135,9 @@ def teardown_db():
135 135
         tbs.append(t)
136 136
         all_fks.extend(fks)
137 137
 
138
-    for fkc in all_fks:
139
-        connection.execute(DropConstraint(fkc))
138
+    if not config['sqlalchemy.url'].startswith('sqlite'):
139
+        for fkc in all_fks:
140
+            connection.execute(DropConstraint(fkc))
140 141
 
141 142
     for view in views:
142 143
         drop_statement = 'DROP VIEW {}'.format(view.name)