Trees | Index | Help |
|
---|
Package zope :: Package configuration :: Module fields :: Class Path |
|
object
--+ |Element
--+ |Attribute
--+ |Field
--+ |object
--+ | | |MinMaxLen
--+ |Text
--+ | Path
A file path name, which may be input as a relative path
Input paths are converted to absolute paths and normalized.
Let's look at an example:
First, we need a "context" for the field that has a path function for converting relative path to an absolute path.
We'll be careful to do this in an os-independent fashion.
>>> class FauxContext(object): ... def path(self, p): ... return os.path.join(os.sep, 'faux', 'context', p)
>>> context = FauxContext() >>> field = Path().bind(context)
Lets try an absolute path first:
>>> p = unicode(os.path.join(os.sep, 'a', 'b')) >>> n = field.fromUnicode(p) >>> n.split(os.sep) [u'', u'a', u'b']
This should also work with extra spaces around the path:
>>> p = " \n %s \n\n " % p >>> n = field.fromUnicode(p) >>> n.split(os.sep) [u'', u'a', u'b']
Now try a relative path:
>>> p = unicode(os.path.join('a', 'b')) >>> n = field.fromUnicode(p) >>> n.split(os.sep) [u'', u'faux', u'context', u'a', u'b']
Method Summary | |
---|---|
fromUnicode(self,
u)
| |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__repr__() <==> repr(x) | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Class Variable Summary | |
---|---|
Implements |
__implemented__ = <implementedBy zope.configuration.fiel...
|
ClassProvides |
__provides__ = <zope.interface.declarations.ClassProvide...
|
Class Variable Details |
---|
__implemented__
|
__provides__
|
Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Fri Jun 24 12:01:22 2005 | http://epydoc.sf.net |