Code

432bab6b8d27859dd0aa6b1dc4b92743b92027f8
[roundup.git] / roundup / instance.py
1 #
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3 # This module is free software, and you may redistribute it and/or modify
4 # under the same terms as Python, so long as this copyright message and
5 # disclaimer are retained in their original form.
6 #
7 # IN NO EVENT SHALL THE BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10 # POSSIBILITY OF SUCH DAMAGE.
11 #
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
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"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17
18 # $Id: instance.py,v 1.2 2001-08-07 00:15:51 richard Exp $
20 ''' Currently this module provides one function: open. This function opens
21 an instance.
22 '''
24 import imp
26 class Opener:
27     def __init__(self):
28         self.number = 0
29         self.instances = {}
31     def open(self, instance_home):
32         if self.instances.has_key(instance_home):
33             return imp.load_package(self.instances[instance_home],
34                 instance_home)
35         self.number = self.number + 1
36         modname = '_roundup_instance_%s'%self.number
37         self.instances[instance_home] = modname
38         return imp.load_package(modname, instance_home)
40 opener = Opener()
41 open = opener.open
43 del Opener
44 del opener
47 #
48 # $Log: not supported by cvs2svn $
49 # Revision 1.1  2001/08/05 07:43:52  richard
50 # Instances are now opened by a special function that generates a unique
51 # module name for the instances on import time.
52 #
53 #
54 #
55 # vim: set filetype=python ts=4 sw=4 et si