def newrelic_transaction(event): try: request = event.request published = request.get('PUBLISHED', None) trans = newrelic.agent.current_transaction() # TODO: Better name resolvement. SimpleViewClass seems to have no reference # to the browserview it simplifies. Making it hard to make a proper dotted name. # Preffered name would be: Products.MyProduct.browser.views.MyView # Now we only get the name as defined in conifure zcml, ie: "my_view" transname = published.__name__ if trans: # We only want to track the following: # 1. BrowserViews (but not the resource kind ..) # 2. PageTemplate (/skins/*/*.pt ) being used as views if (IBrowserView.providedBy(published) or IPageTemplate.providedBy(published)) and not IResource.providedBy(published): trans.name_transaction(transname, group='Zope2', priority=1) newrelic.agent.add_custom_parameter('id', published.context.id) newrelic.agent.add_custom_parameter('absolute_url', published.context.absolute_url()) logger.debug("Transaction: {0}".format(transname)) else: # For debugging purpose logger.debug("NO transaction? : {0} Browser: {1} Resource: {2} PageTemplate: {3}".format( transname, IBrowserView.providedBy(published), IResource.providedBy(published), IPageTemplate.providedBy(published))) except Exception, e: # Log it and carry on. logger.exception(e)
def newrelic_transaction(event): try: request = event.request published = request.get('PUBLISHED', None) trans = newrelic.agent.current_transaction() # TODO: Better name resolvement. SimpleViewClass seems to have no reference # to the browserview it simplifies. Making it hard to make a proper dotted name. # Preffered name would be: Products.MyProduct.browser.views.MyView # Now we only get the name as defined in conifure zcml, ie: "my_view" transname = getattr(published, '__name__', None) if not transname: transname = published.__class__.__module__ + '.' + published.__class__.__name__ if trans: # We only want to track the following: # 1. BrowserViews (but not the resource kind ..) # 2. PageTemplate (/skins/*/*.pt ) being used as views # 3. PageTemplates in ZMI if IBrowserView.providedBy(published) or IPageTemplate.providedBy( published): trans.name_transaction(transname, group='Zope2', priority=1) if hasattr(published, 'context'): # Plone newrelic.agent.add_custom_parameter( 'id', getattr(published.context, 'id', '')) newrelic.agent.add_custom_parameter( 'absolute_url', getattr(published.context, 'absolute_url', '')) elif hasattr(published, 'id') and hasattr( published, 'absolute_url'): # Zope newrelic.agent.add_custom_parameter('id', published.id) newrelic.agent.add_custom_parameter( 'absolute_url', published.absolute_url()) else: # We don't know what it is .. so no custom parameters! logger.debug( "Published has no context nor an id/absolute_url. Skipping custom parameters" ) logger.debug("Transaction: {0}".format(transname)) else: # For debugging purpose logger.debug( "NO transaction? : {0} Browser: {1} PageTemplate: {2}". format(transname, IBrowserView.providedBy(published), IPageTemplate.providedBy(published))) except Exception, e: # Log it and carry on. logger.exception(e)
def newrelic_transaction(event): try: request = event.request published = request.get("PUBLISHED", None) trans = newrelic.agent.current_transaction() # TODO: Better name resolvement. SimpleViewClass seems to have no reference # to the browserview it simplifies. Making it hard to make a proper dotted name. # Preffered name would be: Products.MyProduct.browser.views.MyView # Now we only get the name as defined in conifure zcml, ie: "my_view" transname = published.__name__ if trans: # We only want to track the following: # 1. BrowserViews (but not the resource kind ..) # 2. PageTemplate (/skins/*/*.pt ) being used as views # 3. PageTemplates in ZMI if (IBrowserView.providedBy(published) or IPageTemplate.providedBy(published)) and not IResource.providedBy( published ): trans.name_transaction(transname, group="Zope2", priority=1) if hasattr(published, "context"): # Plone newrelic.agent.add_custom_parameter("id", getattr(published.context, "id", "")) newrelic.agent.add_custom_parameter("absolute_url", getattr(published.context, "absolute_url", "")) elif hasattr(published, "id") and hasattr(published, "absolute_url"): # Zope newrelic.agent.add_custom_parameter("id", published.id) newrelic.agent.add_custom_parameter("absolute_url", published.absolute_url()) else: # We don't know what it is .. so no custom parameters! logger.debug("Published has no context nor an id/absolute_url. Skipping custom parameters") logger.debug("Transaction: {0}".format(transname)) else: # For debugging purpose logger.debug( "NO transaction? : {0} Browser: {1} Resource: {2} PageTemplate: {3}".format( transname, IBrowserView.providedBy(published), IResource.providedBy(published), IPageTemplate.providedBy(published), ) ) except Exception, e: # Log it and carry on. logger.exception(e)
def newrelic_transaction(event): try: request = event.request published = request.get('PUBLISHED', None) trans = newrelic.agent.current_transaction() # TODO: Better name resolvement. SimpleViewClass seems to have no reference # to the browserview it simplifies. Making it hard to make a proper dotted name. # Preffered name would be: Products.MyProduct.browser.views.MyView # Now we only get the name as defined in conifure zcml, ie: "my_view" transname = published.__name__ if trans: # We only want to track the following: # 1. BrowserViews (but not the resource kind ..) # 2. PageTemplate (/skins/*/*.pt ) being used as views if (IBrowserView.providedBy(published) or IPageTemplate.providedBy(published) ) and not IResource.providedBy(published): trans.name_transaction(transname, group='Zope2', priority=1) newrelic.agent.add_custom_parameter('id', published.context.id) newrelic.agent.add_custom_parameter( 'absolute_url', published.context.absolute_url()) logger.debug("Transaction: {0}".format(transname)) else: # For debugging purpose logger.debug( "NO transaction? : {0} Browser: {1} Resource: {2} PageTemplate: {3}" .format(transname, IBrowserView.providedBy(published), IResource.providedBy(published), IPageTemplate.providedBy(published))) except Exception, e: # Log it and carry on. logger.exception(e)
text = text.split("/view")[0] obj = doc.unrestrictedTraverse(text, None) if obj is None: obj = doc.unrestrictedTraverse(nav_root_path + '/' + text, None) if obj is None: err = "No object found" logger.warn("%s while trying " "doc.unrestrictedTraverse(text)" "with doc: %s text: %s", err, doc.absolute_url_path(), text) continue else: if IBrowserView.providedBy(obj): obj = obj.context elif (IPageTemplate.providedBy(obj) or IPythonScript.providedBy(obj) or isinstance(obj, FSPythonScript)): obj = obj.getParentNode() if not canRelate(doc, obj): continue uid = IUUID(obj, None) if not uid: continue if uid == myuid: continue if uid in uids:
def __iter__(self): if self.skins_tool is None: self.skins_tool = getToolByName(getSite(), "portal_skins") if self.skin is None: self.skin = self.skins_tool.getDefaultSkin() skin_path = self.skins_tool.getSkinPath(self.skin) if skin_path is None: return for layer_path in skin_path.split(","): try: layer_folder = self.skins_tool.unrestrictedTraverse(layer_path) except KeyError: # Sometimes the active theme declares nonexistent folders # this is not themeeditors fault, so we skip the error continue for name, obj in layer_folder.items(): res = CMFResourceRegistration() res.base_skin = self.skin res.name = name res.layer = layer_path res.actions = [] res.icon = obj.icon res.tags = [] res.path = None if isinstance(obj, FSObject): res.info = _( "On the filesystem", default=u"On the filesystem: ${path}", mapping={"path": obj._filepath} ) res.path = obj._filepath res.actions.append((PMF(u"View"), obj.absolute_url() + "/manage_main")) elif isinstance(obj, Persistent) and not isinstance(obj, DirectoryViewSurrogate): res.tags.append("customized") res.path = "/".join(obj.getPhysicalPath()) # res.info = 'In the database: ' + res.path res.info = _(u"In the database", default=u"In the database: ${path}", mapping={u"path": res.path}) res.actions.append((PMF(u"Edit"), obj.absolute_url() + "/manage_main")) res.actions.append( (PMF(u"Remove"), obj.aq_parent.absolute_url() + "/manage_delObjects?ids=" + obj.getId()) ) elif isinstance(obj, Persistent): res.path = "/".join(obj.getPhysicalPath()) res.info = "In the database: " + res.path res.info = _(u"In the database", default=u"In the database: ${path}", mapping={u"path": res.path}) if IPageTemplate.providedBy(obj): res.tags.append("template") if isinstance(obj, Image) or isinstance(obj, FSImage): res.tags.append("image") elif isinstance(obj, FSPythonScript) or isinstance(obj, CustomizedPythonScript): res.tags.append("python-script") elif isinstance(obj, FSControllerValidator) or isinstance(obj, FSControllerPythonScript): res.tags.append("controller-page-template") elif isinstance(obj, FSDTMLMethod): res.tags.append("dtml") id = obj.getId().lower() if id.endswith(".css"): res.tags.append("stylesheet") elif id.endswith(".js"): res.tags.append("javascript") elif id.endswith(".kss"): res.tags.append("kss") yield res
if obj is None: obj = doc.unrestrictedTraverse(nav_root_path + "/" + text, None) if obj is None: err = "No object found" logger.warn( "%s while trying " "doc.unrestrictedTraverse(text)" "with doc: %s text: %s", err, doc.absolute_url_path(), text, ) continue else: if IBrowserView.providedBy(obj): obj = obj.context elif IPageTemplate.providedBy(obj) or IPythonScript.providedBy(obj) or isinstance(obj, FSPythonScript): obj = obj.getParentNode() if not canRelate(doc, obj): continue uid = IUUID(obj, None) if not uid: continue if uid == myuid: continue if uid in uids: continue