Author: jmorliaguet Date: Thu Jun 15 16:42:53 2006 New Revision: 3418 Modified: cpsskins/branches/paris-sprint-2006/doc/portlets.txt cpsskins/branches/paris-sprint-2006/elements/interfaces.py cpsskins/branches/paris-sprint-2006/elements/slot.py cpsskins/branches/paris-sprint-2006/setup/io/README.txt
Log: - documentation updates - renamed the 'slot' field which contains the name of the slot as 'name' Modified: cpsskins/branches/paris-sprint-2006/doc/portlets.txt ============================================================================== --- cpsskins/branches/paris-sprint-2006/doc/portlets.txt (original) +++ cpsskins/branches/paris-sprint-2006/doc/portlets.txt Thu Jun 15 16:42:53 2006 @@ -308,92 +308,117 @@ [to finish] -PORTLET ORDERING -================ +LOCAL PORTLETS +============== -The portlets displayed in slots need to be ordered. The order information is -stored in the slot's display. +Local portlets are located in slots. +They can be made visible from a given perspective. -We set up some test environment: +Let us create a portlet: - >>> from cpsskins.tests.setup import makeSite - >>> from cpsskins.tests.setup import addThemeManager, addThemeSkeleton - >>> root = getRootFolder() - >>> tmutil = addThemeManager(root, makeSite(root)) + >>> from cpsskins.elements.portlet import TestPortlet as Portlet + >>> portlet = Portlet('Some portlet') + >>> portlet.identifier = 1 -Let us create a theme with two slots ('slot_A', 'slot_B'): +and a slot: >>> from cpsskins.elements.slot import Slot - >>> theme = addThemeSkeleton(tmutil) + >>> slot = Slot(name=u'Right') + >>> slot.identifier = 2 - >>> slot_A = Slot(slot=u'A') - >>> slot_B = Slot(slot=u'B') +Slot names +---------- - >>> theme[u'page'][u'block'][u'cell'][u'slot_a'] = slot_A - >>> theme[u'page'][u'block'][u'cell'][u'slot_b'] = slot_B +A slot has: -The slots A and B have their own display +- a unique identifier that is used internally - >>> from cpsskins.elements.interfaces import IDisplayable - >>> from cpsskins.standard.displays.boxgroup import BoxGroup + >>> slot.identifier + 2 - >>> display_slot_A = IDisplayable(slot_A).getDisplay() - >>> display_slot_B = IDisplayable(slot_B).getDisplay() +- a name that is exposed to the designer: - >>> isinstance(display_slot_A, BoxGroup) - True + >>> str(slot) + 'Right' - >>> isinstance(display_slot_B, BoxGroup) - True +The slot's name determines the portlets that the slot contains. - >>> display_slot_A is not display_slot_B - True +If two different slots have the same slot name, they will display the same +portlets: + >>> slotA = Slot(name=u'Some slot') + >>> slotA.identifier = 5 + >>> slotB = Slot(name=u'Some slot') + >>> slotB.identifier = 6 -LOCAL PORTLETS -============== + >>> from cpsskins.ontology import hasPortlet + >>> from cpsskins.relations import DyadicRelation - >>> from cpsskins.elements.slot import Slot - >>> from cpsskins.elements.portlet import TestPortlet as Portlet - >>> from cpsskins.perspectives import Perspective + >>> relationA = DyadicRelation( + ... predicate=hasPortlet, + ... first=slotA, + ... second=portlet) -Local portlets are displayed in *slots* + >>> relationB = DyadicRelation( + ... predicate=hasPortlet, + ... first=slotB, + ... second=portlet) - >>> portlet = Portlet('Some portlet') - >>> portlet.identifier = 1 + >>> from cpsskins.storage.relations import RelationStorage + >>> relations = RelationStorage() -Let us create a slot: + >>> relations.add(relationA) + >>> relations.add(relationB) - >>> slot = Slot(slot=u'Right') - >>> slot.identifier = 2 + >>> relations.getSeconds(predicate=hasPortlet, first=slotA) + [Portlet('Some portlet')] + + >>> relations.getSeconds(predicate=hasPortlet, first=slotB) + [Portlet('Some portlet')] + +If we change the name of a slot, the portlets that the slot contained +become unavailable, but they are not destroyed: + + >>> slotB.name = u'Some other slot' + >>> relations.getSeconds(predicate=hasPortlet, first=slotB) + [] -And a perspective: +If we change back the slot's name, the portlets will be present in the slot again: + >>> slotB.name = u'Some slot' + >>> relations.getSeconds(predicate=hasPortlet, first=slotB) + [Portlet('Some portlet')] + + +Perspectives +------------ + +Portlets can be associated to a slot from a given perspective. + +We create a perspective: + + >>> from cpsskins.perspectives import Perspective >>> perspective = Perspective('Some perspective') >>> perspective.identifier = 3 Let us create a relation to connect the slots, the portlet and the perspective: >>> from cpsskins.ontology import hasPortletFromPerspective - >>> from cpsskins.relations import TriadicRelation as Triad + >>> from cpsskins.relations import TriadicRelation - >>> relation = Triad( + >>> relation = TriadicRelation( ... predicate=hasPortletFromPerspective, ... first=slot, ... second=portlet, - ... third=perspective - ... ) - -and add them to the storage: + ... third=perspective) - >>> from cpsskins.storage.relations import RelationStorage - >>> storage = RelationStorage() +and add it to the relation storage: - >>> storage[u'some_id'] = relation + >>> relations.add(relation) We can now find the portlets present in the slot from the given perspective: - >>> storage.getSeconds( + >>> relations.getSeconds( ... predicate=hasPortletFromPerspective, ... first=slot, ... third=perspective @@ -405,71 +430,62 @@ >>> other_perspective = Perspective('Some other perspective') >>> other_perspective.identifier = 4 - >>> storage.getSeconds( + >>> relations.getSeconds( ... predicate=hasPortletFromPerspective, ... first=slot, ... third=other_perspective ... ) [] -We clear the storage: - >>> storage.clear() -A slot has: +Finally we clear the storage: -- a unique identifier that is used internally + >>> relations.clear() - >>> slot.identifier - 2 -- a slot name that is exposed to the user. - >>> str(slot) - 'Right' +PORTLET ORDERING +================ +The portlets displayed in slots need to be ordered. The order information is +stored in the slot's display. -If two *different* slots have the *same slot name*, they will display the same -portlets: +We set up some test environment: - >>> slotA = Slot(slot=u'Some slot') - >>> slotA.identifier = 5 - >>> slotB = Slot(slot=u'Some slot') - >>> slotB.identifier = 6 + >>> from cpsskins.tests.setup import makeSite + >>> from cpsskins.tests.setup import addThemeManager, addThemeSkeleton + >>> root = getRootFolder() + >>> tmutil = addThemeManager(root, makeSite(root)) - >>> relationA = Triad( - ... predicate=hasPortletFromPerspective, - ... first=slotA, - ... second=portlet, - ... third=perspective - ... ) +Let us create a theme with two slots ('slot_A', 'slot_B'): - >>> relationB = Triad( - ... predicate=hasPortletFromPerspective, - ... first=slotB, - ... second=portlet, - ... third=perspective - ... ) + >>> from cpsskins.elements.slot import Slot + >>> theme = addThemeSkeleton(tmutil) - >>> storage[u'A'] = relationA - >>> storage[u'B'] = relationB + >>> slot_A = Slot(name=u'A') + >>> slot_B = Slot(name=u'B') - >>> storage.getSeconds( - ... predicate=hasPortletFromPerspective, - ... first=slotA, - ... third=perspective - ... ) - [Portlet('Some portlet')] + >>> theme[u'page'][u'block'][u'cell'][u'slot_a'] = slot_A + >>> theme[u'page'][u'block'][u'cell'][u'slot_b'] = slot_B - >>> storage.getSeconds( - ... predicate=hasPortletFromPerspective, - ... first=slotB, - ... third=perspective - ... ) - [Portlet('Some portlet')] +The slots A and B have their own display -Finally we clear the storage: + >>> from cpsskins.elements.interfaces import IDisplayable + >>> from cpsskins.standard.displays.boxgroup import BoxGroup + + >>> display_slot_A = IDisplayable(slot_A).getDisplay() + >>> display_slot_B = IDisplayable(slot_B).getDisplay() + + >>> isinstance(display_slot_A, BoxGroup) + True + + >>> isinstance(display_slot_B, BoxGroup) + True + + >>> display_slot_A is not display_slot_B + True - >>> storage.clear() +[...] Modified: cpsskins/branches/paris-sprint-2006/elements/interfaces.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/elements/interfaces.py (original) +++ cpsskins/branches/paris-sprint-2006/elements/interfaces.py Thu Jun 15 16:42:53 2006 @@ -165,7 +165,7 @@ title=_(u"Slot's description"), required=False) - slot = TextLine( + name = TextLine( title=_(u"Slot's name"), description=_(u"The slot name is used to identify the slot " "inside a theme. Slot names must be unique on a same page."), Modified: cpsskins/branches/paris-sprint-2006/elements/slot.py ============================================================================== --- cpsskins/branches/paris-sprint-2006/elements/slot.py (original) +++ cpsskins/branches/paris-sprint-2006/elements/slot.py Thu Jun 15 16:42:53 2006 @@ -40,14 +40,14 @@ """ implements(ISlot) - def __init__(self, title=u'', description=u'', slot=u''): + def __init__(self, title=u'', description=u'', name=u''): super(Slot, self).__init__() self.title = title self.description = description - self.slot = slot + self.name = name def __str__(self): - return self.slot + return self.name def __repr__(self): return "Slot('%s', '%s')" % (self.title, str(self)) Modified: cpsskins/branches/paris-sprint-2006/setup/io/README.txt ============================================================================== --- cpsskins/branches/paris-sprint-2006/setup/io/README.txt (original) +++ cpsskins/branches/paris-sprint-2006/setup/io/README.txt Thu Jun 15 16:42:53 2006 @@ -144,7 +144,7 @@ >>> relation = TriadicRelation(predicate=Predicate(u'_ C _ D _'), ... first=Actions(u'Actions portlet'), ... second=Breadcrumbs(u'Breadcrumbs portlet'), - ... third=Slot(slot=u'slotA')) + ... third=Slot(name=u'slotA')) >>> print toXML(relation, u'relations') <?xml version="1.0" encoding="utf-8"?> @@ -174,7 +174,7 @@ >>> pageblock[u'cell2'] = cell2 >>> from cpsskins.elements.slot import Slot - >>> slot = Slot(u'Some slot', slot=u'slot1') + >>> slot = Slot(title=u'Some slot', name=u'slot1') >>> pageblock[u'cell1'][u'slot'] = slot >>> print toXML(pageblock, u'elements', (u'title', u'description'), -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins