Skip to content

Commit c0df48d

Browse files
author
Richard Jones
committed
changed all config accesses...
...so they access either the instance or the config attriubute on the db. This means that all config is obtained from instance_config instead of the mish-mash of classes. This will make switching to a ConfigParser setup easier too, I hope. At a minimum, this makes migration a _little_ easier (a lot easier in the 0.5.0 switch, I hope!)
1 parent 23d04d1 commit c0df48d

File tree

17 files changed

+261
-160
lines changed

17 files changed

+261
-160
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ Fixed:
1313
. #502342 ] pipe interface
1414
. #502437 ] rogue reactor and unittest
1515
. re-enabled dumbdbm when using python >2.1.1 (ie 2.1.2, 2.2)
16+
. changed all config accesses so they access either the instance or the
17+
config attriubute on the db. This means that all config is obtained from
18+
instance_config instead of the mish-mash of classes. This will make
19+
switching to a ConfigParser setup easier too, I hope.
20+
1621

1722
2002-01-08 - 0.4.0b1
1823
Feature:

MIGRATION.txt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ If you used the extended schema, the file is in:
2727

2828
<roundup source>/roundup/templates/extended/dbinit.py
2929

30-
If you have modified your dbinit.py file, you may use encoded passwords:
31-
32-
1. Edit the dbinit.py file in your instance home directory. Find the lines
33-
which define the msg class:
30+
If you have modified your dbinit.py file, you need to edit the dbinit.py
31+
file in your instance home directory. Find the lines which define the msg
32+
class:
3433

3534
msg = FileClass(db, "msg",
3635
author=Link("user"), recipients=Multilink("user"),
@@ -45,18 +44,24 @@ If you have modified your dbinit.py file, you may use encoded passwords:
4544
files=Multilink("file"),
4645
messageid=String(), inreplyto=String())
4746

47+
Also, configuration is being cleaned up. This means that your dbinit.py will
48+
also need to be changed in the open function. If you haven't changed your
49+
dbinit.py, the above copy will be enough. If you have, you'll need to change
50+
the line (round line 50):
51+
52+
db = Database(instance_config.DATABASE, name)
53+
54+
to:
55+
56+
db = Database(instance_config, name)
57+
58+
4859
Configuration
4960
-------------
5061
INSTANCE_NAME and EMAIL_SIGNATURE_POSITION have been added to the
5162
instance_config.py. Simplest solution is to copy the default values from
5263
template in the core source.
5364

54-
INSTANCE_NAME needs to be added to the Client class in your interfaces.py
55-
file. INSTANCE_NAME and ANONYMOUS_REGISTER need to be added to the MailGW
56-
class in your interfaces.py file. In both cases if might be easier to just
57-
copy the file from the core source (roundup/templates/[schema]/interfaces.py)
58-
where schema is "classic" or "extended".
59-
6065

6166
CGI script roundup.cgi
6267
----------------------

roundup/backends/back_anydbm.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.21 2002-01-02 02:31:38 richard Exp $
18+
#$Id: back_anydbm.py,v 1.22 2002-01-14 02:20:15 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in a database
2121
chosen by anydbm. It is guaranteed to always be available in python
@@ -40,9 +40,10 @@ class Database(hyperdb.Database):
4040
. perhaps detect write collisions (related to above)?
4141
4242
"""
43-
def __init__(self, storagelocator, journaltag=None):
43+
def __init__(self, config, journaltag=None):
4444
"""Open a hyperdatabase given a specifier to some storage.
4545
46+
The 'storagelocator' is obtained from config.DATABASE.
4647
The meaning of 'storagelocator' depends on the particular
4748
implementation of the hyperdatabase. It could be a file name,
4849
a directory path, a socket descriptor for a connection to a
@@ -53,7 +54,8 @@ def __init__(self, storagelocator, journaltag=None):
5354
None, the database is opened in read-only mode: the Class.create(),
5455
Class.set(), and Class.retire() methods are disabled.
5556
"""
56-
self.dir, self.journaltag = storagelocator, journaltag
57+
self.config, self.journaltag = config, journaltag
58+
self.dir = config.DATABASE
5759
self.classes = {}
5860
self.cache = {} # cache of nodes loaded or created
5961
self.dirtynodes = {} # keep track of the dirty nodes by class
@@ -404,6 +406,21 @@ def rollback(self):
404406

405407
#
406408
#$Log: not supported by cvs2svn $
409+
#Revision 1.21 2002/01/02 02:31:38 richard
410+
#Sorry for the huge checkin message - I was only intending to implement #496356
411+
#but I found a number of places where things had been broken by transactions:
412+
# . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename
413+
# for _all_ roundup-generated smtp messages to be sent to.
414+
# . the transaction cache had broken the roundupdb.Class set() reactors
415+
# . newly-created author users in the mailgw weren't being committed to the db
416+
#
417+
#Stuff that made it into CHANGES.txt (ie. the stuff I was actually working
418+
#on when I found that stuff :):
419+
# . #496356 ] Use threading in messages
420+
# . detectors were being registered multiple times
421+
# . added tests for mailgw
422+
# . much better attaching of erroneous messages in the mail gateway
423+
#
407424
#Revision 1.20 2001/12/18 15:30:34 rochecompaan
408425
#Fixed bugs:
409426
# . Fixed file creation and retrieval in same transaction in anydbm

roundup/backends/back_bsddb3.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_bsddb3.py,v 1.10 2001-11-21 02:34:18 richard Exp $
18+
#$Id: back_bsddb3.py,v 1.11 2002-01-14 02:20:15 richard Exp $
1919

2020
import bsddb3, os, marshal
2121
from roundup import hyperdb, date, password
@@ -26,9 +26,10 @@
2626
class Database(hyperdb.Database):
2727
"""A database for storing records containing flexible data types."""
2828

29-
def __init__(self, storagelocator, journaltag=None):
29+
def __init__(self, config, journaltag=None):
3030
"""Open a hyperdatabase given a specifier to some storage.
3131
32+
The 'storagelocator' is obtained from config.DATABASE.
3233
The meaning of 'storagelocator' depends on the particular
3334
implementation of the hyperdatabase. It could be a file name,
3435
a directory path, a socket descriptor for a connection to a
@@ -39,7 +40,8 @@ def __init__(self, storagelocator, journaltag=None):
3940
None, the database is opened in read-only mode: the Class.create(),
4041
Class.set(), and Class.retire() methods are disabled.
4142
"""
42-
self.dir, self.journaltag = storagelocator, journaltag
43+
self.config, self.journaltag = config, journaltag
44+
self.dir = config.DATABASE
4345
self.classes = {}
4446

4547
#
@@ -201,6 +203,9 @@ def rollback(self):
201203

202204
#
203205
#$Log: not supported by cvs2svn $
206+
#Revision 1.10 2001/11/21 02:34:18 richard
207+
#Added a target version field to the extended issue schema
208+
#
204209
#Revision 1.9 2001/10/09 23:58:10 richard
205210
#Moved the data stringification up into the hyperdb.Class class' get, set
206211
#and create methods. This means that the data is also stringified for the

roundup/cgi_client.py

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: cgi_client.py,v 1.97 2002-01-11 23:22:29 richard Exp $
18+
# $Id: cgi_client.py,v 1.98 2002-01-14 02:20:14 richard Exp $
1919

2020
__doc__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -44,21 +44,7 @@ class Client:
4444
'anonymous' user exists, the user is logged in using that user (though
4545
there is no cookie). This allows them to modify the database, and all
4646
modifications are attributed to the 'anonymous' user.
47-
48-
49-
Customisation
50-
-------------
51-
FILTER_POSITION - one of 'top', 'bottom', 'top and bottom'
52-
ANONYMOUS_ACCESS - one of 'deny', 'allow'
53-
ANONYMOUS_REGISTER - one of 'deny', 'allow'
54-
55-
from the roundup class:
56-
INSTANCE_NAME - defaults to 'Roundup issue tracker'
57-
5847
'''
59-
FILTER_POSITION = 'bottom' # one of 'top', 'bottom', 'top and bottom'
60-
ANONYMOUS_ACCESS = 'deny' # one of 'deny', 'allow'
61-
ANONYMOUS_REGISTER = 'deny' # one of 'deny', 'allow'
6248

6349
def __init__(self, instance, request, env, form=None):
6450
self.instance = instance
@@ -104,7 +90,7 @@ def pagehead(self, title, message=None):
10490
message = _('<div class="system-msg">%(message)s</div>')%locals()
10591
else:
10692
message = ''
107-
style = open(os.path.join(self.TEMPLATES, 'style.css')).read()
93+
style = open(os.path.join(self.instance.TEMPLATES, 'style.css')).read()
10894
user_name = self.user or ''
10995
if self.user == 'admin':
11096
admin_links = _(' | <a href="list_classes">Class List</a>' \
@@ -286,7 +272,7 @@ def list(self, sort=None, group=None, filter=None, columns=None,
286272
cn = self.classname
287273
cl = self.db.classes[cn]
288274
self.pagehead(_('%(instancename)s: Index of %(classname)s')%{
289-
'classname': cn, 'instancename': self.INSTANCE_NAME})
275+
'classname': cn, 'instancename': self.instance.INSTANCE_NAME})
290276
if sort is None: sort = self.index_arg(':sort')
291277
if group is None: group = self.index_arg(':group')
292278
if filter is None: filter = self.index_arg(':filter')
@@ -295,7 +281,7 @@ def list(self, sort=None, group=None, filter=None, columns=None,
295281
if show_customization is None:
296282
show_customization = self.customization_widget()
297283

298-
index = htmltemplate.IndexTemplate(self, self.TEMPLATES, cn)
284+
index = htmltemplate.IndexTemplate(self, self.instance.TEMPLATES, cn)
299285
index.render(filterspec, filter, columns, sort, group,
300286
show_customization=show_customization)
301287
self.pagefoot()
@@ -342,7 +328,8 @@ def shownode(self, message=None):
342328
nodeid = self.nodeid
343329

344330
# use the template to display the item
345-
item = htmltemplate.ItemTemplate(self, self.TEMPLATES, self.classname)
331+
item = htmltemplate.ItemTemplate(self, self.instance.TEMPLATES,
332+
self.classname)
346333
item.render(nodeid)
347334

348335
self.pagefoot()
@@ -561,7 +548,7 @@ def newnode(self, message=None):
561548
self.nodeid = nid
562549
self.pagehead('%s: %s'%(self.classname.capitalize(), nid),
563550
message)
564-
item = htmltemplate.ItemTemplate(self, self.TEMPLATES,
551+
item = htmltemplate.ItemTemplate(self, self.instance.TEMPLATES,
565552
self.classname)
566553
item.render(nid)
567554
self.pagefoot()
@@ -575,7 +562,7 @@ def newnode(self, message=None):
575562
self.classname.capitalize()}, message)
576563

577564
# call the template
578-
newitem = htmltemplate.NewItemTemplate(self, self.TEMPLATES,
565+
newitem = htmltemplate.NewItemTemplate(self, self.instance.TEMPLATES,
579566
self.classname)
580567
newitem.render(self.form)
581568

@@ -609,7 +596,7 @@ def newuser(self, message=None):
609596
self.classname.capitalize()}, message)
610597

611598
# call the template
612-
newitem = htmltemplate.NewItemTemplate(self, self.TEMPLATES,
599+
newitem = htmltemplate.NewItemTemplate(self, self.instance.TEMPLATES,
613600
self.classname)
614601
newitem.render(self.form)
615602

@@ -647,7 +634,7 @@ def newfile(self, message=None):
647634

648635
self.pagehead(_('New %(classname)s')%{'classname':
649636
self.classname.capitalize()}, message)
650-
newitem = htmltemplate.NewItemTemplate(self, self.TEMPLATES,
637+
newitem = htmltemplate.NewItemTemplate(self, self.instance.TEMPLATES,
651638
self.classname)
652639
newitem.render(self.form)
653640
self.pagefoot()
@@ -707,7 +694,7 @@ def showuser(self, message=None):
707694
self.pagehead(_('User: %(user)s')%{'user': node_user}, message)
708695

709696
# use the template to display the item
710-
item = htmltemplate.ItemTemplate(self, self.TEMPLATES, 'user')
697+
item = htmltemplate.ItemTemplate(self, self.instance.TEMPLATES, 'user')
711698
item.render(self.nodeid)
712699
self.pagefoot()
713700

@@ -760,7 +747,7 @@ def login(self, message=None, newuser_form=None, action='index'):
760747
<td><input type="submit" value="Log In"></td></tr>
761748
</form>
762749
''')%locals())
763-
if self.user is None and self.ANONYMOUS_REGISTER == 'deny':
750+
if self.user is None and self.instance.ANONYMOUS_REGISTER == 'deny':
764751
self.write('</table>')
765752
self.pagefoot()
766753
return
@@ -953,7 +940,7 @@ def main(self):
953940
if action == 'newuser_action':
954941
# if we don't have a login and anonymous people aren't allowed to
955942
# register, then spit up the login form
956-
if self.ANONYMOUS_REGISTER == 'deny' and self.user is None:
943+
if self.instance.ANONYMOUS_REGISTER == 'deny' and self.user is None:
957944
if action == 'login':
958945
self.login() # go to the index after login
959946
else:
@@ -968,7 +955,7 @@ def main(self):
968955
action = 'index'
969956

970957
# no login or registration, make sure totally anonymous access is OK
971-
elif self.ANONYMOUS_ACCESS == 'deny' and self.user is None:
958+
elif self.instance.ANONYMOUS_ACCESS == 'deny' and self.user is None:
972959
if action == 'login':
973960
self.login() # go to the index after login
974961
else:
@@ -1058,7 +1045,7 @@ def pagehead(self, title, message=None):
10581045
message = _('<div class="system-msg">%(message)s</div>')%locals()
10591046
else:
10601047
message = ''
1061-
style = open(os.path.join(self.TEMPLATES, 'style.css')).read()
1048+
style = open(os.path.join(self.instance.TEMPLATES, 'style.css')).read()
10621049
user_name = self.user or ''
10631050
if self.user == 'admin':
10641051
admin_links = _(' | <a href="list_classes">Class List</a>' \
@@ -1178,6 +1165,14 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
11781165

11791166
#
11801167
# $Log: not supported by cvs2svn $
1168+
# Revision 1.97 2002/01/11 23:22:29 richard
1169+
# . #502437 ] rogue reactor and unittest
1170+
# in short, the nosy reactor was modifying the nosy list. That code had
1171+
# been there for a long time, and I suspsect it was there because we
1172+
# weren't generating the nosy list correctly in other places of the code.
1173+
# We're now doing that, so the nosy-modifying code can go away from the
1174+
# nosy reactor.
1175+
#
11811176
# Revision 1.96 2002/01/10 05:26:10 richard
11821177
# missed a parsePropsFromForm in last update
11831178
#

roundup/htmltemplate.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: htmltemplate.py,v 1.51 2002-01-10 10:02:15 grubert Exp $
18+
# $Id: htmltemplate.py,v 1.52 2002-01-14 02:20:14 richard Exp $
1919

2020
__doc__ = """
2121
Template engine.
@@ -506,6 +506,7 @@ def __call__(self, m, filter=None, columns=None, sort=None, group=None):
506506
class IndexTemplate(TemplateFunctions):
507507
def __init__(self, client, templates, classname):
508508
self.client = client
509+
self.instance = client.instance
509510
self.templates = templates
510511
self.classname = classname
511512

@@ -551,8 +552,8 @@ def render(self, filterspec={}, filter=[], columns=[], sort=[], group=[],
551552
columns = l
552553

553554
# display the filter section
554-
if (show_display_form and hasattr(self.client, 'FILTER_POSITION') and
555-
self.client.FILTER_POSITION in ('top and bottom', 'top')):
555+
if (show_display_form and
556+
self.instance.FILTER_POSITION in ('top and bottom', 'top')):
556557
w('<form action="index">\n')
557558
self.filter_section(filter_template, filter, columns, group,
558559
all_filters, all_columns, show_customization)
@@ -633,8 +634,8 @@ def render(self, filterspec={}, filter=[], columns=[], sort=[], group=[],
633634
w('</table>')
634635

635636
# display the filter section
636-
if (show_display_form and hasattr(self.client, 'FILTER_POSITION') and
637-
self.client.FILTER_POSITION in ('top and bottom', 'bottom')):
637+
if (show_display_form and hasattr(self.instance, 'FILTER_POSITION') and
638+
self.instance.FILTER_POSITION in ('top and bottom', 'bottom')):
638639
w('<form action="index">\n')
639640
self.filter_section(filter_template, filter, columns, group,
640641
all_filters, all_columns, show_customization)
@@ -823,6 +824,7 @@ def __call__(self, m, filter=None, columns=None, sort=None, group=None):
823824
class ItemTemplate(TemplateFunctions):
824825
def __init__(self, client, templates, classname):
825826
self.client = client
827+
self.instance = client.instance
826828
self.templates = templates
827829
self.classname = classname
828830

@@ -855,6 +857,7 @@ def render(self, nodeid):
855857
class NewItemTemplate(TemplateFunctions):
856858
def __init__(self, client, templates, classname):
857859
self.client = client
860+
self.instance = client.instance
858861
self.templates = templates
859862
self.classname = classname
860863

@@ -886,6 +889,10 @@ def render(self, form):
886889

887890
#
888891
# $Log: not supported by cvs2svn $
892+
# Revision 1.51 2002/01/10 10:02:15 grubert
893+
# In do_history: replace "." in date by " " so html wraps more sensible.
894+
# Should this be done in date's string converter ?
895+
#
889896
# Revision 1.50 2002/01/05 02:35:10 richard
890897
# I18N'ification
891898
#

0 commit comments

Comments
 (0)