def fireTransitionScheduled(item, wfc, toward): try: wfc.fireTransitionToward(toward, check_security=True) raise RuntimeWarning("It has WORKED !!! fireTransitionToward(%r)" % (toward)) except (NoTransitionAvailableError, RuntimeWarning): probing.log_exc_info(sys.exc_info(), log.error)
def publishTraverse(self, request, name): """Lookup a name - (request:IRequest, name:str) -> IView The 'request' argument is the publisher request object. The 'name' argument is the name that is to be looked up; it must be an ASCII string or Unicode object. If a lookup is not possible, raise a NotFound error. This method should return an object having the specified name and `self` as parent. The method can use the request to determine the correct object. """ _meth_id = "%s.publishTraverse" % self.__class__.__name__ log.debug("%s: name=%s __name__=%s __parent__=%s context=%s", _meth_id, name, self.__name__, self.__parent__, getattr(self, "context", "UNDEFINED")) try: assert self.publishTraverseResolver is not None return self.publishTraverseResolver(self, request, name) except (AssertionError,): pass # self.publishTraverseResolver is None, not an error except (NotFound,): pass # this is not really an error #probing.log_exc_info(sys.exc_info(), log.debug) except (TypeError, Exception): probing.log_exc_info(sys.exc_info(), log.error) traverser = ItemTraverser(self, request) return traverser.publishTraverse(request, name)
def unsubscribe(self): session = Session() context = removeSecurityProxy(self.context) redirect_url = absoluteURL(context, self.request) user = session.query(User).filter(User.login == self.request.principal.id).first() # In case we somewhy couldn't find the user if user is None: return self.request.response.redirect(redirect_url) # Removing context item from user's subscriptions try: user.subscriptions.remove(context) except ValueError: log.error("Cannot unsubscribe: [%s] not subscribed by [%s]", context, user) probing.log_exc_info(sys.exc_info(), log_handler=log.error) # Redirecting back to the item's page return self.request.response.redirect(redirect_url)
def unsubscribe(self): session = Session() context = removeSecurityProxy(self.context) redirect_url = absoluteURL(context, self.request) user = session.query(User).filter( User.login == self.request.principal.id).first() # In case we somewhy couldn't find the user if user is None: return self.request.response.redirect(redirect_url) # Removing context item from user's subscriptions try: user.subscriptions.remove(context) except ValueError: log.error("Cannot unsubscribe: [%s] not subscribed by [%s]", context, user) probing.log_exc_info(sys.exc_info(), log_handler=log.error) # Redirecting back to the item's page return self.request.response.redirect(redirect_url)