Mercurial > p > roundup > code
annotate roundup/instance.py @ 7752:b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
Converting to using the ruff linter and its rulesets. Fixed a number
of issues.
admin.py:
sort imports
use immutable tuples as default value markers for parameters where a
None value is valid.
reduced some loops to list comprehensions for performance
used ternary to simplify some if statements
named some variables to make them less magic
(e.g. _default_savepoint_setting = 1000)
fixed some tests for argument counts < 2 becomes != 2 so 3 is an
error.
moved exception handlers outside of loops for performance where
exception handler will abort loop anyway.
renamed variables called 'id' or 'dir' as they shadow builtin
commands.
fix translations of form _("string %s" % value) -> _("string %s") %
value so translation will be looked up with the key before
substitution.
end dicts, tuples with a trailing comma to reduce missing comma
errors if modified
simplified sorted(list(self.setting.keys())) to
sorted(self.setting.keys()) as sorted consumes whole list.
in if conditions put compared variable on left and threshold condition
on right. (no yoda conditions)
multiple noqa: suppression
removed unneeded noqa as lint rulesets are a bit different
do_get - refactor output printing logic: Use fast return if not
special formatting is requested; use isinstance with a tuple
rather than two isinstance calls; cleaned up flow and removed
comments on algorithm as it can be easily read from the code.
do_filter, do_find - refactor output printing logic. Reduce
duplicate code.
do_find - renamed variable 'value' that was set inside a loop. The
loop index variable was also named 'value'.
do_pragma - added hint to use list subcommand if setting was not
found. Replaced condition 'type(x) is bool' with 'isinstance(x,
bool)' for various types.
test_admin.py
added testing for do_list
better test coverage for do_get includes: -S and -d for multilinks,
error case for -d with non-link.
better testing for do_find including all output modes
better testing for do_filter including all output modes
fixed expected output for do_pragma that now includes hint to use
pragma list if setting not found.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Fri, 01 Mar 2024 14:53:18 -0500 |
| parents | 771d7c43c76f |
| children | 78585199552a 1045425c23b2 |
| rev | line source |
|---|---|
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
1 # |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/) |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
3 # This module is free software, and you may redistribute it and/or modify |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
4 # under the same terms as Python, so long as this copyright message and |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
5 # disclaimer are retained in their original form. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
6 # |
| 214 | 7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR |
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
10 # POSSIBILITY OF SUCH DAMAGE. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
11 # |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
|
2621
d344419d599d
use new style config;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2584
diff
changeset
|
17 # |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 |
| 4388 | 19 """Top-level tracker interface. |
| 20 | |
| 21 Open a tracker with: | |
|
406
bdc2ea127ae9
Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents:
380
diff
changeset
|
22 |
| 4388 | 23 >>> from roundup import instance |
| 24 >>> db = instance.open('path to tracker home') | |
| 25 | |
| 26 The "db" handle you get back is the tracker's hyperdb which has the interface | |
| 4395 | 27 described in `roundup.hyperdb.Database`. |
| 4083 | 28 """ |
|
2005
fc52d57c6c3e
documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents:
1953
diff
changeset
|
29 __docformat__ = 'restructuredtext' |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 |
|
5383
6fbb7d52e38f
Python 3 preparation: use open() instead of file().
Joseph Myers <jsm@polyomino.org.uk>
parents:
5381
diff
changeset
|
31 try: |
|
6fbb7d52e38f
Python 3 preparation: use open() instead of file().
Joseph Myers <jsm@polyomino.org.uk>
parents:
5381
diff
changeset
|
32 import builtins |
|
6fbb7d52e38f
Python 3 preparation: use open() instead of file().
Joseph Myers <jsm@polyomino.org.uk>
parents:
5381
diff
changeset
|
33 except ImportError: |
|
6fbb7d52e38f
Python 3 preparation: use open() instead of file().
Joseph Myers <jsm@polyomino.org.uk>
parents:
5381
diff
changeset
|
34 import __builtin__ as builtins |
|
6fbb7d52e38f
Python 3 preparation: use open() instead of file().
Joseph Myers <jsm@polyomino.org.uk>
parents:
5381
diff
changeset
|
35 |
|
5810
5258e89e896a
Fix: DeprecationWarning: Using or importing the ABCs from 'collections'
John Rouillard <rouilj@ieee.org>
parents:
5406
diff
changeset
|
36 try: |
|
5258e89e896a
Fix: DeprecationWarning: Using or importing the ABCs from 'collections'
John Rouillard <rouilj@ieee.org>
parents:
5406
diff
changeset
|
37 from collections.abc import Callable |
|
5258e89e896a
Fix: DeprecationWarning: Using or importing the ABCs from 'collections'
John Rouillard <rouilj@ieee.org>
parents:
5406
diff
changeset
|
38 except ImportError: |
|
5258e89e896a
Fix: DeprecationWarning: Using or importing the ABCs from 'collections'
John Rouillard <rouilj@ieee.org>
parents:
5406
diff
changeset
|
39 from collections import Callable |
|
5258e89e896a
Fix: DeprecationWarning: Using or importing the ABCs from 'collections'
John Rouillard <rouilj@ieee.org>
parents:
5406
diff
changeset
|
40 |
|
1780
d2801a2b0a77
Initial implementation (half-baked) at new Tracker instance.
Richard Jones <richard@users.sourceforge.net>
parents:
1174
diff
changeset
|
41 import os |
|
3771
bf660e65ba45
Directory structure changes.
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
2977
diff
changeset
|
42 import sys |
|
5041
5251e97b1de0
Configure the database backend in the config.ini
John Kristensen <john@jerrykan.com>
parents:
4781
diff
changeset
|
43 |
|
2977
9c8de04a76b1
unit test fixes
Richard Jones <richard@users.sourceforge.net>
parents:
2933
diff
changeset
|
44 from roundup import configuration, mailgw |
| 4083 | 45 from roundup import hyperdb, backends, actions |
|
2851
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
46 from roundup.cgi import client, templating |
| 4083 | 47 from roundup.cgi import actions as cgi_actions |
|
6123
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6010
diff
changeset
|
48 from roundup.exceptions import RoundupException |
|
1780
d2801a2b0a77
Initial implementation (half-baked) at new Tracker instance.
Richard Jones <richard@users.sourceforge.net>
parents:
1174
diff
changeset
|
49 |
|
6010
8ccb41b477d1
Flake8 cleanup. Formating only no code changes.
John Rouillard <rouilj@ieee.org>
parents:
5810
diff
changeset
|
50 |
|
1780
d2801a2b0a77
Initial implementation (half-baked) at new Tracker instance.
Richard Jones <richard@users.sourceforge.net>
parents:
1174
diff
changeset
|
51 class Tracker: |
|
2851
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
52 def __init__(self, tracker_home, optimize=0): |
|
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
53 """New-style tracker instance constructor |
|
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
54 |
|
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
55 Parameters: |
|
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
56 tracker_home: |
|
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
57 tracker home directory |
|
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
58 optimize: |
|
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
59 if set, precompile html templates |
|
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
60 |
|
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
61 """ |
|
1780
d2801a2b0a77
Initial implementation (half-baked) at new Tracker instance.
Richard Jones <richard@users.sourceforge.net>
parents:
1174
diff
changeset
|
62 self.tracker_home = tracker_home |
|
2851
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
63 self.optimize = optimize |
|
2647
8c46091c36d0
Main Roundup configuration class renamed to CoreConfig.
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2638
diff
changeset
|
64 self.config = configuration.CoreConfig(tracker_home) |
| 4083 | 65 self.actions = {} |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
66 self.cgi_actions = {} |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
67 self.templating_utils = {} |
|
4588
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
68 |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
69 libdir = os.path.join(self.tracker_home, 'lib') |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
70 self.libdir = os.path.isdir(libdir) and libdir or '' |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
71 |
|
4592
7b7cfb4b00eb
Fix improvements on instance.py.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4588
diff
changeset
|
72 self.load_interfaces() |
|
4721
ec359e7c6c95
Rename templating.get_templates to get_loader
anatoly techtonik <techtonik@gmail.com>
parents:
4720
diff
changeset
|
73 self.templates = templating.get_loader(self.config["TEMPLATES"], |
|
6010
8ccb41b477d1
Flake8 cleanup. Formating only no code changes.
John Rouillard <rouilj@ieee.org>
parents:
5810
diff
changeset
|
74 self.config["TEMPLATE_ENGINE"]) |
|
5041
5251e97b1de0
Configure the database backend in the config.ini
John Kristensen <john@jerrykan.com>
parents:
4781
diff
changeset
|
75 |
|
5251e97b1de0
Configure the database backend in the config.ini
John Kristensen <john@jerrykan.com>
parents:
4781
diff
changeset
|
76 rdbms_backend = self.config.RDBMS_BACKEND |
|
5251e97b1de0
Configure the database backend in the config.ini
John Kristensen <john@jerrykan.com>
parents:
4781
diff
changeset
|
77 |
|
5251e97b1de0
Configure the database backend in the config.ini
John Kristensen <john@jerrykan.com>
parents:
4781
diff
changeset
|
78 self.backend = backends.get_backend(rdbms_backend) |
|
4592
7b7cfb4b00eb
Fix improvements on instance.py.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4588
diff
changeset
|
79 |
|
2851
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
80 if self.optimize: |
|
4748
e339583eae8e
templating: rename precompileTemplates to precompile
anatoly techtonik <techtonik@gmail.com>
parents:
4722
diff
changeset
|
81 self.templates.precompile() |
|
2891
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
82 # initialize tracker extensions |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
83 for extension in self.get_extensions('extensions'): |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
84 extension(self) |
|
2902
f50b867747c9
if optimize is set, load the schema file in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2891
diff
changeset
|
85 # load database schema |
|
4588
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
86 self.schema = self._compile('schema.py') |
|
2891
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
87 # load database detectors |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
88 self.detectors = self.get_extensions('detectors') |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
89 # db_open is set to True after first open() |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
90 self.db_open = 0 |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
91 |
|
2796
7f1e17aeca1b
journaltag is optional
Richard Jones <richard@users.sourceforge.net>
parents:
2736
diff
changeset
|
92 def open(self, name=None): |
|
2891
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
93 # load the database schema |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
94 # we cannot skip this part even if self.optimize is set |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
95 # because the schema has security settings that must be |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
96 # applied to each database instance |
|
2890
938915fbcb49
get_backend_name() is a lengthy thing (file I/O).
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2856
diff
changeset
|
97 backend = self.backend |
|
4588
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
98 env = { |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
99 'Class': backend.Class, |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
100 'FileClass': backend.FileClass, |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
101 'IssueClass': backend.IssueClass, |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
102 'String': hyperdb.String, |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
103 'Password': hyperdb.Password, |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
104 'Date': hyperdb.Date, |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
105 'Link': hyperdb.Link, |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
106 'Multilink': hyperdb.Multilink, |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
107 'Interval': hyperdb.Interval, |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
108 'Boolean': hyperdb.Boolean, |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
109 'Number': hyperdb.Number, |
|
5067
e424987d294a
Add support for an integer type to join the existing number type.
John Rouillard <rouilj@ieee.org>
parents:
5041
diff
changeset
|
110 'Integer': hyperdb.Integer, |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
111 'db': backend.Database(self.config, name) |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
112 } |
|
1780
d2801a2b0a77
Initial implementation (half-baked) at new Tracker instance.
Richard Jones <richard@users.sourceforge.net>
parents:
1174
diff
changeset
|
113 |
|
2891
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
114 if self.optimize: |
|
2902
f50b867747c9
if optimize is set, load the schema file in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2891
diff
changeset
|
115 # execute preloaded schema object |
|
4606
48b73776601c
More fix for improvements on instance.py.
Cheer Xiao <xiaqqaix@gmail.com>
parents:
4592
diff
changeset
|
116 self._exec(self.schema, env) |
|
2891
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
117 # use preloaded detectors |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
118 detectors = self.detectors |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
119 else: |
|
2902
f50b867747c9
if optimize is set, load the schema file in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2891
diff
changeset
|
120 # execute the schema file |
|
4588
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
121 self._execfile('schema.py', env) |
|
2891
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
122 # reload extensions and detectors |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
123 for extension in self.get_extensions('extensions'): |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
124 extension(self) |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
125 detectors = self.get_extensions('detectors') |
|
4588
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
126 db = env['db'] |
| 4781 | 127 db.tx_Source = None |
|
6658
408fd477761f
Add i18n object to roundupdb.Database
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6536
diff
changeset
|
128 # Useful for script when multiple open calls happen. Scripts have |
|
408fd477761f
Add i18n object to roundupdb.Database
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6536
diff
changeset
|
129 # to inject the i18n object, there is currently no support for this |
|
408fd477761f
Add i18n object to roundupdb.Database
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6536
diff
changeset
|
130 if hasattr(self, 'i18n'): |
|
408fd477761f
Add i18n object to roundupdb.Database
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6536
diff
changeset
|
131 db.i18n = self.i18n |
| 4781 | 132 |
|
2891
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
133 # apply the detectors |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
134 for detector in detectors: |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
135 detector(db) |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
136 # if we are running in debug mode |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
137 # or this is the first time the database is opened, |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
138 # do database upgrade checks |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
139 if not (self.optimize and self.db_open): |
|
4266
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
140 # As a consistency check, ensure that every link property is |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
141 # pointing at a defined class. Otherwise, the schema is |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
142 # internally inconsistent. This is an important safety |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
143 # measure as it protects against an accidental schema change |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
144 # dropping a table while there are still links to the table; |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
145 # once the table has been dropped, there is no way to get it |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
146 # back, so it is important to drop it only if we are as sure |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
147 # as possible that it is no longer needed. |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
148 classes = db.getclasses() |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
149 for classname in classes: |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
150 cl = db.getclass(classname) |
|
5395
23b8e6067f7c
Python 3 preparation: update calls to dict methods.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5383
diff
changeset
|
151 for propname, prop in cl.getprops().items(): |
|
4266
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
152 if not isinstance(prop, (hyperdb.Link, |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
153 hyperdb.Multilink)): |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
154 continue |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
155 linkto = prop.classname |
|
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
156 if linkto not in classes: |
|
6010
8ccb41b477d1
Flake8 cleanup. Formating only no code changes.
John Rouillard <rouilj@ieee.org>
parents:
5810
diff
changeset
|
157 raise ValueError("property %s.%s links to " |
|
8ccb41b477d1
Flake8 cleanup. Formating only no code changes.
John Rouillard <rouilj@ieee.org>
parents:
5810
diff
changeset
|
158 "non-existent class %s" |
|
8ccb41b477d1
Flake8 cleanup. Formating only no code changes.
John Rouillard <rouilj@ieee.org>
parents:
5810
diff
changeset
|
159 % (classname, propname, linkto)) |
|
4266
2b75274936bc
Add schema consistency checks.
Stefan Seefeld <stefan@seefeld.name>
parents:
4211
diff
changeset
|
160 |
|
2891
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
161 self.db_open = 1 |
|
6658
408fd477761f
Add i18n object to roundupdb.Database
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6536
diff
changeset
|
162 # *Must* call post_init! It is not an error if called multiple times. |
|
408fd477761f
Add i18n object to roundupdb.Database
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6536
diff
changeset
|
163 db.post_init() |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
164 return db |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
165 |
|
2697
d138df58b0c3
load user interfaces
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2688
diff
changeset
|
166 def load_interfaces(self): |
|
d138df58b0c3
load user interfaces
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2688
diff
changeset
|
167 """load interfaces.py (if any), initialize Client and MailGW attrs""" |
|
4588
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
168 env = {} |
|
2697
d138df58b0c3
load user interfaces
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2688
diff
changeset
|
169 if os.path.isfile(os.path.join(self.tracker_home, 'interfaces.py')): |
|
4588
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
170 self._execfile('interfaces.py', env) |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
171 self.Client = env.get('Client', client.Client) |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
172 self.MailGW = env.get('MailGW', mailgw.MailGW) |
|
6010
8ccb41b477d1
Flake8 cleanup. Formating only no code changes.
John Rouillard <rouilj@ieee.org>
parents:
5810
diff
changeset
|
173 self.TemplatingUtils = env.get('TemplatingUtils', |
|
8ccb41b477d1
Flake8 cleanup. Formating only no code changes.
John Rouillard <rouilj@ieee.org>
parents:
5810
diff
changeset
|
174 templating.TemplatingUtils) |
|
2697
d138df58b0c3
load user interfaces
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2688
diff
changeset
|
175 |
|
2891
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
176 def get_extensions(self, dirname): |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
177 """Load python extensions |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
178 |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
179 Parameters: |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
180 dirname: |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
181 extension directory name relative to tracker home |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
182 |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
183 Return value: |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
184 list of init() functions for each extension |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
185 |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
186 """ |
|
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
187 extensions = [] |
|
2688
eb14c12813a0
fix load_extensions():
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2677
diff
changeset
|
188 dirpath = os.path.join(self.tracker_home, dirname) |
|
eb14c12813a0
fix load_extensions():
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2677
diff
changeset
|
189 if os.path.isdir(dirpath): |
|
3771
bf660e65ba45
Directory structure changes.
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
2977
diff
changeset
|
190 sys.path.insert(1, dirpath) |
|
2688
eb14c12813a0
fix load_extensions():
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2677
diff
changeset
|
191 for name in os.listdir(dirpath): |
|
2677
1f0143b53bee
fix .load_extensions():
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2647
diff
changeset
|
192 if not name.endswith('.py'): |
|
1f0143b53bee
fix .load_extensions():
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2647
diff
changeset
|
193 continue |
|
4588
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
194 env = {} |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
195 self._execfile(os.path.join(dirname, name), env) |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
196 extensions.append(env['init']) |
|
3773
21ff756e4549
Fixes for directory handling.
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
3771
diff
changeset
|
197 sys.path.remove(dirpath) |
|
2891
bc72b1c7319b
if optimize is set, load all extension modules in __init__()...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2890
diff
changeset
|
198 return extensions |
|
2638
18e86941c950
Load up extensions in the tracker "extensions" directory.
Richard Jones <richard@users.sourceforge.net>
parents:
2633
diff
changeset
|
199 |
|
5216
6a4317738a90
make roundup-admin init function set the transaction source. Otherwise when initial_data.py is loaded as part of init, db.tx_Source is set to None and thus checks like db.tx_Source in [ 'cli' ] will fail.
John Rouillard <rouilj@ieee.org>
parents:
5067
diff
changeset
|
200 def init(self, adminpw, tx_Source=None): |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
201 db = self.open('admin') |
|
5216
6a4317738a90
make roundup-admin init function set the transaction source. Otherwise when initial_data.py is loaded as part of init, db.tx_Source is set to None and thus checks like db.tx_Source in [ 'cli' ] will fail.
John Rouillard <rouilj@ieee.org>
parents:
5067
diff
changeset
|
202 db.tx_Source = tx_Source |
|
6010
8ccb41b477d1
Flake8 cleanup. Formating only no code changes.
John Rouillard <rouilj@ieee.org>
parents:
5810
diff
changeset
|
203 self._execfile('initial_data.py', |
|
8ccb41b477d1
Flake8 cleanup. Formating only no code changes.
John Rouillard <rouilj@ieee.org>
parents:
5810
diff
changeset
|
204 {'db': db, 'adminpw': adminpw, |
|
8ccb41b477d1
Flake8 cleanup. Formating only no code changes.
John Rouillard <rouilj@ieee.org>
parents:
5810
diff
changeset
|
205 'admin_email': self.config['ADMIN_EMAIL']}) |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
206 db.commit() |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
207 db.close() |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
208 |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
209 def exists(self): |
|
2890
938915fbcb49
get_backend_name() is a lengthy thing (file I/O).
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2856
diff
changeset
|
210 return self.backend.db_exists(self.config) |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
211 |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
212 def nuke(self): |
|
2890
938915fbcb49
get_backend_name() is a lengthy thing (file I/O).
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2856
diff
changeset
|
213 self.backend.db_nuke(self.config) |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
214 |
|
4588
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
215 def _compile(self, fname): |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
216 fname = os.path.join(self.tracker_home, fname) |
|
6479
808f7a8ed2b6
Clean leaking file descriptors. Eliminates ResourceWarnings.
John Rouillard <rouilj@ieee.org>
parents:
6330
diff
changeset
|
217 with builtins.open(fname) as fnamed: |
|
808f7a8ed2b6
Clean leaking file descriptors. Eliminates ResourceWarnings.
John Rouillard <rouilj@ieee.org>
parents:
6330
diff
changeset
|
218 return compile(fnamed.read(), fname, 'exec') |
|
4588
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
219 |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
220 def _exec(self, obj, env): |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
221 if self.libdir: |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
222 sys.path.insert(1, self.libdir) |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
223 exec(obj, env) |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
224 if self.libdir: |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
225 sys.path.remove(self.libdir) |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
226 return env |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
227 |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
228 def _execfile(self, fname, env): |
|
7017c8dd704c
Small improvements on instance.py by Cheer Xiao.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4587
diff
changeset
|
229 self._exec(self._compile(fname), env) |
|
1780
d2801a2b0a77
Initial implementation (half-baked) at new Tracker instance.
Richard Jones <richard@users.sourceforge.net>
parents:
1174
diff
changeset
|
230 |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
231 def registerAction(self, name, action): |
| 4083 | 232 |
| 233 # The logic here is this: | |
| 234 # * if `action` derives from actions.Action, | |
| 235 # it is executable as a generic action. | |
| 236 # * if, moreover, it also derives from cgi.actions.Bridge, | |
| 237 # it may in addition be called via CGI | |
| 238 # * in all other cases we register it as a CGI action, without | |
| 239 # any check (for backward compatibility). | |
| 240 if issubclass(action, actions.Action): | |
| 241 self.actions[name] = action | |
| 242 if issubclass(action, cgi_actions.Bridge): | |
| 243 self.cgi_actions[name] = action | |
| 244 else: | |
| 245 self.cgi_actions[name] = action | |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
246 |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
247 def registerUtil(self, name, function): |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2621
diff
changeset
|
248 self.templating_utils[name] = function |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
249 |
|
6010
8ccb41b477d1
Flake8 cleanup. Formating only no code changes.
John Rouillard <rouilj@ieee.org>
parents:
5810
diff
changeset
|
250 |
|
6123
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6010
diff
changeset
|
251 class TrackerError(RoundupException): |
|
1158
30db4a11d700
sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents:
1090
diff
changeset
|
252 pass |
|
30db4a11d700
sanity check instance attributes on open
Richard Jones <richard@users.sourceforge.net>
parents:
1090
diff
changeset
|
253 |
|
1780
d2801a2b0a77
Initial implementation (half-baked) at new Tracker instance.
Richard Jones <richard@users.sourceforge.net>
parents:
1174
diff
changeset
|
254 |
|
2851
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
255 def open(tracker_home, optimize=0): |
|
1780
d2801a2b0a77
Initial implementation (half-baked) at new Tracker instance.
Richard Jones <richard@users.sourceforge.net>
parents:
1174
diff
changeset
|
256 if os.path.exists(os.path.join(tracker_home, 'dbinit.py')): |
|
d2801a2b0a77
Initial implementation (half-baked) at new Tracker instance.
Richard Jones <richard@users.sourceforge.net>
parents:
1174
diff
changeset
|
257 # user should upgrade... |
|
6300
778a9f455067
Remove old code import imp, old style trackers db/backend_name
John Rouillard <rouilj@ieee.org>
parents:
6123
diff
changeset
|
258 raise TrackerError("Old style trackers using dbinit.py " |
|
778a9f455067
Remove old code import imp, old style trackers db/backend_name
John Rouillard <rouilj@ieee.org>
parents:
6123
diff
changeset
|
259 "are not supported after release 2.0") |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
260 |
|
2851
96626831def1
trackers got a 'templates' attribute, containing html templates collection...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2836
diff
changeset
|
261 return Tracker(tracker_home, optimize=optimize) |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
262 |
|
2621
d344419d599d
use new style config;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2584
diff
changeset
|
263 # vim: set filetype=python sts=4 sw=4 et si : |
