Fixes and Enhancements since Version 0.5 alpha 3 |
Fixes and Enhancements since Version 0.5 alpha 3 |
|
|
|
- Added a 'data:' URL scheme, implementing RFC 2397 (although it's not as |
|
strict in its parsing of the content type and parameters as the RFC calls |
|
for). This is a semi-convenient way to provide configuration data in-line, |
|
since a 'data:' URL can be a 'config.IStreamSource'. |
|
|
|
- Added 'config.processXML()', a function that provides a high-level, |
|
configuration-driven interface to 'peak.util.SOX.NegotiatingParser'. This |
|
simple front-end lets you supply as little as a configuration context and |
|
a stream source, to do XML processing of arbitrary complexity, controlled by |
|
the configuration of the context. |
|
|
|
- Added 'config.XMLKey()', an 'IConfigKey' type that can be used to register |
|
configuration values for XML attribute and element names under specified |
|
XML namespace URI's. Also, there are now '[XML Attributes for nsuri]' and |
|
'[XML Elements for nsuri]' section types available for use in .ini files. |
|
(Replace 'nsuri' with the appropriate XML namespace URI, or use '*' for a |
|
wildcard.) |
|
|
|
- 'web.IResource' is gone, replaced by 'web.IPlace'. The notion of a place is |
|
broader than the notion of a resource, and we will soon need to have |
|
other "location" objects that implement 'IPlace'. |
|
|
|
- In order to support obtaining the line and column locations of problems in |
|
XML files, we are now using Python 2.4's version of the 'pyexpat' module, |
|
built as 'peak.util.pyexpat'. |
|
|
|
- There's a new class, 'config.IniLoader', that can be used to lazily load |
|
.ini files as configuration. 'IniLoader' instances have an 'iniFiles' |
|
attribute that lists the configuration sources (filenames/URLs/factories) |
|
to be used, and automatically load the .ini files as soon as you try to get |
|
any configuration data for them. Previously, similar functionality was only |
|
available via 'config.makeRoot()'. |
|
|
|
Also, there's now an 'ini' reference type that instantiates an 'IniLoader' |
|
for one or more addresses. You can use it like this:: |
|
|
|
[Named Services] |
|
|
|
some.example = naming.Reference('ini', |
|
['pkgfile:peak/peak.ini', '/etc/something.ini'] |
|
) |
|
|
|
another.example = naming.LinkRef( |
|
'ref:ini@pkgfile:peak/peak.ini||/etc/something.ini' |
|
) |
|
|
|
The two examples above will each load the same pair of specified .ini files. |
|
You can also directly instantiate an 'IniLoader', as in:: |
|
|
|
cfg = config.IniLoader(self, iniFiles=['pkgfile:peak/peak.ini']) |
|
|
|
Attempting to look up any configuration properties via the 'cfg' object |
|
will cause it to load the specified .ini file. |
|
|
|
- 'config.fileNearModule()' is DEPRECATED, in favor of 'config.packageFile()'. |
|
The latter returns a 'naming.IStreamFactory', which is more suitable for |
|
working with e.g. module data files compressed in a zipfile. Uses of |
|
'fileNearModule()' that were being passed to 'config.loadConfigFile()' can |
|
be safely changed to 'config.packageFile()' without needing any other code |
|
changes, but if you were directly using 'fileNearModule()' as a filename, |
|
you will need to rewrite appropriately. |
|
|
|
- 'config.loadConfigFile()' and 'config.loadConfigFiles()' now accept URLs, |
|
'naming.IStreamFactory' objects, and 'config.IStreamSource' objects as well |
|
as filenames. This was primarily added to support use of |
|
'config.packageFile()' or 'pkgfile:' URLs, in place of using |
|
'config.fileNearModule()'. |
|
|
|
- There is a new 'config.IStreamSource' protocol, to make it easy to accept |
|
URLs, filenames, or 'naming.IStreamFactory' objects as the source of a |
|
"file". |
|
|
|
Its typical usage is just:: |
|
|
|
factory = config.IStreamSource(data).getFactory(self) |
|
stream = factory.open('t') # open for reading in text mode |
|
|
|
where 'data' is a string or a 'naming.IStreamFactory', and 'self' is a |
|
component to be used as lookup context. The returned 'factory' is a |
|
'naming.IStreamFactory' that can then be '.open()'-ed for reading, or used |
|
in other ways as needed. |
|
|
|
Wherever practical, as we encounter them, we'll be changing PEAK API's that |
|
take filenames to also accept stream sources. |
|
|
|
- The 'naming.IStreamFactory' interface now has an 'address' attribute, which |
|
is the string form of the canonical URL of the target stream. This was |
|
added to make it easier to e.g. report errors in a stream that's being |
|
parsed, since the parser only needs the factory in order to report the |
|
location of an error. (Note: if you implement 'naming.IStreamFactory', be |
|
sure to add this attribute to your implementations.) |
|
|
- The 'peak.util.WSGIServer' module has been moved to the |
- The 'peak.util.WSGIServer' module has been moved to the |
'wsgiref.simple_server' module. The 'wsgiref' reference library for WSGI |
'wsgiref.simple_server' module. The 'wsgiref' reference library for WSGI |
(aka PEP 333) is now distributed with PEAK. |
(aka PEP 333) is now distributed with PEAK. |