[TransWarp] peak.binding questions
Ulrich Eck
ueck at net-labs.de
Wed Jun 4 12:55:36 EDT 2003
Hi Phillip,
while i have done lots of coding with peak during the last weeks
the following problem occured regularly and i don't know
how to "peak"ish solve it:
- I have different Implementations of something (e.g.
platform-dependent) i specify them in my package-ini:
[some.property]
variantA = importString('some.path.to:A')
variantB = importString('some.path.to:B')
- then i have some Component where i want to use *one*
of those variants. i also specify the choice in some
user-conf(ini) file:
[main.config]
wichVariant = 'variantA'
the user-conf file should be as easy as possible e.g. no
cryptic config.getProperty(propertyMap ........)
initially i thought i could write something like this to create
an instance of some.path.to.A:
class MyImpl(binding.Component):
myVariantInstance = binding.New( \
PropertyName('some.property.' + \
config.getProperty('main.config.whichVariant')))
this obviously does not work as getProperty has ctx as first
parameter and is not known at that time. and New only accepts
strings or types/classes.
within the component i end up with once methods that do the
property lookups and create the instance by hand.
is there an easier way to do this?
same applies when i wanna configure some e.g. LDAPConnection:
i want to specify it in a config-file:
[main.config]
ldapurl = 'ldap://user:auth@server/base'
but i cannot say:
class MyDBComponent(binding.Base):
connection = \
binding.bindTo(config.getProperty('main.config.ldapurl'))
if these situations could be solved without writing once-methods
my could would look much better.
thanks for your comments
Ulrich
--
---------------------------------------
Ulrich Eck
net-labs Systemhaus GmbH
Ebersberger Str. 46
85570 Markt Schwaben - Germany
eMail: ueck <at> net-labs.de
phone: +49 8121 4747 10
fax: +49 8121 4747 77
More information about the PEAK
mailing list