Mercurial > p > roundup > code
annotate roundup/instance.py @ 778:fb2ce2b8b2ef
Moved the file storage commit into blobfiles where it belongs.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 19 Jun 2002 03:07:19 +0000 |
| parents | bdc2ea127ae9 |
| children | 13719594278b 9b910e8d987d |
| 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. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
17 # |
|
406
bdc2ea127ae9
Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents:
380
diff
changeset
|
18 # $Id: instance.py,v 1.5 2001-11-22 15:46:42 jhermann Exp $ |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 |
|
406
bdc2ea127ae9
Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents:
380
diff
changeset
|
20 __doc__ = ''' |
|
bdc2ea127ae9
Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents:
380
diff
changeset
|
21 Instance handling (open instance). |
|
bdc2ea127ae9
Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents:
380
diff
changeset
|
22 |
|
bdc2ea127ae9
Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents:
380
diff
changeset
|
23 Currently this module provides one function: open. This function opens |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 an instance. |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 ''' |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 |
|
380
a1331423eb93
Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
27 import imp, os |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 class Opener: |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 def __init__(self): |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
31 self.number = 0 |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
32 self.instances = {} |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 def open(self, instance_home): |
|
380
a1331423eb93
Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
35 '''Open the instance. |
|
a1331423eb93
Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
36 |
|
a1331423eb93
Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
37 Raise ValueError if the instance home doesn't exist. |
|
a1331423eb93
Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
38 ''' |
|
a1331423eb93
Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
39 if not os.path.exists(instance_home): |
|
a1331423eb93
Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
40 raise ValueError, 'no such directory: "%s"'%instance_home |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
41 if self.instances.has_key(instance_home): |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 return imp.load_package(self.instances[instance_home], |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 instance_home) |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 self.number = self.number + 1 |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
45 modname = '_roundup_instance_%s'%self.number |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
46 self.instances[instance_home] = modname |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 return imp.load_package(modname, instance_home) |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
49 opener = Opener() |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
50 open = opener.open |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
51 |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
52 del Opener |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
53 del opener |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
54 |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
55 |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
56 # |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
57 # $Log: not supported by cvs2svn $ |
|
406
bdc2ea127ae9
Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents:
380
diff
changeset
|
58 # Revision 1.4 2001/11/12 22:01:06 richard |
|
bdc2ea127ae9
Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents:
380
diff
changeset
|
59 # Fixed issues with nosy reaction and author copies. |
|
bdc2ea127ae9
Added module docstrings to all modules.
Jürgen Hermann <jhermann@users.sourceforge.net>
parents:
380
diff
changeset
|
60 # |
|
380
a1331423eb93
Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
61 # Revision 1.3 2001/08/07 00:24:42 richard |
|
a1331423eb93
Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
62 # stupid typo |
|
a1331423eb93
Fixed issues with nosy reaction and author copies.
Richard Jones <richard@users.sourceforge.net>
parents:
214
diff
changeset
|
63 # |
| 214 | 64 # Revision 1.2 2001/08/07 00:15:51 richard |
| 65 # Added the copyright/license notice to (nearly) all files at request of | |
| 66 # Bizar Software. | |
| 67 # | |
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
68 # Revision 1.1 2001/08/05 07:43:52 richard |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
69 # Instances are now opened by a special function that generates a unique |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
70 # module name for the instances on import time. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
204
diff
changeset
|
71 # |
|
204
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
72 # |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
73 # |
|
c1461733cbf9
Instances are now opened by a special function...
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
74 # vim: set filetype=python ts=4 sw=4 et si |
