/usr/share/pyshared/z3c/rml/special.py is in python-z3c.rml 2.0.0-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | ##############################################################################
#
# Copyright (c) 2007 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Special Element Processing
$Id: special.py 128797 2012-12-19 22:00:20Z srichter $
"""
__docformat__ = "reStructuredText"
from z3c.rml import attr, directive, interfaces
class IName(interfaces.IRMLDirectiveSignature):
"""Defines a name for a string."""
id = attr.String(
title=u'Id',
description=u'The id under which the value will be known.',
required=True)
value = attr.Text(
title=u'Value',
description=u'The text that is displayed if the id is called.',
required=True)
class Name(directive.RMLDirective):
signature = IName
def process(self):
id, value = self.getAttributeValues(valuesOnly=True)
manager = attr.getManager(self)
manager.names[id] = value
class IGetName(interfaces.IRMLDirectiveSignature):
"""Get the text for the id."""
id = attr.String(
title=u'Id',
description=u'The id as which the value is known.',
required=True)
class GetName(directive.RMLDirective):
signature = IGetName
def process(self):
id = dict(self.getAttributeValues()).pop('id')
manager = attr.getManager(self)
try:
text = manager.names[id] + (self.element.tail or u'')
except:
import pdb; pdb.set_trace()
# Now replace the element with the text
parent = self.element.getparent()
if parent.text is None:
parent.text = text
else:
parent.text += text
parent.remove(self.element)
class IAlias(interfaces.IRMLDirectiveSignature):
"""Defines an alias for a given style."""
id = attr.String(
title=u'Id',
description=u'The id as which the style will be known.',
required=True)
value = attr.Style(
title=u'Value',
description=u'The style that is represented.',
required=True)
class Alias(directive.RMLDirective):
signature = IAlias
def process(self):
id, value = self.getAttributeValues(valuesOnly=True)
manager = attr.getManager(self)
manager.styles[id] = value
|