comparison roundup/templates/classic/dbinit.py @ 1085:04a6b3bfbf23

instance_config -> config, and other related cleanups
author Richard Jones <richard@users.sourceforge.net>
date Mon, 09 Sep 2002 23:55:29 +0000
parents fec6af48558b
children 62485452f514
comparison
equal deleted inserted replaced
1084:a625adcd6254 1085:04a6b3bfbf23
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: dbinit.py,v 1.25 2002-09-02 07:00:22 richard Exp $ 18 # $Id: dbinit.py,v 1.26 2002-09-09 23:55:19 richard Exp $
19 19
20 import os 20 import os
21 21
22 import instance_config 22 import config
23 from select_db import Database, Class, FileClass, IssueClass 23 from select_db import Database, Class, FileClass, IssueClass
24 24
25 def open(name=None): 25 def open(name=None):
26 ''' as from the roundupdb method openDB 26 ''' as from the roundupdb method openDB
27 ''' 27 '''
28 from roundup.hyperdb import String, Password, Date, Link, Multilink 28 from roundup.hyperdb import String, Password, Date, Link, Multilink
29 29
30 # open the database 30 # open the database
31 db = Database(instance_config, name) 31 db = Database(config, name)
32 32
33 # 33 #
34 # Now initialise the schema. Must do this each time the database is 34 # Now initialise the schema. Must do this each time the database is
35 # opened. 35 # opened.
36 # 36 #
64 alternate_addresses=String(), 64 alternate_addresses=String(),
65 queries=Multilink('query'), roles=String()) 65 queries=Multilink('query'), roles=String())
66 user.setkey("username") 66 user.setkey("username")
67 67
68 # FileClass automatically gets these properties: 68 # FileClass automatically gets these properties:
69 # content = String() [saved to disk in <instance home>/db/files/] 69 # content = String() [saved to disk in <tracker home>/db/files/]
70 # (it also gets the Class properties creation, activity and creator) 70 # (it also gets the Class properties creation, activity and creator)
71 msg = FileClass(db, "msg", 71 msg = FileClass(db, "msg",
72 author=Link("user", do_journal='no'), 72 author=Link("user", do_journal='no'),
73 recipients=Multilink("user", do_journal='no'), 73 recipients=Multilink("user", do_journal='no'),
74 date=Date(), summary=String(), 74 date=Date(), summary=String(),
152 152
153 Open the new database, and add new nodes - used for initialisation. You 153 Open the new database, and add new nodes - used for initialisation. You
154 can edit this before running the "roundup-admin initialise" command to 154 can edit this before running the "roundup-admin initialise" command to
155 change the initial database entries. 155 change the initial database entries.
156 ''' 156 '''
157 dbdir = os.path.join(instance_config.DATABASE, 'files') 157 dbdir = os.path.join(config.DATABASE, 'files')
158 if not os.path.isdir(dbdir): 158 if not os.path.isdir(dbdir):
159 os.makedirs(dbdir) 159 os.makedirs(dbdir)
160 160
161 db = open("admin") 161 db = open("admin")
162 db.clear() 162 db.clear()
182 stat.create(name="resolved", order="8") 182 stat.create(name="resolved", order="8")
183 183
184 # create the two default users 184 # create the two default users
185 user = db.getclass('user') 185 user = db.getclass('user')
186 user.create(username="admin", password=adminpw, 186 user.create(username="admin", password=adminpw,
187 address=instance_config.ADMIN_EMAIL, roles='Admin') 187 address=config.ADMIN_EMAIL, roles='Admin')
188 user.create(username="anonymous", roles='Anonymous') 188 user.create(username="anonymous", roles='Anonymous')
189 189
190 db.commit() 190 db.commit()
191 191
192 #
193 # $Log: not supported by cvs2svn $
194 # Revision 1.24 2002/09/01 04:32:30 richard
195 # . Lots of cleanup in the classic html (stylesheet, search page, index page, ...)
196 # . Reinstated searching, but not query saving yet
197 # . Filtering only allows sorting and grouping by one property - all backends
198 # now implement this behaviour.
199 # . Nosy list journalling turned off by default, everything else is on.
200 # . Added some convenience methods (reverse, propchanged, [item] accesses, ...)
201 # . Did I mention the stylesheet is much cleaner now? :)
202 #
203 # Revision 1.23 2002/08/30 08:30:45 richard
204 # allow perms on user class
205 #
206 # Revision 1.22 2002/08/01 00:56:22 richard
207 # Added the web access and email access permissions, so people can restrict
208 # access to users who register through the email interface (for example).
209 # Also added "security" command to the roundup-admin interface to display the
210 # Role/Permission config for an instance.
211 #
212 # Revision 1.21 2002/07/26 08:26:59 richard
213 # Very close now. The cgi and mailgw now use the new security API. The two
214 # templates have been migrated to that setup. Lots of unit tests. Still some
215 # issue in the web form for editing Roles assigned to users.
216 #
217 # Revision 1.20 2002/07/17 12:39:10 gmcm
218 # Saving, running & editing queries.
219 #
220 # Revision 1.19 2002/07/14 02:05:54 richard
221 # . all storage-specific code (ie. backend) is now implemented by the backends
222 #
223 # Revision 1.18 2002/07/09 03:02:53 richard
224 # More indexer work:
225 # - all String properties may now be indexed too. Currently there's a bit of
226 # "issue" specific code in the actual searching which needs to be
227 # addressed. In a nutshell:
228 # + pass 'indexme="yes"' as a String() property initialisation arg, eg:
229 # file = FileClass(db, "file", name=String(), type=String(),
230 # comment=String(indexme="yes"))
231 # + the comment will then be indexed and be searchable, with the results
232 # related back to the issue that the file is linked to
233 # - as a result of this work, the FileClass has a default MIME type that may
234 # be overridden in a subclass, or by the use of a "type" property as is
235 # done in the default templates.
236 # - the regeneration of the indexes (if necessary) is done once the schema is
237 # set up in the dbinit.
238 #
239 # Revision 1.17 2002/05/24 04:03:23 richard
240 # Added commentage to the dbinit files to help people with their
241 # customisation.
242 #
243 # Revision 1.16 2002/02/16 08:06:14 richard
244 # Removed the key property restriction on title of the classic issue class.
245 #
246 # Revision 1.15 2002/02/15 07:08:44 richard
247 # . Alternate email addresses are now available for users. See the MIGRATION
248 # file for info on how to activate the feature.
249 #
250 # Revision 1.14 2002/01/14 02:20:15 richard
251 # . changed all config accesses so they access either the instance or the
252 # config attriubute on the db. This means that all config is obtained from
253 # instance_config instead of the mish-mash of classes. This will make
254 # switching to a ConfigParser setup easier too, I hope.
255 #
256 # At a minimum, this makes migration a _little_ easier (a lot easier in the
257 # 0.5.0 switch, I hope!)
258 #
259 # Revision 1.13 2002/01/02 02:31:38 richard
260 # Sorry for the huge checkin message - I was only intending to implement #496356
261 # but I found a number of places where things had been broken by transactions:
262 # . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename
263 # for _all_ roundup-generated smtp messages to be sent to.
264 # . the transaction cache had broken the roundupdb.Class set() reactors
265 # . newly-created author users in the mailgw weren't being committed to the db
266 #
267 # Stuff that made it into CHANGES.txt (ie. the stuff I was actually working
268 # on when I found that stuff :):
269 # . #496356 ] Use threading in messages
270 # . detectors were being registered multiple times
271 # . added tests for mailgw
272 # . much better attaching of erroneous messages in the mail gateway
273 #
274 # Revision 1.12 2001/12/02 05:06:16 richard
275 # . We now use weakrefs in the Classes to keep the database reference, so
276 # the close() method on the database is no longer needed.
277 # I bumped the minimum python requirement up to 2.1 accordingly.
278 # . #487480 ] roundup-server
279 # . #487476 ] INSTALL.txt
280 #
281 # I also cleaned up the change message / post-edit stuff in the cgi client.
282 # There's now a clearly marked "TODO: append the change note" where I believe
283 # the change note should be added there. The "changes" list will obviously
284 # have to be modified to be a dict of the changes, or somesuch.
285 #
286 # More testing needed.
287 #
288 # Revision 1.11 2001/12/01 07:17:50 richard
289 # . We now have basic transaction support! Information is only written to
290 # the database when the commit() method is called. Only the anydbm
291 # backend is modified in this way - neither of the bsddb backends have been.
292 # The mail, admin and cgi interfaces all use commit (except the admin tool
293 # doesn't have a commit command, so interactive users can't commit...)
294 # . Fixed login/registration forwarding the user to the right page (or not,
295 # on a failure)
296 #
297 # Revision 1.10 2001/11/26 22:55:56 richard
298 # Feature:
299 # . Added INSTANCE_NAME to configuration - used in web and email to identify
300 # the instance.
301 # . Added EMAIL_SIGNATURE_POSITION to indicate where to place the roundup
302 # signature info in e-mails.
303 # . Some more flexibility in the mail gateway and more error handling.
304 # . Login now takes you to the page you back to the were denied access to.
305 #
306 # Fixed:
307 # . Lots of bugs, thanks Roché and others on the devel mailing list!
308 #
309 # Revision 1.9 2001/10/30 00:54:45 richard
310 # Features:
311 # . #467129 ] Lossage when username=e-mail-address
312 # . #473123 ] Change message generation for author
313 # . MailGW now moves 'resolved' to 'chatting' on receiving e-mail for an issue.
314 #
315 # Revision 1.8 2001/10/09 07:25:59 richard
316 # Added the Password property type. See "pydoc roundup.password" for
317 # implementation details. Have updated some of the documentation too.
318 #
319 # Revision 1.7 2001/08/07 00:24:43 richard
320 # stupid typo
321 #
322 # Revision 1.6 2001/08/07 00:15:51 richard
323 # Added the copyright/license notice to (nearly) all files at request of
324 # Bizar Software.
325 #
326 # Revision 1.5 2001/08/02 06:38:17 richard
327 # Roundupdb now appends "mailing list" information to its messages which
328 # include the e-mail address and web interface address. Templates may
329 # override this in their db classes to include specific information (support
330 # instructions, etc).
331 #
332 # Revision 1.4 2001/07/29 07:01:39 richard
333 # Added vim command to all source so that we don't get no steenkin' tabs :)
334 #
335 # Revision 1.3 2001/07/24 10:46:22 anthonybaxter
336 # Added templatebuilder module. two functions - one to pack up the html base,
337 # one to unpack it. Packed up the two standard templates into htmlbases.
338 # Modified __init__ to install them.
339 #
340 # __init__.py magic was needed for the rather high levels of wierd import magic.
341 # Reducing level of import magic == (good, future)
342 #
343 # Revision 1.2 2001/07/24 01:06:43 richard
344 # Oops - accidentally duped the keywords class
345 #
346 # Revision 1.1 2001/07/23 23:28:43 richard
347 # Adding the classic template
348 #
349 # Revision 1.4 2001/07/23 08:45:28 richard
350 # ok, so now "./roundup-admin init" will ask questions in an attempt to get a
351 # workable instance_home set up :)
352 # _and_ anydbm has had its first test :)
353 #
354 # Revision 1.3 2001/07/23 07:14:41 richard
355 # Moved the database backends off into backends.
356 #
357 # Revision 1.2 2001/07/23 06:25:50 richard
358 # relfected the move to roundup/backends
359 #
360 # Revision 1.1 2001/07/23 04:33:21 anthonybaxter
361 # split __init__.py into 2. dbinit and instance_config.
362 #
363 # Revision 1.1 2001/07/23 03:50:46 anthonybaxter
364 # moved templates to proper location
365 #
366 # Revision 1.2 2001/07/22 12:09:32 richard
367 # Final commit of Grande Splite
368 #
369 #
370 # vim: set filetype=python ts=4 sw=4 et si 192 # vim: set filetype=python ts=4 sw=4 et si
371 193

Roundup Issue Tracker: http://roundup-tracker.org/