How to use the zope.event.notify function in Zope

To help you get started, we’ve selected a few Zope examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plone / Products.Archetypes / Products / Archetypes / browser / lifecycle.py View on Github external
def cancel_edit(self):
        """Cancel an edit operation
        """
        notify(EditCancelledEvent(aq_inner(self.context)))
github 05dirnbe / nefi / osx_build / nefi2_osx_amd64_xcode_2015 / bin / nefi2 / model / pipeline.py View on Github external
| *img_path* (str): image path

        """
        try:
            shutil.copy(img_path, os.path.join(os.path.dirname(__file__), '..', '_cache_'))
        except (IOError, OSError) as ex:
            print(ex)
            print('ERROR in update_cache() ' +
                  'Cannot copy to _cache_ directory, make sure there ' +
                  'is enough space on disk')
            sys.exit(1)

        cache_img_path = os.path.join(os.path.dirname(__file__), '..', '_cache_',
                                      os.path.basename(img_path))

        zope.event.notify(CacheAddEvent(cat, cache_img_path))
        self.cache.append((cat, cache_img_path))

github plone / plone.app.discussion / plone / app / discussion / browser / moderation.py View on Github external
/Plone/startseite/++conversation++default/1286200010610352
        """
        context = aq_inner(self.context)
        for path in self.paths:
            comment = context.restrictedTraverse(path)
            content_object = aq_parent(aq_parent(comment))
            allowed_transitions = [
                transition['id'] for transition in self.workflowTool.listActionInfos(object=comment)
                if transition['category'] == 'workflow' and transition['allowed']
                ]
            if action in allowed_transitions:
                self.workflowTool.doActionFor(comment, action)
                comment.reindexObject()
                content_object.reindexObject(idxs=['total_comments'])
                notify(CommentPublishedEvent(content_object, comment))
                # for complexer workflows:
                notify(CommentTransitionEvent(self.context, comment))
github socialplanning / opencore / opencore / listen / browser / view.py View on Github external
if not result:
            return

        title, workflow, archive, mailto, managers = result
        private_archives = "private_list" in self.request.form
        sync_project_membership = "sync_project_membership" in self.request.form

        list = self.context

        list.setTitle(title)
        list.setDescription(unicode(self.request.form.get('description',''), 'utf-8'))

        old_workflow_type = list.list_type
        new_workflow_type = workflow_to_mlist_type(workflow)
            
        notify(ListTypeChanged(list,
                               old_workflow_type.list_marker,
                               new_workflow_type.list_marker))


        list.archived = archive

        list.private_archives = private_archives
        if sync_project_membership:
            if not ISyncWithProjectMembership.providedBy(list):
                alsoProvides(list, ISyncWithProjectMembership)
        else:
            if ISyncWithProjectMembership.providedBy(list):
                noLongerProvides(list, ISyncWithProjectMembership)

        list.managers = tuple(managers)
        self._assign_local_roles_to_managers()
github plone / plone.restapi / src / plone / restapi / deserializer / atcontent.py View on Github external
if modified:
            errors = self.validate()
            if not validate_all:
                errors = {f: e for f, e in errors.items() if f in data}
            if errors:
                errors = [{
                    'message': e,
                    'field': f,
                    'error': 'ValidationError'} for f, e in errors.items()]
                raise BadRequest(errors)

            if create:
                if obj.checkCreationFlag():
                    obj.unmarkCreationFlag()
                notify(ObjectInitializedEvent(obj))
                obj.at_post_create_script()
            else:
                obj.reindexObject()
                notify(ObjectEditedEvent(obj))
                obj.at_post_edit_script()

        # We'll set the layout after the validation and and even if there
        # are no other changes.
        if 'layout' in data:
            layout = data['layout']
            self.context.setLayout(layout)

        # OrderingMixin
        self.handle_ordering(data)

        return obj
github plone / plone.restapi / src / plone / restapi / deserializer / atcontent.py View on Github external
errors = {f: e for f, e in errors.items() if f in data}
            if errors:
                errors = [{
                    'message': e,
                    'field': f,
                    'error': 'ValidationError'} for f, e in errors.items()]
                raise BadRequest(errors)

            if create:
                if obj.checkCreationFlag():
                    obj.unmarkCreationFlag()
                notify(ObjectInitializedEvent(obj))
                obj.at_post_create_script()
            else:
                obj.reindexObject()
                notify(ObjectEditedEvent(obj))
                obj.at_post_edit_script()

        # We'll set the layout after the validation and and even if there
        # are no other changes.
        if 'layout' in data:
            layout = data['layout']
            self.context.setLayout(layout)

        # OrderingMixin
        self.handle_ordering(data)

        return obj
github castlecms / castle.cms / castle / cms / browser / tiles.py View on Github external
# also, destroy any other active edits for this slot
        for key in list(annotations.keys()):
            if key.startswith(TILE_ANNOTATIONS_KEY_PREFIX + '.' + _id + '-copy-'):
                # also delete tiles referenced here.
                if key not in annotations:
                    continue
                data = annotations[key]
                for tile in data.get('tiles', []):
                    # since these are all copied tiles or new tiles, we can remove
                    tile_id = tile['id']
                    if TILE_ANNOTATIONS_KEY_PREFIX + '.' + tile_id in annotations:
                        del annotations[TILE_ANNOTATIONS_KEY_PREFIX + '.' + tile_id]
                del annotations[key]

        notify(MetaTileEditedEvent(self.context, _id))

        return json.dumps({
            'success': True
        })
github plone / plone.restapi / src / plone / restapi / deserializer / local_roles.py View on Github external
roles_list = [key for key in user["roles"] if user["roles"][key]]

                # Limit roles to ones the user is allowed to delegate
                roles_list = set(roles_list).intersection(managed_roles)

                user["roles"] = roles_list
            roles_reindex = sharing_view.update_role_settings(new_roles, reindex=False)

        # reindex object security
        can_reindex = ICatalogAware(self.context, None) or IPloneSiteRoot.providedBy(
            self.context
        )
        if can_reindex and (inherit_reindex or roles_reindex):
            self.context.reindexObjectSecurity()
            if LOCALROLES_MODIFIED_EVENT_AVAILABLE:
                notify(LocalrolesModifiedEvent(self.context, self.request))
github zopefoundation / Zope / src / OFS / CopySupport.py View on Github external
except Exception:
            raise CopyError('Invalid Id')

        self._verifyObjectPaste(ob)

        try:
            ob._notifyOfCopyTo(self, op=0)
        except ConflictError:
            raise
        except Exception:
            raise CopyError('Clone Error')

        orig_ob = ob
        ob = ob._getCopy(self)
        ob._setId(id)
        notify(ObjectCopiedEvent(ob, orig_ob))

        self._setObject(id, ob)
        ob = self._getOb(id)

        ob._postCopy(self, op=0)

        compatibilityCall('manage_afterClone', ob, ob)

        notify(ObjectClonedEvent(ob))

        return ob
github plomino / Plomino / Products / CMFPlomino / PlominoDatabase.py View on Github external
"""
        if not self.isCurrentUserAuthor(doc):
            raise Unauthorized, "You cannot delete this document."
        else:
            # execute the onDeleteDocument code of the form
            form = doc.getForm()
            if form:
                try:
                    self.runFormulaScript("form_"+form.id+"_ondelete", doc, form.onDeleteDocument)
                except PlominoScriptException, e:
                    e.reportError('Document has been deleted, but onDelete event failed.')

            self.getIndex().unindexDocument(doc)
            if self.getIndexInPortal():
                self.portal_catalog.uncatalog_object("/".join(self.getPhysicalPath() + (doc.id,)))
            event.notify(ObjectRemovedEvent(doc, self.documents, doc.id))
            self.documents._delOb(doc.id)