def attach_igisfile(context, logger=None): catalog = getToolByName(context, 'portal_catalog') brains = catalog(portal_type='File') for brain in brains: ob = brain.getObject() mimetype = ob.content_type if mimetype in ['application/vnd.google-earth.kml+xml', 'application/gpx+xml']: if not IGisFile.providedBy(ob): alsoProvides(ob, IGisFile) reindex = True
def set_mapview(context, event): mimetype = context.content_type reindex = False if mimetype in ['application/vnd.google-earth.kml+xml', 'application/gpx+xml']: if not IGisFile.providedBy(context): alsoProvides(context, IGisFile) reindex = True if 'filekml_view' in [l[0] for l in context.getAvailableLayouts()]: context.setLayout('filekml_view') else: if IGisFile.providedBy(context): noLongerProvides(context, IGisFile) reindex = True # reset to default view context.setLayout(context.getDefaultLayout()) # we need to reindex the object, because ObjectEditedEvent is fired # after reindexing if reindex: context.reindexObject()
def attach_igisfile(context, logger=None): if logger is None: # Called as upgrade step: define our own logger. logger = logging.getLogger('collective.geo.file') logger.info('attaching IGisFile to KML, KMZ and GPS Files') portal = getSite() catalog = getToolByName(portal, 'portal_catalog') brains = catalog(portal_type='File') reindex = False for brain in brains: ob = brain.getObject() mimetype = ob.content_type if mimetype in MIMETYPES: if not IGisFile.providedBy(ob): alsoProvides(ob, IGisFile) reindex = True if reindex: logger.info('rebuilding object_provides catalog index') catalog.manage_reindexIndex(ids=['object_provides',])