[Zope-dev] app = Zope.app() backwards incompatibility notice / discussion

Erik A.Dahl edahl at zentinel.com
Mon Feb 16 14:29:28 EST 2004


Whatever happened to the ZOPE_CONFIG env idea?  What I have found is 
that I started putting

Zope.config(os.getenv("ZOPE_CONFIG"))

in all my scripts.  Why can't his happen within Zope.app()?  Something 
like this.

*** lib/python/Zope/__init__.py.orig  2003-12-21 19:24:25.000000000 
-0500
--- lib/python/Zope/__init__.py 2004-02-16 14:15:48.000000000 -0500
***************
*** 45,52 ****
--- 45,59 ----
       from Zope.App.startup import startup as _startup
       _startup()

+ from Zope.Startup.run import configure
+ class ZopeConfig(Exception):pass
+
   def app(*args, **kw):
       """Utility for scripts to open a connection to the database"""
+     configfile = os.getenv("ZOPE_CONFIG")
+     if not configfile:
+         raise ZopeConfig, "ERROR: ZOPE_CONFIG environment variable 
not found"
+     configure(configfile)
       startup()
       return bobo_application(*args, **kw)

***************
*** 56,62 ****
       import ZPublisher
       return ZPublisher.test('Zope', *args, **kw)

- from Zope.Startup.run import configure

   # Zope.App.startup.startup() sets the following variables in this 
module.
   DB = None
--- 63,68 ----

-EAD


On Dec 22, 2003, at 1:37 PM, Dieter Maurer wrote:

> Chris McDonough wrote at 2003-12-21 18:16 -0500:
>> ...
>> Will need to do this under 2.7b4+:
>>
>> import Zope
>> Zope.configure('/path/to/configfile')
>> app = Zope.app()
>> ...
>> Jim Roepke suggested that if an "ZOPE_CONFIG" envvar was set with the
>> config file path, that "import Zope; Zope.app()" could be made to 
>> "just
>> work",
>
> A very good suggestion!
>
>> but I'm not sure this is any better than requiring that
>> developers change their scripts.
>
> For developpers, it is much better:
>
>   Add an environment variable at one (or a few) central
>   place versus change lots of scripts.
>
>> Guessing at the config file location
>> is also fraught with problems, and I'd be hesitant to do it.
>
> The suggestion was to use the value of "ZOPE_CONFIG" as
> config file path. Thus, you do not need to guess...
>
> -- 
> Dieter
>
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev at zope.org
> http://mail.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope )




More information about the Zope-Dev mailing list