I'd like to get some other opinions on whether or not it is useful for
learning CPIA to be able to specify a single view (tree of blocks) that
is used to display a particular Item in the detail view without going
into the extra complexity of the "full blown" detail view mechanism.
I had heard that scripts might be an example of such an situation.
Of course I'm not opposed to doing a "full blown" example, I just think
starting with a simple example is useful. And as I mentioned before I
intend to move the tutorial forward to include a complete detail view
example with a discussion on the trade-offs.
John
Bryan Stearns wrote:
[commits] (john) [8190] Bug 3229: Hello world CPIA parcel
example to go with documenation.
There was a brief discussion a week or so ago about what happens when a
reviewer disagrees with a change; that discussion didn't come to any
conclusion, so I don't know what the process is to object to a change
that I didn't review. This particular issue is something that I'm
*very* frustrated by, but I'm trying to work through it in our open
process, so here goes:
The change below is supposed to be an example, but much of it
introduces a new mechanism for associating detail views with items, and
the example just shows how to use that. At the meeting last week where
John proposed this, I objected to it strongly, on the grounds that we
already have a satisfactory mechanism for associating detail views with
items, which isn't hard to use -- adding another doesn't serve any
useful purpose. I stated then that it's important, in example code, to
focus on showing techniques that you expect developers to use in their
code; it's bad to give examples that you wouldn't want developers to
ship. I feel strongly that our examples should focus on doing things
"the Chandler way"; if that "way" needs to be refined, fine, let's
refine it, but let's not pollute it with alternatives we don't need.
I'd like to suggest that this change be backed out, and that John (or
someone else) find a way to show how to add a new content item type and
a detail view for it without creating a new structural mechanism to do
so.
...Bryan
-------- Original Message --------
[commits] (john) [8190] Bug 3229: Hello world CPIA parcel
example to go with documenation.
- Revision
- 8190
- Author
- john
- Date
- 2005-11-07 07:15:46 -0800 (Mon, 07 Nov 2005)
Log Message
Bug 3229:
Hello world CPIA parcel example to go with documenation. Checking in
rough draft. r=donn
Modified Paths
Added Paths
Diff
Modified:
trunk/chandler/parcels/osaf/framework/blocks/ControlBlocks.py (8189
=> 8190)
--- trunk/chandler/parcels/osaf/framework/blocks/ControlBlocks.py 2005-11-05 02:49:04 UTC (rev 8189)
+++ trunk/chandler/parcels/osaf/framework/blocks/ControlBlocks.py 2005-11-07 15:15:46 UTC (rev 8190)
@@ -44,7 +44,7 @@
characterStyle = schema.One(Styles.CharacterStyle)
title = schema.One(schema.Text)
- buttonKind = schema.One(buttonKindEnumType)
+ buttonKind = schema.One(buttonKindEnumType, initialValue="Text")
icon = schema.One(schema.Text)
rightClicked = schema.One(BlockEvent)
event = schema.One(BlockEvent)
Modified: trunk/chandler/parcels/osaf/framework/blocks/Trunk.py
(8189 => 8190)
--- trunk/chandler/parcels/osaf/framework/blocks/Trunk.py 2005-11-05 02:49:04 UTC (rev 8189)
+++ trunk/chandler/parcels/osaf/framework/blocks/Trunk.py 2005-11-07 15:15:46 UTC (rev 8190)
@@ -21,6 +21,14 @@
to customize its behavior.
"""
+class ViewableKind(schema.Annotation):
+ """
+ Annotate the Kind class to add a detailView attribute which is the detailView to
+ use when displaying the Items of this class
+ """
+ schema.kindInfo(annotates=schema.Kind)
+ detailView = schema.One(Block.Block)
+
class wxTrunkParentBlock(ContainerBlocks.wxBoxContainer):
"""
A widget block that gives its TrunkParentBlock a chance to change
Modified: trunk/chandler/parcels/osaf/framework/blocks/Views.py
(8189 => 8190)
--- trunk/chandler/parcels/osaf/framework/blocks/Views.py 2005-11-05 02:49:04 UTC (rev 8189)
+++ trunk/chandler/parcels/osaf/framework/blocks/Views.py 2005-11-07 15:15:46 UTC (rev 8190)
@@ -4,10 +4,8 @@
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
__parcel__ = "osaf.framework.blocks"
-import application.Globals as Globals
-from osaf.framework.blocks.Block import Block
from ContainerBlocks import BoxContainer
-import wx
+from application import schema
class View(BoxContainer):
pass
Modified:
trunk/chandler/parcels/osaf/framework/blocks/__init__.py
(8189 => 8190)
--- trunk/chandler/parcels/osaf/framework/blocks/__init__.py 2005-11-05 02:49:04 UTC (rev 8189)
+++ trunk/chandler/parcels/osaf/framework/blocks/__init__.py 2005-11-07 15:15:46 UTC (rev 8190)
@@ -13,8 +13,7 @@
SplitterWindow, TabbedContainer, ViewContainer
)
-from Trunk import TrunkDelegate, TrunkParentBlock
-from Views import View
+from Trunk import TrunkDelegate, TrunkParentBlock, ViewableKind
from ControlBlocks import (
AEBlock, Button, CheckBox, Choice, ComboBox, ContentItemDetail,
Modified:
trunk/chandler/parcels/osaf/framework/blocks/detail/Detail.py (8189
=> 8190)
--- trunk/chandler/parcels/osaf/framework/blocks/detail/Detail.py 2005-11-05 02:49:04 UTC (rev 8189)
+++ trunk/chandler/parcels/osaf/framework/blocks/detail/Detail.py 2005-11-07 15:15:46 UTC (rev 8190)
@@ -285,24 +285,26 @@
# (Yes, I wrote this as a double nested list comprehension with filtering,
# but I couldn't decide how to work in a lambda function, so I backed off and
# opted for clarity.)
- decoratedSubtreeList = [] # each entry will be (position, path, subtreechild)
- for subtree in self._getSubtrees():
- if keyItem.isKindOf(subtree.key) and subtree.hasLocalAttributeValue('rootBlocks'):
- for block in subtree.rootBlocks:
- entryTobeSorted = (block.getAttributeValue('position', default=sys.maxint),
- block.itsPath,
- self._copyItem(block))
- decoratedSubtreeList.append(entryTobeSorted)
-
- if len(decoratedSubtreeList) == 0:
- assert False, "Don't know how to build a trunk for this kind!"
- # (We can continue here - we'll end up just caching an empty view.)
-
- decoratedSubtreeList.sort()
-
- # Copy our stub block and move the new kids on(to) the block
- trunk = self._copyItem(self.trunkStub)
- trunk.childrenBlocks.extend([ block for position, path, block in decoratedSubtreeList ])
+ trunk = getattr (Trunk.ViewableKind(keyItem), "detailView", None)
+ if trunk is None:
+ decoratedSubtreeList = [] # each entry will be (position, path, subtreechild)
+ for subtree in self._getSubtrees():
+ if keyItem.isKindOf(subtree.key) and subtree.hasLocalAttributeValue('rootBlocks'):
+ for block in subtree.rootBlocks:
+ entryTobeSorted = (block.getAttributeValue('position', default=sys.maxint),
+ block.itsPath,
+ self._copyItem(block))
+ decoratedSubtreeList.append(entryTobeSorted)
+
+ if len(decoratedSubtreeList) == 0:
+ assert False, "Don't know how to build a trunk for this kind!"
+ # (We can continue here - we'll end up just caching an empty view.)
+
+ decoratedSubtreeList.sort()
+
+ # Copy our stub block and move the new kids on(to) the block
+ trunk = self._copyItem(self.trunkStub)
+ trunk.childrenBlocks.extend([ block for position, path, block in decoratedSubtreeList ])
return trunk
def _getSubtrees(self):
Modified: trunk/chandler/parcels/osaf/pim/__init__.py (8189 =>
8190)
--- trunk/chandler/parcels/osaf/pim/__init__.py 2005-11-05 02:49:04 UTC (rev 8189)
+++ trunk/chandler/parcels/osaf/pim/__init__.py 2005-11-07 15:15:46 UTC (rev 8190)
@@ -2,7 +2,7 @@
# (this should include all ContentItem subclasses in this package)
#
from items import (
- ContentKind, ContentItem, ImportanceEnum, Group, Project
+ ContentItem, ImportanceEnum, Group, Project
)
from notes import Note
from contacts import Contact, ContactName
Modified: trunk/chandler/parcels/osaf/pim/items.py (8189 =>
8190)
--- trunk/chandler/parcels/osaf/pim/items.py 2005-11-05 02:49:04 UTC (rev 8189)
+++ trunk/chandler/parcels/osaf/pim/items.py 2005-11-07 15:15:46 UTC (rev 8190)
@@ -22,18 +22,6 @@
logger = logging.getLogger(__name__)
-class ContentKind(Kind):
- """This kind is a metakind for creating other kinds. Kinds which are
- an instance of ContentKind will have an attribute 'detailView' of type
- Block. We could also make this attribute a bidiref."""
-
- __metaclass__ = schema.ItemClass
-
- schema.kindInfo(displayName=u"Metakind 'Content Kind'")
-
- detailView = schema.One() # Block
-
-
class ImportanceEnum(schema.Enumeration):
"""Importance Enum"""
schema.kindInfo(
Added: trunk/chandler/parcels/samples/__init__.py (8189 =>
8190)
--- trunk/chandler/parcels/samples/__init__.py 2005-11-05 02:49:04 UTC (rev 8189)
+++ trunk/chandler/parcels/samples/__init__.py 2005-11-07 15:15:46 UTC (rev 8190)
@@ -0,0 +1,7 @@
+import application.schema as schema
+
+#Comment in tthe following code to enable your favorite sample.
+#Replace "samples.hello_world-1" with your favorite sample
+
+#def installParcel(parcel, oldVersion=None):
+ #schema.synchronize(parcel.itsView, 'samples.hello_world-1')
\ No newline at end of file
Property changes on: trunk/chandler/parcels/samples/__init__.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/chandler/parcels/samples/hello_world-1/__init__.py
(8189 => 8190)
--- trunk/chandler/parcels/samples/hello_world-1/__init__.py 2005-11-05 02:49:04 UTC (rev 8189)
+++ trunk/chandler/parcels/samples/hello_world-1/__init__.py 2005-11-07 15:15:46 UTC (rev 8190)
@@ -0,0 +1,43 @@
+import application.schema as schema
+import osaf.framework.attributeEditors as attributeEditors
+import osaf.framework.blocks as blocks
+from osaf.framework.types.DocumentTypes import RectType, SizeType
+from hello_world import MP3
+
+def installParcel(parcel, oldVersion=None):
+
+ repositoryView = parcel.itsView
+ blocksParcel = schema.ns('osaf.framework.blocks', repositoryView)
+
+ aePresentationStyle = blocks.ControlBlocks.PresentationStyle.update(
+ parcel, 'presentationStyle',
+ format = 'static')
+
+ attributeEditorBlock = blocks.ControlBlocks.AEBlock.update(
+ parcel, 'attributeEditorBlock',
+ blockName = 'HeadlineBlock',
+ alignmentEnum = 'alignTopCenter',
+ viewAttribute = 'about',
+ presentationStyle = aePresentationStyle)
+
+ button = blocks.ControlBlocks.Button.update(
+ parcel, 'button',
+ minimumSize = SizeType (40, 20),
+ alignmentEnum = 'alignTopLeft',
+ stretchFactor = 0.0,
+ title = u'Play')
+
+ view = blocks.BoxContainer.update(
+ parcel, 'HelloWorldBoxContainer',
+ orientationEnum = 'Horizontal',
+ eventBoundary = True,
+ childrenBlocks=[button, attributeEditorBlock])
+
+ blocks.Trunk.ViewableKind(MP3.getKind(repositoryView)).detailView = view
+
+ song = MP3.update(parcel, "French Rock",
+ about = "French Rock")
+
+ #eventually we need to populate the song using:
+ #stream = song.audio.getOutputStream()
+ #stream.write
\ No newline at end of file
Property changes on: trunk/chandler/parcels/samples/hello_world-1/__init__.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
trunk/chandler/parcels/samples/hello_world-1/hello_world.py
(8189 => 8190)
--- trunk/chandler/parcels/samples/hello_world-1/hello_world.py 2005-11-05 02:49:04 UTC (rev 8189)
+++ trunk/chandler/parcels/samples/hello_world-1/hello_world.py 2005-11-07 15:15:46 UTC (rev 8190)
@@ -0,0 +1,7 @@
+from osaf.pim.notes import Note
+from application import schema
+
+class MP3(Note):
+ audio = schema.One (schema.Lob)
+
+
Property changes on: trunk/chandler/parcels/samples/hello_world-1/hello_world.py
___________________________________________________________________
Name: svn:eol-style
+ native
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Open Source Applications Foundation "Dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/dev
|