本文整理汇总了Python中txdav.xml.base.encodeXMLName函数的典型用法代码示例。如果您正苦于以下问题:Python encodeXMLName函数的具体用法?Python encodeXMLName怎么用?Python encodeXMLName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了encodeXMLName函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_encodeXMLName
def test_encodeXMLName(self):
# No namespace
self.assertEquals(encodeXMLName(None, "name"), "name")
self.assertEquals(encodeXMLName("", "name"), "name")
# Normal case
self.assertEquals(encodeXMLName("namespace", "name"), "{namespace}name")
开发者ID:redtailtech,项目名称:calendarserver,代码行数:7,代码来源:test_base.py
示例2: gotProperties
def gotProperties(qnames):
accessDeniedValue = object()
def gotError(f, name):
f.trap(HTTPError)
code = f.value.response.code
if code == responsecode.NOT_FOUND:
log.error("Property %s was returned by listProperties() "
"but does not exist for resource %s."
% (name, self.resource))
return (name, None)
if code == responsecode.UNAUTHORIZED:
return (name, accessDeniedValue)
return f
whenAllProperties = gatherResults([
maybeDeferred(self.resource.readProperty, qn, request)
.addCallback(lambda p, iqn=qn: (p.sname(), p.toxml())
if p is not None else (encodeXMLName(*iqn), None))
.addErrback(gotError, encodeXMLName(*qn))
for qn in sorted(qnames)
])
@whenAllProperties.addCallback
def gotValues(items):
for even, [name, value] in zip(cycle(["odd", "even"]), items):
if value is None:
value = tags.i("(no value)")
elif value is accessDeniedValue:
value = tags.i("(access forbidden)")
yield tag.clone().fillSlots(
even=even, name=name, value=value,
)
return whenAllProperties
开发者ID:anemitz,项目名称:calendarserver,代码行数:34,代码来源:extensions.py
示例3: get
def get(self, qname, uid=None):
"""
Retrieve the value of a property stored as an extended attribute on the
wrapped path.
@param qname: The property to retrieve as a two-tuple of namespace URI
and local name.
@param uid: The per-user identifier for per user properties.
@raise HTTPError: If there is no value associated with the given
property.
@return: A L{WebDAVDocument} representing the value associated with the
given property.
"""
try:
data = self.attrs.get(self._encode(qname, uid))
except KeyError:
raise HTTPError(StatusResponse(
responsecode.NOT_FOUND,
"No such property: %s" % (encodeXMLName(*qname),)
))
except IOError, e:
if e.errno in _ATTR_MISSING or e.errno == errno.ENOENT:
raise HTTPError(StatusResponse(
responsecode.NOT_FOUND,
"No such property: %s" % (encodeXMLName(*qname),)
))
else:
raise HTTPError(StatusResponse(
statusForFailure(Failure()),
"Unable to read property: %s" % (encodeXMLName(*qname),)
))
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:35,代码来源:xattrprops.py
示例4: __init__
def __init__(self, qname):
HTTPError.__init__(self,
StatusResponse(
responsecode.NOT_FOUND,
"No such property: %s" % encodeXMLName(*qname)
)
)
开发者ID:anemitz,项目名称:calendarserver,代码行数:7,代码来源:extensions.py
示例5: setProperty
def setProperty(self, child, property, uid, delete=False):
propertyCache, key, childCache, token = self.childCache(child)
if delete:
qname = property
qnameuid = qname + (uid,)
if qnameuid in childCache:
del childCache[qnameuid]
else:
qname = property.qname()
qnameuid = qname + (uid,)
childCache[qnameuid] = property
client = self.memcacheClient()
if client is not None:
retries = 10
while retries:
try:
if client.set(
key, childCache, time=self.cacheTimeout,
token=token
):
# Success
break
except TokenMismatchError:
# The value in memcache has changed since we last
# fetched it
self.log.debug("memcacheprops setProperty TokenMismatchError; retrying...")
finally:
# Re-fetch the properties for this child
loaded = self._loadCache(childNames=(child.fp.basename(),))
propertyCache.update(loaded.iteritems())
retries -= 1
propertyCache, key, childCache, token = self.childCache(child)
if delete:
if qnameuid in childCache:
del childCache[qnameuid]
else:
childCache[qnameuid] = property
else:
self.log.error("memcacheprops setProperty had too many failures")
delattr(self, "_propertyCache")
raise MemcacheError("Unable to %s property %s%s on %s" % (
"delete" if delete else "set",
uid if uid else "",
encodeXMLName(*qname),
child
))
开发者ID:eventable,项目名称:CalendarServer,代码行数:55,代码来源:memcacheprops.py
示例6: get
def get(self, qname):
try:
property = self._dict[qname]
except KeyError:
raise HTTPError(StatusResponse(
responsecode.NOT_FOUND,
"No such property: %s" % (encodeXMLName(*qname),)
))
doc = element.WebDAVDocument.fromString(property)
return doc.root_element
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:11,代码来源:util.py
示例7: _encodeKey
def _encodeKey(self, effective, compressNamespace=True):
qname, uid = effective
if compressNamespace:
namespace = self._namespaceCompress.get(qname.namespace,
qname.namespace)
else:
namespace = qname.namespace
result = urllib.quote(encodeXMLName(namespace, qname.name), safe="{}:")
if uid and uid != self._defaultUser:
result = uid + result
r = self.deadPropertyXattrPrefix + result
return r
开发者ID:anemitz,项目名称:calendarserver,代码行数:13,代码来源:xattr.py
示例8: get
def get(self, qname, uid=None, cache=True):
if cache:
propertyCache = self.propertyCache()
qnameuid = qname + (uid,)
if qnameuid in propertyCache:
return propertyCache[qnameuid]
else:
raise HTTPError(StatusResponse(
responsecode.NOT_FOUND,
"No such property: %s%s" % (uid if uid else "", encodeXMLName(*qname))
))
self.log_debug("Read for %s%s on %s" % (
("{%s}:" % (uid,)) if uid else "",
qname,
self.childPropertyStore.resource.fp.path
))
return self.childPropertyStore.get(qname, uid=uid)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:18,代码来源:memcacheprops.py
示例9: toString
def toString(self):
return encodeXMLName(self.namespace, self.name)
开发者ID:anemitz,项目名称:calendarserver,代码行数:2,代码来源:base.py
示例10: HTTPError
if doc is None:
raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, "REPORT request body may not be empty"))
#
# Parse request
#
namespace = doc.root_element.namespace
name = doc.root_element.name
if namespace:
if namespace == davxml.dav_namespace:
request.submethod = "DAV:" + name
elif namespace == caldavxml.caldav_namespace:
request.submethod = "CalDAV:" + name
else:
request.submethod = encodeXMLName(namespace, name)
else:
request.submethod = name
def to_method(namespace, name):
if namespace:
s = "_".join((namespace, name))
else:
s = name
ok = string.ascii_letters + string.digits + "_"
out = []
for c in s:
if c in ok:
out.append(c)
else:
开发者ID:eventable,项目名称:CalendarServer,代码行数:31,代码来源:report.py
示例11: to_method
def to_method(s):
out = []
for c in s:
if c in ok:
out.append(c)
else:
out.append("_")
return "report_" + "".join(out)
if namespace:
method_name = to_method("_".join((namespace, name)))
if namespace == davxml.dav_namespace:
request.submethod = "DAV:" + name
else:
request.submethod = encodeXMLName(namespace, name)
else:
method_name = to_method(name)
request.submethod = name
try:
method = getattr(self, method_name)
# Also double-check via supported-reports property
reports = self.supportedReports()
test = lookupElement((namespace, name))
if not test:
raise AttributeError()
test = davxml.Report(test())
if test not in reports:
开发者ID:anemitz,项目名称:calendarserver,代码行数:31,代码来源:report.py
示例12: action_readProperty
def action_readProperty(rootResource, directory, store, resource, qname):
property = (yield resource.readProperty(qname, None))
print("%r on %s:" % (encodeXMLName(*qname), resource))
print("")
print(property.toxml())
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:5,代码来源:principals.py
示例13: __repr__
def __repr__(self):
return "%s = %s" % (encodeXMLName(self.ns, self.name), self.value)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:2,代码来源:test_memcacheprops.py
示例14: action_readProperty
def action_readProperty(resource, qname):
property = (yield resource.readProperty(qname, None))
print "%r on %s:" % (encodeXMLName(*qname), resource)
print ""
print property.toxml()
开发者ID:azbarcea,项目名称:calendarserver,代码行数:5,代码来源:principals.py
示例15: encodeXMLName
"REPORT request body may not be empty"
))
#
# Parse request
#
namespace = doc.root_element.namespace
name = doc.root_element.name
if namespace:
if namespace == davxml.dav_namespace:
request.submethod = "DAV:" + name
elif namespace == caldavxml.caldav_namespace:
request.submethod = "CalDAV:" + name
else:
request.submethod = encodeXMLName(namespace, name)
else:
request.submethod = name
def to_method(namespace, name):
if namespace:
s = "_".join((namespace, name))
else:
s = name
ok = string.ascii_letters + string.digits + "_"
out = []
for c in s:
if c in ok:
out.append(c)
开发者ID:nunb,项目名称:calendarserver,代码行数:31,代码来源:report.py
示例16: get
def get(self, qname, uid=None):
raise HTTPError(StatusResponse(
responsecode.NOT_FOUND,
"No such property: %s" % (encodeXMLName(*qname),)
))
开发者ID:anemitz,项目名称:calendarserver,代码行数:5,代码来源:noneprops.py
示例17: _encode
def _encode(clazz, name, uid=None):
result = urllib.quote(encodeXMLName(*name), safe='{}:')
if uid:
result = uid + result
r = clazz.deadPropertyXattrPrefix + result
return r
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:6,代码来源:xattrprops.py
注:本文中的txdav.xml.base.encodeXMLName函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论