How to install p2.container
- Download and install ActivePython
- Open Command Prompt
- Type
pypm install p2.container
Lastest release
Tests for the participation aware container
Test-Layer: | functional |
---|
Let's first create an a grok.Container with two grok.Model items in it. >>> from p2.container.container import ParticipationAwareContainer >>> from grok import Model, Container >>> item1 = Model(); item1.title = "item1" >>> item2 = Model(); item2.title = "item2" >>> cont = Container() >>> cont['item1'] = item1 >>> cont['item2'] = item2
Now we adapt it to IParticipationAwareContainer to make it security aware. >>> from p2.container.interfaces import IParticipationAwareContainer
Check enumeration behaviour of the participation aware container. First with no security constraints in place. >>> # participationAwareContainer seems a too long word.. >>> p25r = IParticipationAwareContainer(cont) >>> for key in p25r: ... print key ... item1 item2
>>> [value for value in p25r.values()] [<grokcore.content.components.Model object at 0x...>, <grokcore.content.components.Model object at 0x...>]
>>> [value for value in p25r.keys()] [u'item1', u'item2']
>>> for key, value in p25r.items(): ... print "%s:%s" % (key, value) ... item1:<grokcore.content.components.Model object at 0x...> item2:<grokcore.content.components.Model object at 0x...>
>>> len(p25r) 2
Changelog
0.1 - Unreleased
- Initial release