The changes announced last night just got checked in. Some people have asked me to explain two things:

 - what's wrong with Globals ?
 - why use 'view' instead of 'repository' ?

What's wrong with Globals ?
---------------------------

Globals, and global variables in general, have two flaws:

  - They break software layering, all layers of the software have to ensure
    the global variables are happy, since any of the other layers may use
    them.

  - They assume that the value they describe is unique for the whole app,
    there could only be one repository open at a time in Chandler for example.
    While this is a safe assumption in the Chandler app at the moment, in unit
    tests it was broken recently when Morgen implemented a sharing test
    involving two repositories in the same process. Such assumptions are, in
    fact, inherently unsafe.

Why use 'view' and not 'repository' ?
-------------------------------------

Before there was multithreaded support in the repository, there was only a
repository object. When I added support for concurrent views of the same repository - typically in different threads, but that doesn't have to be the case - the concept of repository view was added. Both objects support almost the same API, the repository object delegating most of its calls to the current view. By using the view instead of the repository, you're saving yourself the time to lookup the current view from the repository, a thread local lookup and another method call.


Andi..


On Wed, 26 Jan 2005, Code Janitor wrote:


Today, I went through the entire Chandler codebase and removed all references to Globals.repository. Below is the list of the files that changed to accomodate this. The changes are a bunch of boilerplate that could be summed as follows:


 - all class methods that needed it had a 'view' argument added to their
   signature
 - ChandlerItem and its subclasses ContentItem, CalendarEvent, etc.....
   all had an optional 'view' keyword argument added to their constructor
   such that parent, kind and view are not all None at the same time
 - all code invoking these class methods or these constructors was fixed to
   pass the 'view' argument as needed

All unit tests pass and all Chandler functionality I know how to trigger seems to working well.

Let me know if you wish to review these changes or try them out on my Chandler build before I check them in tomorrow Thursday after the staff meeting.

Andi..

M application/Application.py
M application/Globals.py
M application/Parcel.py
M application/dialogs/AccountPreferences.py
M application/dialogs/PublishCollection.py
M application/dialogs/ReminderDialog.py
M application/tests/ParcelLoaderTestCase.py
M distrib/docgen/Util.py
M distrib/docgen/genmodeldocs.py
M parcels/osaf/contentmodel/ContentModel.py
M parcels/osaf/contentmodel/Notes.py
M parcels/osaf/contentmodel/calendar/Calendar.py
M parcels/osaf/contentmodel/contacts/Contacts.py
M parcels/osaf/contentmodel/mail/Mail.py
M parcels/osaf/contentmodel/tasks/Task.py
M parcels/osaf/contentmodel/tests/GenerateItems.py
M parcels/osaf/contentmodel/tests/TestCalendar.py
M parcels/osaf/contentmodel/tests/TestContacts.py
M parcels/osaf/contentmodel/tests/TestContentModel.py
M parcels/osaf/contentmodel/tests/TestItemCollection.py
M parcels/osaf/contentmodel/tests/TestLocations.py
M parcels/osaf/contentmodel/tests/TestMail.py
M parcels/osaf/contentmodel/tests/TestNotes.py
M parcels/osaf/contentmodel/tests/TestStamping.py
M parcels/osaf/contentmodel/tests/TestTask.py
M parcels/osaf/examples/zaobao/RSSData.py
M parcels/osaf/examples/zaobao/ZaoBaoWakeupCall.py
M parcels/osaf/examples/zaobao/blocks.py
M parcels/osaf/framework/attributeEditors/AttributeEditors.py
M parcels/osaf/framework/blocks/calendar/CalendarBlocks.py
M parcels/osaf/framework/blocks/calendar/CalendarCanvas.py
M parcels/osaf/framework/blocks/calendar/CollectionCanvas.py
M parcels/osaf/framework/blocks/detail/Detail.py
M parcels/osaf/framework/sharing/ICalendar.py
M parcels/osaf/framework/sharing/ShareTool.py
M parcels/osaf/framework/sharing/Sharing.py
M parcels/osaf/framework/sharing/tests/TestFileSystemSharing.py
M parcels/osaf/framework/sharing/tests/TestImportICalendar.py
M parcels/osaf/framework/utils/imports/ImportMap.py
M parcels/osaf/framework/utils/imports/Importer.py
M parcels/osaf/framework/utils/imports/MapXML.py
M parcels/osaf/framework/utils/imports/OutlookContacts.py
M parcels/osaf/framework/utils/imports/icalendar.py
M parcels/osaf/framework/wakeup/WakeupCaller.py
M parcels/osaf/framework/wakeup/WakeupCallerParcel.py
M parcels/osaf/framework/wakeup/test/TestWakeupCaller.py
M parcels/osaf/mail/imap.py
M parcels/osaf/mail/message.py
M parcels/osaf/mail/sharing.py
M parcels/osaf/mail/smtp.py
M parcels/osaf/mail/utils.py
M parcels/osaf/mail/tests/MailTestCase.py
M parcels/osaf/mail/tests/TestMessage.py
M parcels/osaf/views/main/Main.py
M repository/item/Item.py
M repository/persistence/Repository.py
M repository/persistence/RepositoryView.py
M repository/query/tests/TestCompoundQueries.py
M repository/query/tests/TestNotification.py
M repository/query/tests/TestSimpleQueries.py
M repository/tests/PreloadedRepositoryUtils.py
M repository/tests/RepositoryTestCase.py
M repository/tests/TestPerfWithRSS.py
M tools/s.py
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

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

Reply via email to