Beispiel #1
0
    def __init__(self, INSTANCE_HOME=None, *args, **kw):

        # Cmd-specific attributes
        self.intro = 'zosh version 0.1'
        self.prompt = 'zosh: '

        # let our superclass have its way too
        cmd.Cmd.__init__(self, *args, **kw)

        # get SOFTWARE_HOME from the environment

        SOFTWARE_HOME = os.environ.get('SOFTWARE_HOME')
        if SOFTWARE_HOME is None:
            print "Please set SOFTWARE_HOME to your Zope's lib/python."
            sys.exit(2)
        sys.path.append(SOFTWARE_HOME)

        # If we are given an INSTANCE_HOME, use the ZODB there. Otherwise
        # assume we are being tested either interactively or from a test
        # runner and use a stub ZODB.

        if INSTANCE_HOME is not None:
            import Zope
            INSTANCE_HOME = os.path.realpath(INSTANCE_HOME)
            Zope.configure('%s/etc/zope.conf' % INSTANCE_HOME)
        else:
            print >> self.stdout, "no INSTANCE_HOME given, using a test ZODB"
            sys.stderr = file('/dev/null', 'r+')
            from Testing.ZopeTestCase import base as Zope
            sys.stderr = sys.__stderr__

        self.context = Zope.app()
Beispiel #2
0
 def connect_to_zodb(self):
     #connect to ZODB
     try:
         print '\tConnect to ZODB...\n'
         Zope.configure(os.environ['CONFIG_FILE'])
         self.root = Zope.app()
         self.root = self.makerequest()
         self.login_to_zodb()
     except Exception, error:
         #failed to connect to ZODB
         self.exit_script('\tFailed to connect to ZODB: %s.\n' % str(error))