Re: [Zope3-Users] Re: Using ZCML for defining global constants ?

2006-09-11 Thread Baiju M

On 9/11/06, Martin Aspeli [EMAIL PROTECTED] wrote:

Andrew Groom wrote:
 Hi there,

 I've got a few global constants that I'd like to be available to my
 application and a .zcml file seems to be a sensible place. I'm thinking
 of something like a .zcml file with, e.g.:

 applicationSettings
 setting name=name1 value=value1/
 setting name=name2 value=value2/
 ...
 /applicationSettings

 This would then be available in a component as a dictionary. Is anythign
 like this already available ?

You could just use utility, and thereby group your constants into
logical chunks.

interfaces.py:

class IDatabaseLoginOptions(Interface):
 username = Attribute()
 password = Attribute()

config.py:

class DatabaseLoginOptions(object):
 implements(IDatabaseLoginOptions)
 username = 'foo'
 password = 'bar'

configure.zcml:

utility factory=.config.DatabaseLoginOptions /

used:

opts = getUtility(IDatabaseLoginOptions)

Obviously, this is a bit more work than just declaring some constants in
ZCML, but global constants suffer the same problems whether they're
defined in Python or XML. Parts of your application are making
assumptions that they are there, with very specific names, which are not
type checked.


Just added this to FAQ: http://kpug.zwiki.org/Zope3Faq

Regards,
Baiju M
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Using ZCML for defining global constants ?

2006-09-11 Thread FB
Hi,

On Mon, Sep 11, 2006 at 01:19:31PM +0530, Baiju M wrote:
 Just added this to FAQ: http://kpug.zwiki.org/Zope3Faq

I did the same - in german:

http://zope3.mpg.de/cgi-bin/twiki/view/Zope/CookBook#Globale_Konfigurationsparameter

Regards,

Frank
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users