Re: [Zope-dev] Zope 2.12 and Globals.DevelopmentMode

2010-02-10 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Sylvain Viollon wrote:
> On Sat, 06 Feb 2010 02:14:07 -0500
> Tres Seaver  wrote:
> 
>Hello,
> 
>> There was never any guarantee that Globals would be fully popluated
>> before the start of product initialization:  third-party code needs to
>> defer checking that flag at "import" time (which is the point of the
>> pattern Hanno outlines).
>>
>> An even better pattern would probably be to avoid the Globals "dumping
>> ground" altogether and use the configuration object directly:
>>
>>   from App.config import getConfiguration
>>   config = getConfiguration()
>>   if config.debug_mode:
>>  
>>
> 
>As matter of fact I tried that. And it always returned False
>(that's why I posted that mail at first). I have to review my setup,
>to see if there is something wrong, before I can continue to argue.
> 
>I am using buildout and plone.recipe.zope2instance.

That sounds as though you grabbed the configuration "early" (before
startup has loaded it from the config file / command line options).  You
*can't* to this at module scope, because your module may be imported
before the initialization has been done.


Tres.
- --
===
Tres Seaver  +1 540-429-0999  tsea...@palladion.com
Palladion Software   "Excellence by Design"http://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkty4icACgkQ+gerLs4ltQ4a/QCeIXRVUIg4ib7m0yOj2lWP21XI
pMYAn0V7pQ7x0hVGn1eRXLAd1NfHuoh7
=EUxK
-END PGP SIGNATURE-

___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Zope 2.12 and Globals.DevelopmentMode

2010-02-10 Thread Sylvain Viollon
On Sat, 06 Feb 2010 02:14:07 -0500
Tres Seaver  wrote:

   Hello,

> 
> There was never any guarantee that Globals would be fully popluated
> before the start of product initialization:  third-party code needs to
> defer checking that flag at "import" time (which is the point of the
> pattern Hanno outlines).
> 
> An even better pattern would probably be to avoid the Globals "dumping
> ground" altogether and use the configuration object directly:
> 
>   from App.config import getConfiguration
>   config = getConfiguration()
>   if config.debug_mode:
>  
> 

   As matter of fact I tried that. And it always returned False
   (that's why I posted that mail at first). I have to review my setup,
   to see if there is something wrong, before I can continue to argue.

   I am using buildout and plone.recipe.zope2instance.

   Regards,

   Sylvain,


-- 
Sylvain Viollon -- Infrae
t +31 10 243 7051 -- http://infrae.com
Hoevestraat 10 3033GC Rotterdam -- The Netherlands
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Zope 2.12 and Globals.DevelopmentMode

2010-02-05 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hanno Schlichting wrote:
> On Fri, Feb 5, 2010 at 2:35 PM, Sylvain Viollon  wrote:
>>   Maybe I missed something, but it seems to me that
>>   Globals.DevelopmentMode in Zope 2.12 is always False, even if you
>>   start Zope in fg, or set debug-mode to on in the configuration file.
> 
> This works for me and DevelopmentMode is set correctly.
> 
> Make sure you don't try to get the value too early (like at module
> scope import time) but after the server has actually started up. So
> don't do: "from Globals import DevelopmentMode" but "import Globals;
> Globals.DevelopmentMode". I think the exact timing of the startup
> process is somewhat different compared to prior versions.

There was never any guarantee that Globals would be fully popluated
before the start of product initialization:  third-party code needs to
defer checking that flag at "import" time (which is the point of the
pattern Hanno outlines).

An even better pattern would probably be to avoid the Globals "dumping
ground" altogether and use the configuration object directly:

  from App.config import getConfiguration
  config = getConfiguration()
  if config.debug_mode:
 


Tres.
- --
===
Tres Seaver  +1 540-429-0999  tsea...@palladion.com
Palladion Software   "Excellence by Design"http://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkttFr8ACgkQ+gerLs4ltQ5gqQCeN168JLfr328HmkcBxaI8pHlj
qs4AoIZO+ojZJ5MSXjZuxV7ipyjtdZAD
=qr6k
-END PGP SIGNATURE-

___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Zope 2.12 and Globals.DevelopmentMode

2010-02-05 Thread Hanno Schlichting
On Fri, Feb 5, 2010 at 2:35 PM, Sylvain Viollon  wrote:
>   Maybe I missed something, but it seems to me that
>   Globals.DevelopmentMode in Zope 2.12 is always False, even if you
>   start Zope in fg, or set debug-mode to on in the configuration file.

This works for me and DevelopmentMode is set correctly.

Make sure you don't try to get the value too early (like at module
scope import time) but after the server has actually started up. So
don't do: "from Globals import DevelopmentMode" but "import Globals;
Globals.DevelopmentMode". I think the exact timing of the startup
process is somewhat different compared to prior versions.

Hanno
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Zope 2.12 and Globals.DevelopmentMode

2010-02-05 Thread Sylvain Viollon
Hello,

   Maybe I missed something, but it seems to me that
   Globals.DevelopmentMode in Zope 2.12 is always False, even if you
   start Zope in fg, or set debug-mode to on in the configuration file.

   And I tried App.config.getConfiguration().debug_mode, it's the same.

   Did I miss something ? There is a new (working) way to know if Zope
   is running in debug mode or not ?

   Best regards,

   Sylvain Viollon


-- 
Sylvain Viollon -- Infrae
t +31 10 243 7051 -- http://infrae.com
Hoevestraat 10 3033GC Rotterdam -- The Netherlands
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )