Alexey Smishlayev
2015-04-15 12:49:51 UTC
Hello!
I am trying to refactor existing peak application. I need to be able to
load ZConfig file from data incoming by STDIN. Now, the loader included
in peak is using files, so I implemented a subclass which should
simulate a file resource (in file zconfig.py). I also searched peak.ini
for any lines regarding zconfig. I copied all settings and changed them
to point to my custom classes (in file custom.ini; "ank.BBS" is my
project package).
In the python script, ZConfigInperpreter was used to get the application
But the PEAK seem to not find settings which I've put in my .ini file
and I'm stuck.
I've narrowed it down - the
ZConfigInterpreter.lookupComponent('zconfig.schema:'+str(url)) returns
peak.config.load_zconfig.ConfigLoader, instead of my custom class
(STDINConfigLoader from my file). I tried to trace down the stack with
pdb, and it seems that some lookup for
"zconfig.schema:/path/to/schema/file.xml" returns
peak.config.load_zconfig.ZConfigSchemaContext.
I've subclassed that one too, but have no success.
Can anyone, please, help me, how to replace the standard ZConfig classes?
Best regards,
Alexey
I am trying to refactor existing peak application. I need to be able to
load ZConfig file from data incoming by STDIN. Now, the loader included
in peak is using files, so I implemented a subclass which should
simulate a file resource (in file zconfig.py). I also searched peak.ini
for any lines regarding zconfig. I copied all settings and changed them
to point to my custom classes (in file custom.ini; "ank.BBS" is my
project package).
In the python script, ZConfigInperpreter was used to get the application
_argv=["ZConfig", scheme, cfgName]
_argv.extend(sys.argv[1:])
return ZConfigInterpreter(
config.makeRoot(),
argv=_argv,
componentName="MYAPP"
)
Now I want to pass no cfgName and get interpreter to process the STDIN._argv.extend(sys.argv[1:])
return ZConfigInterpreter(
config.makeRoot(),
argv=_argv,
componentName="MYAPP"
)
But the PEAK seem to not find settings which I've put in my .ini file
and I'm stuck.
I've narrowed it down - the
ZConfigInterpreter.lookupComponent('zconfig.schema:'+str(url)) returns
peak.config.load_zconfig.ConfigLoader, instead of my custom class
(STDINConfigLoader from my file). I tried to trace down the stack with
pdb, and it seems that some lookup for
"zconfig.schema:/path/to/schema/file.xml" returns
peak.config.load_zconfig.ZConfigSchemaContext.
I've subclassed that one too, but have no success.
Can anyone, please, help me, how to replace the standard ZConfig classes?
Best regards,
Alexey