[PEAK] Offering Named Services with configuration keys

Tiago Cogumbreiro cogumbreiro at gmail.com
Wed May 18 20:31:04 EDT 2005


Is it possible to offer a [Named Services] as something?

right now I am obligated to recriate all my components available in
the service area (created by [Component Factories]) because I can't
offer a database as a ISQLConnection.

Example follows:

--myapp.ini---

[Named Services]
myapp.db = naming.LinkRef('sqlite:myapp.db')

[Component Factories]
myapp.model.SomeDM = "myapp.storage.SomeDM"

--myapp-example.py--
# Problem:
# I need to offer to my DM's a ISQLConnection
# The PropertyName("myapp.db") should be offered as an storage.ISQLConnection
# Because I can't I have to recriate all the components and offer them again:
MyBaseComponet (binding.Component):
    # Override the DM so that further calls get this component instead
    SomeDM = binding.Make (myapp.model.SomeDM, offerAs=[myapp.model.SomeDM]
    # Override the DB property so that it offers a ISQLConnection:
    db = binding.Obtain (PropertyName("myapp.db"),
offerAs=[storage.ISQLConnection])


What am I doing wrong? Is it possible to workaround this problem? I
guess the main question is: is it possible to fiddle with the objects
in the service area, such as changing what they offer? And can this
all be made in the configuration level? I would really like my
component to be something like:

MyBaseComponet (binding.Component):
    # I'm just going to need my DM, he needs a ISQLConnection but 
    # my named service myapp.db is already offered as such.
    SomeDM = binding.Obtain (myapp.model.SomeDM)



More information about the PEAK mailing list