[Dev] Content item initialization
Andi Vajda
vajda at osafoundation.org
Mon Jan 24 11:52:46 PST 2005
Couldn't this be done in the constructor for that item's class ?
Or, if the value needs to be recomputed every time the item is loaded from the
repository, with an onItemLoad(self, view) method ?
Andi..
On Mon, 24 Jan 2005, John Anderson wrote:
> Hi Bryan:
>
> I agree with your comments about _initMixin. I had hoped to make it go away
> and just use initial values. However, Donn pointed out that some of the
> values that needed for the initialization were not known at the time the
> initial value needs to be set by the parcel xml. For example, some of the
> values need to be computed at the time the item is created after Chandler has
> been running. In those cases it doesn't seem unreasonable to just have to set
> some values after creating the item -- but this should only be done if
> initialValue in the parcel xml won't work.
>
> John
>
> Bryan Stearns wrote:
>
>> I recently added a couple of (boolean) attributes to CalendarEventMixin,
>> and I'm confused about the way they're being initialized:
>>
>> - None of the existing attributes have initialValues in the content-model
>> parcel.xml, though that seems to be to be the right place to define them.
>> - I saw other attributes being initialized in CalendarEventMixin's
>> _initMixin(), so I defined mine there; _initMixin() is called by
>> InitOutgoingAttributes(), which is called by MainView's onNewEvent(), so
>> this worked.
>> - When I ran the unit tests, however, the calendar tests failed: simply
>> creating a CalendarEvent() (that is, just using its constructor) doesn't
>> call InitOutgoingAttributes(), so I had to initialize my new attributes in
>> the unit tests separately (just like other attributes were being explicitly
>> initialized in the unit tests). This allowed the unit tests to succeed.
>>
>> It bothers me that I need to remember to initialize attributes in two
>> different places (especially since one place is solely to support unit
>> testing; this seems to make our unit tests less rigorous). Shouldn't we use
>> initialValues?
>>
>> ...Bryan
>>
>> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>>
>> Open Source Applications Foundation "Dev" mailing list
>> http://lists.osafoundation.org/mailman/listinfo/dev
>
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> Open Source Applications Foundation "Dev" mailing list
> http://lists.osafoundation.org/mailman/listinfo/dev
>
More information about the Dev
mailing list