I've found a few places where the parcel.xml and Python code are
inconsistent with each other in the blocks framework, and I have some
proposed changes to resolve the inconsistencies. If you work on the blocks
framework, I'd appreciate any review/feedback you can give.
For the vast majority of Chandler Kinds, there is a corresponding Python
class with the same name as the Kind, whose base classes correspond to the
Kind's superkinds. For a few, however, there are differences:
osaf.framework.blocks.DynamicContainerBlocks.Menu: the class derives from
MenuBar and DynamicChild, but the Kind derives from Block,
DynamicContainer, and DynamicChild. I propose to resolve this by making
the parcel.xml Kind definition mimic the existing class definition.
osaf.framework.blocks.calendar.CollectionCanvas.CollectionBlock: the class
is named CollectionBlock, but the Kind is named CollectionCanvas. I
propose to rename the class to match its Kind, but add an alias to the
module so that it can still be imported under the old name, until uses of
the old name can be phased out.
osaf.framework.blocks.calendar.CalendarCanvas.WeekBlock: the class is named
WeekBlock, but the Kind is called CanvasWeek. WeekBlock derives from the
CalendarBlock class, but CalendarBlock has no corresponding Kind. I
propose to rename WeekBlock to match its Kind, but add an alias to the
module so that it can still be imported under the old name, until uses of
the old name can be phased out. I also propose to create a Kind
corresponding to CalendarBlock, so that CanvasWeek can use it as its
superkind, thereby matching up the inheritance structure.
Here are some patch excerpts that implement the above changes; please let
me know if you think they will cause any problems:
Index: parcels/osaf/framework/blocks/parcel.xml
===================================================================
--- parcels/osaf/framework/blocks/parcel.xml (revision 5629)
+++ parcels/osaf/framework/blocks/parcel.xml (working copy)
@@ -803,8 +803,7 @@
-->
<Kind itsName="Menu">
<classes
key="python">osaf.framework.blocks.DynamicContainerBlocks.Menu</classes>
- <superKinds itemref="docSchema:Block"/>
- <superKinds itemref="docSchema:DynamicContainer"/>
+ <superKinds itemref="docSchema:MenuBar"/>
<superKinds itemref="docSchema:DynamicChild"/>
</Kind>
Index: parcels/osaf/framework/blocks/calendar/parcel.xml
===================================================================
--- parcels/osaf/framework/blocks/calendar/parcel.xml (revision 5629)
+++ parcels/osaf/framework/blocks/calendar/parcel.xml (working copy)
@@ -15,15 +15,20 @@
<version>0.3</version>
<Kind itsName="CollectionCanvas">
- <classes
key="python">osaf.framework.blocks.calendar.CollectionCanvas.CollectionBlock</classes>
+ <classes
key="python">osaf.framework.blocks.calendar.CollectionCanvas.CollectionCanvas</classes>
<superKinds itemref="blocks:RectangularChild"/>
<attributes itemref="blocks:selection"/>
</Kind>
- <Kind itsName="CanvasWeek">
- <classes
key="python">osaf.framework.blocks.calendar.CalendarCanvas.WeekBlock</classes>
+ <Kind itsName="CalendarBlock">
+ <classes
key="python">osaf.framework.blocks.calendar.CalendarCanvas.CalendarBlock</classes>
<superKinds itemref="doc:CollectionCanvas"/>
+ </Kind>
+ <Kind itsName="CanvasWeek">
+ <classes
key="python">osaf.framework.blocks.calendar.CalendarCanvas.CanvasWeek</classes>
+ <superKinds itemref="doc:CalendarBlock"/>
+
<Attribute itsName="rangeStart">
<type itemref="DateTime"/>
</Attribute>
Index: parcels/osaf/framework/blocks/calendar/CollectionCanvas.py
===================================================================
--- parcels/osaf/framework/blocks/calendar/CollectionCanvas.py (revision 5629)
+++ parcels/osaf/framework/blocks/calendar/CollectionCanvas.py (working copy)
@@ -720,7 +720,7 @@
def OnEndDragNone(self):
pass
-class CollectionBlock(Block.RectangularChild):
+class CollectionCanvas(Block.RectangularChild):
"""
@ivar selection: selected item (persistent)
@type selection: Item
@@ -767,4 +767,6 @@
def onRemoveEventUpdateUI(self, event):
event.arguments['Enable'] = (self.selection is not None)
-
+
+
+CollectionBlock = CollectionCanvas # backward compatibility
Index: parcels/osaf/framework/blocks/calendar/CalendarCanvas.py
===================================================================
--- parcels/osaf/framework/blocks/calendar/CalendarCanvas.py (revision 5629)
+++ parcels/osaf/framework/blocks/calendar/CalendarCanvas.py (working copy)
@@ -605,7 +605,7 @@
def Notify(self):
self._callback()
-class CalendarBlock(CollectionCanvas.CollectionBlock):
+class CalendarBlock(CollectionCanvas.CollectionCanvas):
""" Abstract block used as base Kind for Calendar related blocks.
This base class can be used for any block that displays a collection of
@@ -1878,7 +1878,7 @@
y = int(self.hourHeight * (datetime.hour +
datetime.minute/float(60)))
return wx.Point(x, y)
-class WeekBlock(CalendarBlock):
+class CanvasWeek(CalendarBlock):
def __init__(self, *arguments, **keywords):
super(WeekBlock, self).__init__ (*arguments, **keywords)
@@ -1917,6 +1917,8 @@
else:
self.selectedDate = self.rangeStart
+WeekBlock = CanvasWeek # Backward compatibility
+
class wxInPlaceEditor(wx.TextCtrl):
def __init__(self, *arguments, **keywords):
super(wxInPlaceEditor, self).__init__(style=wx.TE_PROCESS_ENTER |
wx.NO_BORDER,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Open Source Applications Foundation "Dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/dev