def to_xml(self): dav = zeit.connector.interfaces.IWebDAVProperties(self) try: tags = lxml.objectify.fromstring(dav.get(KEYWORD_PROPERTY, '')) except lxml.etree.XMLSyntaxError: return self.EMPTY_NODE if tags.tag != '{%s}rankedTags' % KEYWORD_PROPERTY[1]: return self.EMPTY_NODE return tags.getchildren()[0]
def _parse(self): dav = zeit.connector.interfaces.IWebDAVProperties(self) try: tags = lxml.objectify.fromstring(dav.get(KEYWORD_PROPERTY, '')) except lxml.etree.XMLSyntaxError: return None if tags.tag != '{{{1}}}{0}'.format(*KEYWORD_PROPERTY): return None return tags.getchildren()[0]
def __delitem__(self, key): node = self._find_tag_node(key) node.getparent().remove(node) dav = zeit.connector.interfaces.IWebDAVProperties(self) dav[KEYWORD_PROPERTY] = lxml.etree.tostring(node.getroottree()) disabled = dav.get(DISABLED_PROPERTY) if disabled is None: disabled = [] else: disabled = disabled.split(DISABLED_SEPARATOR) disabled.append(key) dav[DISABLED_PROPERTY] = DISABLED_SEPARATOR.join(disabled)
def disabled(self): dav = zeit.connector.interfaces.IWebDAVProperties(self) disabled = dav.get(DISABLED_PROPERTY) if not disabled: return () return tuple(disabled.split(DISABLED_SEPARATOR))
def pinned(self): dav = zeit.connector.interfaces.IWebDAVProperties(self) value = dav.get(PINNED_PROPERTY, '') if not value: return () return tuple(value.split(DISABLED_SEPARATOR))