Exemple #1
0
    def test_taggedValues(self):
        """Test that we can update tagged values of more than one element
        """

        e1 = Element("foo")
        e2 = Element("bar")
        e1.setTaggedValue("x", 1)
        e2.setTaggedValue("x", 2)
        self.assertEqual(e1.getTaggedValue("x"), 1)
        self.assertEqual(e2.getTaggedValue("x"), 2)
Exemple #2
0
 def apply(self, IClass, *args, **kw):  # noqa: N803
     instance = self.__instance
     existing = Element.queryTaggedValue(IClass, instance.key, default=None)
     tags = {}
     if existing:
         tags[instance.key] = existing
     value = instance.factory(*args, **kw)
     instance.store(tags, value)
     Element.setTaggedValue(IClass, instance.key, tags[instance.key])
     # IClass.setTaggedValue(instance.key, tags[instance.key])
     return self
Exemple #3
0
 def test_taggedValues(self):
     """Test that we can update tagged values of more than one element
     """
     
     e1 = Element("foo")
     e2 = Element("bar")
     e1.setTaggedValue("x", 1)
     e2.setTaggedValue("x", 2)
     self.assertEqual(e1.getTaggedValue("x"), 1)
     self.assertEqual(e2.getTaggedValue("x"), 2)
Exemple #4
0
def merged_tagged_value_dict(schema, name):
    """Look up the tagged value 'name' in schema and all its bases, assuming
    that the value under 'name' is a dict. Return a dict that consists of
    all dict items, with those from more-specific interfaces overriding those
    from more-general ones.
    """
    tv = {}
    for iface in reversed(schema.__iro__):
        tv.update(Element.queryTaggedValue(iface, name, default={}))
    return tv
Exemple #5
0
def merged_tagged_value_list(schema, name):
    """Look up the tagged value 'name' in schema and all its bases, assuming
    that the value under 'name' is a list. Return a list that consists of
    all elements from all interfaces and base interfaces, with values from
    more-specific interfaces appearing at the end of the list.
    """
    tv = []
    for iface in reversed(schema.__iro__):
        tv.extend(Element.queryTaggedValue(iface, name, default=[]))
    return list(set(tv))