[Zope] probably a faq: access INSTANCE_HOME

Mark McEahern mark@mceahern.com
Fri, 8 Nov 2002 16:35:57 -0600


[Charlie Reiman [mailto:creiman@kefta.com]]
> It's just an enviornment variable, so I assume:
>
> import os
> os.getenv('INSTANCE_HOME')
>
> should work for an external method.

I'm using Zope 2.6.0b2 on Windows--running as a service.

Here's the external method contents (below).  When I test it, I get
HomeNotFoundError.  Which suggests that Zope does not set these environment
variables for me--I must set them myself.  Am I missing something?

Thanks,

// mark

# external method

import os

class UtilsException(Exception):pass
class HomeNotFoundError(UtilsException):pass

def import_file(self):

    location = os.getenv('INSTANCE_HOME')
    if not location:
        location = os.getenv('SOFTWARE_HOME')
    if not location:
        raise HomeNotFoundError
    imp_dir = os.path.join(location, 'import')
    return '\n'.join(os.listdir(imp_dir))

-