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']
context
(type: NoneType
)
None
default
(type:
ValidatedProperty
)
<zope.schema._bootstrapfields.ValidatedProperty object at 0x40b28f2c>
description
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b223ec>
interface
(type: NoneType
)
None
max_length
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b22ecc>
min_length
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b22e8c>
missing_value
(type: NoneType
)
None
order
(type:
int
)
734
readonly
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b2280c>
required
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b22d0c>
title
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b0208c>
bind(object)
constraint(value)
fromUnicode(u)
get(object)
getDoc()
Returns the documentation for the object.
getName()
Returns the name of the object.
getTaggedValue(tag)
Returns the value associated with tag
.
getTaggedValueTags()
Returns a list of all tags.
query(object, default=None)
queryTaggedValue(tag, default=None)
Returns the value associated with tag
.
set(object, value)
setTaggedValue(tag, value)
Associates value
with key
.
validate(value)
There are no known subclasses.