Example #1
0
def installParcel(parcel, oldVersion=None):

    loadCerts(parcel, __name__)
    
    from osaf.pim.collections import KindCollection

    cert = schema.ns('osaf.framework.certstore', parcel)
    kind = schema.itemFor(cert.Certificate, parcel.itsView)
    KindCollection.update(kind, 'fullExtent',  kind=kind, recursive=True)
    KindCollection.update(kind, 'exactExtent', kind=kind, recursive=False)
def installParcel(parcel, oldVersion=None):
    """
    Creates Items that live in the initial repository. 

    Run at repository buildtime. 
    """

    # A KindCollection of all FlickPhoto kinds. The flickrIDIndex is used to
    # lookup photos by flickrID quickly.
    flickrPhotosCollection = KindCollection.update(
        parcel,
        'flickrPhotosCollection',
        kind=FlickrPhotoMixin.getKind(parcel.itsView),
        recursive=True)

    if not flickrPhotosCollection.hasIndex('flickrIDIndex'):
        flickrPhotosCollection.addIndex('flickrIDIndex',
                                        'attribute',
                                        attribute='flickrID',
                                        compare="__cmp__")

    # A NewFlickrCollectionEvent that adds a "Owner" collection to the sidebar
    addFlickrCollectionByOwnerEvent = AddFlickrCollectionEvent.update(
        parcel,
        'addFlickrCollectionByOwnerEvent',
        blockName='addFlickrCollectionByOwnerEvent',
        collectionType='Owner')

    # A NewFlickrCollectionEvent that adds a "Tag" collection to the sidebar
    addFlickrCollectionByTagEvent = AddFlickrCollectionEvent.update(
        parcel,
        'addFlickrCollectionByTagEvent',
        blockName='addFlickrCollectionByTagEvent',
        collectionType='Tag')

    handler = FlickrHandler.update(parcel,
                                   'flickrHandler',
                                   blockName='_flickr_flickrHandler')

    # A BlockEvent that tickles the background update task to run
    # Add an event for managing p2p access to collections
    updateEvent = BlockEvent.update(parcel,
                                    None,
                                    blockName='_flickr_UpdateFlickrNow',
                                    dispatchEnum='SendToBlockByReference',
                                    destinationBlockReference=handler)

    # Add menu items to Chandler
    demoMenu = schema.ns('osaf.views.main', parcel).ExperimentalMenu

    flickrMenu = Menu.update(parcel,
                             'FlickrDemoMenu',
                             blockName='FlickrDemoMenu',
                             title=_(u'F&lickr'),
                             helpString=_(u'Download Flickr photos'),
                             childrenBlocks=[],
                             parentBlock=demoMenu)

    MenuItem.update(parcel,
                    'NewFlickrCollectionByOwner',
                    blockName='NewFlickrCollectionByOwnerMenuItem',
                    title=_(u'Create new Flickr collection by &Owner...'),
                    event=addFlickrCollectionByOwnerEvent,
                    eventsForNamedLookup=[addFlickrCollectionByOwnerEvent],
                    parentBlock=flickrMenu)

    MenuItem.update(parcel,
                    'NewFlickrCollectionByTag',
                    blockName='NewFlickrCollectionByTagMenuItem',
                    title=_(u'Create new Flickr collection by &Tag...'),
                    event=addFlickrCollectionByTagEvent,
                    eventsForNamedLookup=[addFlickrCollectionByTagEvent],
                    parentBlock=flickrMenu)

    MenuItem.update(parcel,
                    'UpdateFlickrNow',
                    blockName='UpdateFlickrNowMenuItem',
                    title=_(u'&Update Flickr collections'),
                    event=updateEvent,
                    eventsForNamedLookup=[updateEvent],
                    parentBlock=flickrMenu)

    # The periodic task that adds new photos to the collection in the background
    UpdateTask.update(parcel,
                      'updateTask',
                      run_at_startup=True,
                      interval=timedelta(minutes=60))

    # The periodic task that sets the Flickr's API key
    LicenseTask.update(parcel,
                       "licenseTask",
                       run_at_startup=True,
                       interval=timedelta(days=1))

    # The detail view used to display a flickrPhoto
    blocks = schema.ns('osaf.framework.blocks', parcel)
    detail = schema.ns('osaf.views.detail', parcel)

    detail.makeSubtree(parcel, FlickrPhoto, [
        detail.makeArea(
            parcel,
            'AuthorArea',
            position=0.6,
            childBlocks=[
                detail.makeLabel(parcel, _(u'author'), borderTop=4),
                detail.makeSpacer(parcel, width=6),
                detail.makeEditor(parcel,
                                  'AuthorAttribute',
                                  viewAttribute=u'owner',
                                  presentationStyle={'format': 'static'}),
            ]).install(parcel)
    ])
Example #3
0
def installParcel(parcel, oldVersion=None):
    """
    Creates Items that live in the initial repository. 

    Run at repository buildtime. 
    """

    # A KindCollection of all FlickPhoto kinds. The flickrIDIndex is used to
    # lookup photos by flickrID quickly.
    flickrPhotosCollection = KindCollection.update(
        parcel, 'flickrPhotosCollection',
        kind = FlickrPhotoMixin.getKind(parcel.itsView),
        recursive = True)

    if not flickrPhotosCollection.hasIndex('flickrIDIndex'):
        flickrPhotosCollection.addIndex('flickrIDIndex', 'attribute',
                                        attribute='flickrID', compare="__cmp__")

    # A NewFlickrCollectionEvent that adds a "Owner" collection to the sidebar
    addFlickrCollectionByOwnerEvent = AddFlickrCollectionEvent.update(
        parcel, 'addFlickrCollectionByOwnerEvent',
        blockName = 'addFlickrCollectionByOwnerEvent',
        collectionType = 'Owner')

    # A NewFlickrCollectionEvent that adds a "Tag" collection to the sidebar
    addFlickrCollectionByTagEvent = AddFlickrCollectionEvent.update(
        parcel, 'addFlickrCollectionByTagEvent',
        blockName = 'addFlickrCollectionByTagEvent',
        collectionType = 'Tag')

    handler = FlickrHandler.update(parcel, 'flickrHandler',
                                   blockName='_flickr_flickrHandler')

    # A BlockEvent that tickles the background update task to run
    # Add an event for managing p2p access to collections
    updateEvent = BlockEvent.update(parcel, None,
                                    blockName='_flickr_UpdateFlickrNow',
                                    dispatchEnum='SendToBlockByReference',
                                    destinationBlockReference=handler)

    # Add menu items to Chandler
    demoMenu = schema.ns('osaf.views.main', parcel).ExperimentalMenu

    flickrMenu = Menu.update(
        parcel, 'FlickrDemoMenu',
        blockName = 'FlickrDemoMenu',
        title = _(u'F&lickr'),
        helpString = _(u'Download Flickr photos'),
        childrenBlocks = [ ],
        parentBlock = demoMenu)

    MenuItem.update(
        parcel, 'NewFlickrCollectionByOwner',
        blockName = 'NewFlickrCollectionByOwnerMenuItem',
        title = _(u'Create new Flickr collection by &Owner...'),
        event = addFlickrCollectionByOwnerEvent,
        eventsForNamedLookup = [addFlickrCollectionByOwnerEvent],
        parentBlock = flickrMenu)
 
    MenuItem.update(
        parcel, 'NewFlickrCollectionByTag',
        blockName = 'NewFlickrCollectionByTagMenuItem',
        title = _(u'Create new Flickr collection by &Tag...'),
        event = addFlickrCollectionByTagEvent,
        eventsForNamedLookup = [addFlickrCollectionByTagEvent],
        parentBlock = flickrMenu)

    MenuItem.update(
        parcel, 'UpdateFlickrNow',
        blockName = 'UpdateFlickrNowMenuItem',
        title = _(u'&Update Flickr collections'),
        event = updateEvent,
        eventsForNamedLookup = [updateEvent],
        parentBlock = flickrMenu)

    # The periodic task that adds new photos to the collection in the background
    UpdateTask.update(parcel, 'updateTask',
                      run_at_startup=True,
                      interval=timedelta(minutes=60))

    # The periodic task that sets the Flickr's API key
    LicenseTask.update(parcel, "licenseTask",
                       run_at_startup=True,
                       interval=timedelta(days=1))

    # The detail view used to display a flickrPhoto
    blocks = schema.ns('osaf.framework.blocks', parcel)
    detail = schema.ns('osaf.views.detail', parcel)

    detail.makeSubtree(parcel, FlickrPhoto, [
        detail.makeArea(parcel, 'AuthorArea',
                        position=0.6,
                        childBlocks=[
                            detail.makeLabel(parcel, _(u'author'), borderTop=4),
                            detail.makeSpacer(parcel, width=6),
                            detail.makeEditor(parcel, 'AuthorAttribute',
                                              viewAttribute=u'owner',
                                              presentationStyle={'format': 'static'}
                                          ),
                        ]).install(parcel)
    ])