[PEAK] ZConfig and peak naming
Phillip J. Eby
pje at telecommunity.com
Thu Jul 29 17:22:44 EDT 2004
At 10:38 PM 7/29/04 +0200, Roché Compaan wrote:
>I need a key in ZConfig file that needs to set a file object as
>attribute on a subclass of binding.Component *and* values should be
>specifiable as peak urls.
>
> <process>
> file pkgfile:jack/somefile.txt
> ...
> </process>
>
>The above configuration, must set 'file' in:
>
> class Process(binding.Component):
> file = binding.Make(lambda:None)
>
>if 'file' is defined as key in my schema file:
>
> <sectiontype name="process" datatype=".Process.fromZConfig">
> <key name="file" datatype="some.peak.component.fromZConfig"
> attribute="file"/>
> ...
> </sectiontype>
>
>Is there a peak component that can do this for me, or do I have to write
>one.
Do something like this:
class Process(binding.Component):
fileURL = binding.Require("URL needed", adaptTo=naming.IStreamFactory)
file = binding.Obtain(naming.Indirect('fileURL'))
And make the 'attribute' for 'file' be 'fileURL' instead.
'naming.Indirect("some_name")' translates to, "use the object you find at
'some_name' as a name to look up".
More information about the PEAK
mailing list