浏览代码

Closes #76: Tracim working with sqlite

Bastien Sevajol (Algoo) 8 年前
父节点
当前提交
df7eccb573
共有 6 个文件被更改,包括 27 次插入10 次删除
  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 查看文件

5
 env:
5
 env:
6
   - DB=postgres
6
   - DB=postgres
7
   - DB=mysql
7
   - DB=mysql
8
+  - DB=sqlite
8
 
9
 
9
 addons:
10
 addons:
10
   postgresql: "9.3"
11
   postgresql: "9.3"
27
   - 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
   - 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
   - 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
   - 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
   - cd ${TRAVIS_BUILD_DIR}/tracim && gearbox setup-app --debug
34
   - cd ${TRAVIS_BUILD_DIR}/tracim && gearbox setup-app --debug
31
 
35
 
32
 # command to run tests
36
 # command to run tests

+ 10 - 2
README.md 查看文件

69
 
69
 
70
 * developed with python >=3.4.
70
 * developed with python >=3.4.
71
 * based on the [TurboGears](http://www.turbogears.org/) web framework.
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
 The user interface is based on the following resources and technologies:
74
 The user interface is based on the following resources and technologies:
75
 
75
 
125
 
125
 
126
     apt-get install mysql-server mysql-client libmysqlclient-dev
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
 ## Installation ##
132
 ## Installation ##
129
 
133
 
130
 ### Get the source ###
134
 ### Get the source ###
263
 At this point, you have :
267
 At this point, you have :
264
 
268
 
265
 * an installation of Tracim with its dedicated python3-ready virtualenv
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
 What you have to do now is to configure the application and to initialize the database content.
272
 What you have to do now is to configure the application and to initialize the database content.
269
 
273
 
283
 
287
 
284
     sqlalchemy.url = mysql+oursql://tracimuser:tracimpassword@127.0.0.1/tracimdb
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
 #### Listening port
294
 #### Listening port
287
 
295
 
288
 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:
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 查看文件

19
 port = 8080
19
 port = 8080
20
 
20
 
21
 [app:main]
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
 use = config:development.ini
23
 use = config:development.ini
24
 
24
 
25
 [app:main_without_authn]
25
 [app:main_without_authn]
27
 skip_authentication = True
27
 skip_authentication = True
28
 
28
 
29
 [app:ldap]
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
 auth_type = ldap
31
 auth_type = ldap
32
 ldap_url = ldap://localhost:3333
32
 ldap_url = ldap://localhost:3333
33
 ldap_base_dn = dc=directory,dc=fsf,dc=org
33
 ldap_base_dn = dc=directory,dc=fsf,dc=org
40
 use = config:development.ini
40
 use = config:development.ini
41
 
41
 
42
 [app:radicale]
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
 use = config:development.ini
45
 use = config:development.ini
46
 
46
 

+ 5 - 2
tracim/tracim/controllers/admin/workspace.py 查看文件

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

+ 2 - 1
tracim/tracim/lib/userworkspace.py 查看文件

92
         role.workspace = workspace
92
         role.workspace = workspace
93
         role.role = role_level
93
         role.role = role_level
94
         if with_notif is not None:
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
         if flush:
97
         if flush:
97
             DBSession.flush()
98
             DBSession.flush()
98
         return role
99
         return role

+ 3 - 2
tracim/tracim/tests/__init__.py 查看文件

135
         tbs.append(t)
135
         tbs.append(t)
136
         all_fks.extend(fks)
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
     for view in views:
142
     for view in views:
142
         drop_statement = 'DROP VIEW {}'.format(view.name)
143
         drop_statement = 'DROP VIEW {}'.format(view.name)