[Checkins] SVN: z3c.profiler/trunk/ Added initial implementation
Roger Ineichen
roger at projekt01.ch
Mon Jan 21 05:01:45 EST 2008
Log message for revision 83050:
Added initial implementation
Changed:
A z3c.profiler/trunk/CHANGES.txt
A z3c.profiler/trunk/README.txt
A z3c.profiler/trunk/bootstrap.py
A z3c.profiler/trunk/buildout.cfg
A z3c.profiler/trunk/setup.py
A z3c.profiler/trunk/src/z3c/__init__.py
A z3c.profiler/trunk/src/z3c/profiler/README.txt
A z3c.profiler/trunk/src/z3c/profiler/SETUP.cfg
A z3c.profiler/trunk/src/z3c/profiler/TODO.txt
A z3c.profiler/trunk/src/z3c/profiler/__init__.py
A z3c.profiler/trunk/src/z3c/profiler/browser/README.txt
A z3c.profiler/trunk/src/z3c/profiler/browser/__init__.py
A z3c.profiler/trunk/src/z3c/profiler/browser/configure.zcml
A z3c.profiler/trunk/src/z3c/profiler/browser/favicon.png
A z3c.profiler/trunk/src/z3c/profiler/browser/help.pt
A z3c.profiler/trunk/src/z3c/profiler/browser/help.py
A z3c.profiler/trunk/src/z3c/profiler/browser/img/
A z3c.profiler/trunk/src/z3c/profiler/browser/img/buttonBG.gif
A z3c.profiler/trunk/src/z3c/profiler/browser/img/logo.gif
A z3c.profiler/trunk/src/z3c/profiler/browser/img/logo.png
A z3c.profiler/trunk/src/z3c/profiler/browser/img/menuBG.jpg
A z3c.profiler/trunk/src/z3c/profiler/browser/img/menuSeparator.gif
A z3c.profiler/trunk/src/z3c/profiler/browser/img/topBG.gif
A z3c.profiler/trunk/src/z3c/profiler/browser/menu.pt
A z3c.profiler/trunk/src/z3c/profiler/browser/menu.py
A z3c.profiler/trunk/src/z3c/profiler/browser/profiler.css
A z3c.profiler/trunk/src/z3c/profiler/browser/profiler.pt
A z3c.profiler/trunk/src/z3c/profiler/browser/profiler.py
A z3c.profiler/trunk/src/z3c/profiler/browser/template.pt
A z3c.profiler/trunk/src/z3c/profiler/configure.zcml
A z3c.profiler/trunk/src/z3c/profiler/ftesting.zcml
A z3c.profiler/trunk/src/z3c/profiler/interfaces.py
A z3c.profiler/trunk/src/z3c/profiler/layer.py
A z3c.profiler/trunk/src/z3c/profiler/setup.zcml
A z3c.profiler/trunk/src/z3c/profiler/skin.py
A z3c.profiler/trunk/src/z3c/profiler/testing.py
A z3c.profiler/trunk/src/z3c/profiler/tests.py
A z3c.profiler/trunk/src/z3c/profiler/wsgi.py
A z3c.profiler/trunk/src/z3c/profiler/z3c.profiler-configure.zcml
-=-
Added: z3c.profiler/trunk/CHANGES.txt
===================================================================
--- z3c.profiler/trunk/CHANGES.txt (rev 0)
+++ z3c.profiler/trunk/CHANGES.txt 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,8 @@
+=======
+CHANGES
+=======
+
+Version 1.0.0 (28.9.2007)
+-------------------------
+
+- Initial Release
Property changes on: z3c.profiler/trunk/CHANGES.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/README.txt
===================================================================
--- z3c.profiler/trunk/README.txt (rev 0)
+++ z3c.profiler/trunk/README.txt 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1 @@
+This package provides an profiler skins whcih allows you to profile pages.
\ No newline at end of file
Property changes on: z3c.profiler/trunk/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/bootstrap.py
===================================================================
--- z3c.profiler/trunk/bootstrap.py (rev 0)
+++ z3c.profiler/trunk/bootstrap.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 75940 2007-05-24 14:45:00Z srichter $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Property changes on: z3c.profiler/trunk/bootstrap.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/buildout.cfg
===================================================================
--- z3c.profiler/trunk/buildout.cfg (rev 0)
+++ z3c.profiler/trunk/buildout.cfg 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,136 @@
+[buildout]
+develop = .
+parts = logs app checker coverage test var
+find-links = http://pypi.python.org/simple/z3c.layer.pagelet/
+
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3c.profiler [test]
+
+
+[checker]
+recipe = lovely.recipe:importchecker
+path = src/z3c/profiler
+
+
+[coverage]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+
+
+
+[logs]
+recipe = lovely.recipe:mkdir
+path = parts/logs
+
+
+[app]
+recipe = z3c.recipe.dev:app
+eggs = z3c.profiler
+server = zserver
+zope.conf =
+ ${var:zconfig}
+
+ interrupt-check-interval 50
+
+ <server>
+ type WSGI-HTTP
+ address 8000
+ </server>
+
+ <eventlog>
+ <logfile>
+ formatter zope.exceptions.log.Formatter
+ path STDOUT
+ </logfile>
+ </eventlog>
+
+ <accesslog>
+ <logfile>
+ path STDOUT
+ </logfile>
+ </accesslog>
+
+ devmode on
+
+site.zcml =
+ <configure
+ xmlns:meta="http://namespaces.zope.org/meta"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ i18n_domain="zope">
+
+ <!-- Turn on the devmode -->
+ <meta:provides feature="devmode" />
+
+
+ <!-- load profiler setup -->
+ <include package="z3c.profiler" file="setup.zcml" />
+
+
+ <!-- load other zcml files -->
+ <include file="securitypolicy.zcml" />
+ <include file="principals.zcml" />
+
+ </configure>
+
+
+principals.zcml =
+ <unauthenticatedPrincipal
+ id="zope.anybody"
+ title="Unauthenticated User"
+ />
+
+ <unauthenticatedGroup
+ id="zope.Anybody"
+ title="Unauthenticated Users"
+ />
+
+ <authenticatedGroup
+ id="zope.Authenticated"
+ title="Authenticated Users"
+ />
+
+ <everybodyGroup
+ id="zope.Everybody"
+ title="All Users"
+ />
+
+ <principal
+ id="zope.manager"
+ title="Manager"
+ login="Manager"
+ password="password"
+ />
+
+ <grant
+ role="zope.Manager"
+ principal="zope.manager"
+ />
+
+securitypolicy.zcml =
+ <include package="zope.securitypolicy" />
+
+ <securityPolicy
+ component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
+
+ <role id="zope.Anonymous" title="Everybody"
+ description="All users have this role implicitly" />
+ <role id="zope.Manager" title="Site Manager" />
+ <role id="zope.Member" title="Site Member" />
+
+ <!-- Replace the following directive if you don't want public access -->
+ <grant
+ permission="zope.View"
+ role="zope.Anonymous"
+ />
+ <grant
+ permission="zope.app.dublincore.view"
+ role="zope.Anonymous"
+ />
+
+ <grantAll role="zope.Manager" />
+
+
+[var]
+recipe = zc.recipe.filestorage
Added: z3c.profiler/trunk/setup.py
===================================================================
--- z3c.profiler/trunk/setup.py (rev 0)
+++ z3c.profiler/trunk/setup.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,88 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Setup
+
+$Id:$
+"""
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup (
+ name='z3c.profiler',
+ version='0.5.0',
+ author = "Stephan Richter, Roger Ineichen and the Zope Community",
+ author_email = "zope3-dev at zope.org",
+ description = "Profiler skin for Zope3",
+ long_description=(
+ read('README.txt')
+ + '\n\n' +
+ read('CHANGES.txt')
+ ),
+ license = "ZPL 2.1",
+ keywords = "zope3 z3c profiler",
+ classifiers = [
+ 'Development Status :: 4 - Beta',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: Zope Public License',
+ 'Programming Language :: Python',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent',
+ 'Topic :: Internet :: WWW/HTTP',
+ 'Framework :: Zope3'],
+ url = 'http://cheeseshop.python.org/pypi/z3c.profiler',
+ packages = find_packages('src'),
+ include_package_data = True,
+ package_dir = {'':'src'},
+ namespace_packages = ['z3c'],
+ extras_require = dict(
+ test = [
+ 'z3c.coverage',
+ 'z3c.etestbrowser',
+ 'zope.app.testing',
+ 'zope.app.securitypolicy'],
+ ),
+ install_requires = [
+ 'setuptools',
+ 'zc.configuration',
+ 'zope.app.component',
+ 'zope.app.pagetemplate',
+ 'zope.app.publisher',
+ 'zope.app.container',
+ 'zope.app.securitypolicy',
+ 'zope.app.testing',
+ 'zope.app.twisted',
+ 'zope.app.zapi',
+ 'zope.contentprovider',
+ 'zope.i18n',
+ 'zope.i18nmessageid',
+ 'zope.interface',
+ 'zope.schema',
+ 'zope.security',
+ 'zope.testing',
+ 'zope.traversing',
+ 'zope.viewlet',
+ 'z3c.i18n',
+ 'z3c.layer',
+ 'z3c.macro',
+ 'z3c.pagelet',
+ 'z3c.template',
+ 'z3c.zrtresource',
+ 'z3c.layer.pagelet',
+ ],
+ zip_safe = False,
+)
\ No newline at end of file
Property changes on: z3c.profiler/trunk/setup.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/__init__.py
===================================================================
--- z3c.profiler/trunk/src/z3c/__init__.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/__init__.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,7 @@
+# this is a namespace package
+try:
+ import pkg_resources
+ pkg_resources.declare_namespace(__name__)
+except ImportError:
+ import pkgutil
+ __path__ = pkgutil.extend_path(__path__, __name__)
Property changes on: z3c.profiler/trunk/src/z3c/__init__.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/README.txt
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/README.txt (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/README.txt 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,36 @@
+======
+README
+======
+
+This package offers a profiler including a skin. This profiler allows you to
+profile views on a existing Zope3 application.
+
+Let's access the profiler start page:
+
+ >>> from z3c.etestbrowser.testing import ExtendedTestBrowser
+ >>> user = ExtendedTestBrowser()
+ >>> user.addHeader('Accept-Language', 'en')
+ >>> user.open('http://localhost/++skin++Profiler')
+
+If you access the profiler, you can push the start button:
+
+ >>> user.getControl('Start').click()
+ >>> 'Show Profile' in user.contents
+ True
+
+Now we can go to the help.html page which get profiled. Let's use another
+browser for this.
+
+ >>> newBrowser = ExtendedTestBrowser()
+ >>> newBrowser.open('http://localhost/++skin++Profiler/help.html')
+ >>> newBrowser.url
+ 'http://localhost/++skin++Profiler/help.html'
+
+After calling the help.html page, we can go to the doProfile page and show the
+profile by clicking on the ``Show Profile`` button:
+
+ >>> user.getControl('Show Profile').click()
+
+If we whould not call this form within this test, we whould see the profile
+data table. But we do not see the profile data table. Probably the testrunner
+conflicts with the monkey call.
Property changes on: z3c.profiler/trunk/src/z3c/profiler/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/SETUP.cfg
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/SETUP.cfg (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/SETUP.cfg 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,3 @@
+<data-files zopeskel/etc/package-includes>
+ z3c.profiler-*.zcml
+</data-files>
Added: z3c.profiler/trunk/src/z3c/profiler/TODO.txt
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/TODO.txt (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/TODO.txt 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,34 @@
+====
+TODO
+====
+
+- remove z3c.pagelet dependency, use only z3c.template
+
+- use separate templates for profile output presentation
+
+- store profile calls in a global none persistent way and allow to show them
+ later till we restart the server
+
+- implement a better data to table conversion
+
+- implement javascript based client side table sorting
+
+- offer a input field for urls which allows us to start profile calls.
+ Store such urls in a session and offer a list for a easy recall.
+
+- implement profile comparsion, allow to comapre profile calls based
+ on the timing
+
+- implement export for profile call data. Probaly implement a export for
+ more then one profile call data as a zip. Check what tools are available
+ for reporting such profile data.
+
+- implement profile data file download (csv formated)
+
+- implement import profile call data for comparsion
+
+- implement i18n translation support
+
+- add more documentation
+
+- add help page text
Property changes on: z3c.profiler/trunk/src/z3c/profiler/TODO.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/__init__.py
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/__init__.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/__init__.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1 @@
+# This file is necessary to make this directory a package.
Property changes on: z3c.profiler/trunk/src/z3c/profiler/__init__.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/browser/README.txt
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/browser/README.txt (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/browser/README.txt 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,17 @@
+======
+README
+======
+
+This package offers a profiler including a skin. This profiler allows you to
+profile views on a existing Zope3 application.
+
+Let's access the profiler start page:
+
+ >>> from z3c.etestbrowser.testing import ExtendedTestBrowser
+ >>> user = ExtendedTestBrowser()
+ >>> user.addHeader('Accept-Language', 'en')
+ >>> user.open('http://localhost/++skin++Profiler')
+
+If you access the profiler, you can push the start button:
+
+ >>> print user.contents
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/browser/__init__.py
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/browser/__init__.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/browser/__init__.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: __init__.py 72088 2007-01-18 01:09:33Z rogerineichen $
+"""
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/__init__.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/browser/configure.zcml
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/browser/configure.zcml (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/browser/configure.zcml 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,85 @@
+<configure
+ xmlns:zope="http://namespaces.zope.org/zope"
+ xmlns="http://namespaces.zope.org/browser"
+ xmlns:z3c="http://namespaces.zope.org/z3c"
+ i18n_domain="z3c">
+
+
+ <!-- resources -->
+ <zrt-resource
+ name="profiler.css"
+ file="profiler.css"
+ layer="z3c.profiler.layer.IProfilerBrowserLayer"
+ />
+
+ <resource
+ name="favicon.png"
+ file="favicon.png"
+ layer="z3c.profiler.layer.IProfilerBrowserLayer"
+ />
+
+ <resourceDirectory
+ name="img"
+ directory="img"
+ layer="z3c.profiler.layer.IProfilerBrowserLayer"
+ />
+
+
+ <!-- layout -->
+ <z3c:layout
+ for="*"
+ layer="z3c.profiler.layer.IProfilerBrowserLayer"
+ template="template.pt"
+ />
+
+ <!-- menu provider -->
+ <zope:adapter
+ name="IMenuProvider"
+ factory=".menu.MenuProvider"
+ />
+
+ <z3c:template
+ name=""
+ template="menu.pt"
+ for="..interfaces.IMenuProvider"
+ layer="z3c.profiler.layer.IProfilerBrowserLayer"
+ />
+
+ <!-- profiler page -->
+ <z3c:pagelet
+ name="doProfile"
+ for="*"
+ class=".profiler.ProfilerPagelet"
+ layer="z3c.profiler.layer.IProfilerBrowserLayer"
+ permission="zope.ManageServices"
+ />
+
+ <z3c:template
+ for=".profiler.ProfilerPagelet"
+ template="profiler.pt"
+ layer="z3c.profiler.layer.IProfilerBrowserLayer"
+ />
+
+ <defaultView
+ name="doProfile"
+ for="*"
+ layer="z3c.profiler.layer.IProfilerBrowserLayer"
+ />
+
+
+ <!-- credits page -->
+ <z3c:pagelet
+ name="help.html"
+ for="*"
+ class=".help.HelpPagelet"
+ layer="z3c.profiler.layer.IProfilerBrowserLayer"
+ permission="zope.View"
+ />
+
+ <z3c:template
+ for=".help.HelpPagelet"
+ template="help.pt"
+ layer="z3c.profiler.layer.IProfilerBrowserLayer"
+ />
+
+</configure>
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/browser/favicon.png
===================================================================
(Binary files differ)
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/favicon.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: z3c.profiler/trunk/src/z3c/profiler/browser/help.pt
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/browser/help.pt (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/browser/help.pt 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1 @@
+Not written yet ;-)
\ No newline at end of file
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/help.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/browser/help.py
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/browser/help.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/browser/help.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,23 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: __init__.py 72087 2007-01-18 01:03:33Z rogerineichen $
+"""
+__docformat__ = "reStructuredText"
+
+from z3c.pagelet import browser
+
+
+class HelpPagelet(browser.BrowserPagelet):
+ """Help page."""
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/help.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/browser/img/buttonBG.gif
===================================================================
(Binary files differ)
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/img/buttonBG.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added: z3c.profiler/trunk/src/z3c/profiler/browser/img/logo.gif
===================================================================
(Binary files differ)
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/img/logo.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added: z3c.profiler/trunk/src/z3c/profiler/browser/img/logo.png
===================================================================
(Binary files differ)
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/img/logo.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Added: z3c.profiler/trunk/src/z3c/profiler/browser/img/menuBG.jpg
===================================================================
(Binary files differ)
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/img/menuBG.jpg
___________________________________________________________________
Name: svn:mime-type
+ image/jpeg
Added: z3c.profiler/trunk/src/z3c/profiler/browser/img/menuSeparator.gif
===================================================================
(Binary files differ)
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/img/menuSeparator.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added: z3c.profiler/trunk/src/z3c/profiler/browser/img/topBG.gif
===================================================================
(Binary files differ)
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/img/topBG.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added: z3c.profiler/trunk/src/z3c/profiler/browser/menu.pt
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/browser/menu.pt (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/browser/menu.pt 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,8 @@
+<ul
+ ><li tal:repeat="item view/items"
+ ><a href="#" class="selected"
+ tal:attributes="href item/url;
+ class item/css"
+ tal:content="item/name">Profiler</a
+ ></li>
+</ul>
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/menu.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/browser/menu.py
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/browser/menu.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/browser/menu.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,62 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: __init__.py 72087 2007-01-18 01:03:33Z rogerineichen $
+"""
+__docformat__ = "reStructuredText"
+
+import zope.interface
+import zope.component
+from zope.traversing.browser import absoluteURL
+
+from z3c.template.template import getPageTemplate
+from z3c.profiler.layer import IProfilerBrowserLayer
+from z3c.profiler.interfaces import IMenuProvider
+
+
+class MenuProvider(object):
+ """Simple menu provider"""
+
+ zope.interface.implements(IMenuProvider)
+ zope.component.adapts(zope.interface.Interface, IProfilerBrowserLayer,
+ zope.interface.Interface)
+
+ template = getPageTemplate()
+
+ def __init__(self, context, request, view):
+ self.__parent__ = view
+ self.context = context
+ self.request = request
+
+ @property
+ def items(self):
+ try:
+ baseURL = absoluteURL(self.context, self.request)
+ except TypeError, e:
+ # not locatable
+ baseURL = '.'
+ return [
+ {'name': 'Profile',
+ 'css' :'',
+ 'url': '%s/doProfile' % baseURL},
+ {'name': 'Help',
+ 'css' :'',
+ 'url': '%s/help.html' % baseURL}
+ ]
+
+ def update(self):
+ pass
+
+ def render(self):
+ return self.template()
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/menu.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/browser/profiler.css
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/browser/profiler.css (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/browser/profiler.css 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,188 @@
+/* zrt-replace: "../img" tal"string:${context/++resource++img}" */
+
+body {
+ font-family: Verdana, sans-serif;
+ font-size: 100%;
+ width: 100%;
+ background-color: #F3F3EE;
+ margin: 0px;
+ padding: 0px;
+}
+
+/* [ html ]---------------------------------------------------------------- */
+
+form {
+ margin: 0px;
+ padding: 0px;
+}
+
+img {
+ border: 0;
+}
+
+a:link {
+ color: #D91813;
+ text-decoration: none;
+}
+
+a:visited {
+ color: #A68E8E;
+ text-decoration: none;
+}
+
+a:hover {
+ color: #8C100D;
+}
+
+pre {
+ background-color: #F8F8F8;
+}
+
+
+/* [ layout ]---------------------------------------------------------------- */
+
+div#layoutWrapper {
+ font-size: 80%;
+ background-color: #F3F3EE;
+ text-align: left;
+ padding: 0px;
+ border-top: solid white 1px;
+ border-right: solid white 1px;
+ border-left: solid white 1px;
+}
+
+#logo {
+ padding-top: 10px;
+}
+
+
+/* [ header ]-------------------------------------------------------------- */
+
+div#headerContainer {
+ height: 75px;
+ margin: 0px;
+ padding: 0px;
+ background: #3112C2 url(../img/topBG.gif) repeat-x top left;
+}
+
+/*---[ menu ]----------------------------------------------------------------*/
+
+#menuContainer {
+ width: 100%;
+ height: 33px;
+ background: #3112C2 url(../img/menuBG.jpg) repeat-x top left;
+ margin: 0;
+ padding: 0;
+}
+
+#menuContainer ul {
+ margin: 0;
+ padding: 0;
+}
+
+
+#menuContainer li {
+ float: left;
+ margin: 0;
+ padding: 0 1px 0 0;
+ list-style: none;
+ background: url(../img/menuSeparator.gif) no-repeat top right;
+}
+
+#menuContainer a {
+ float: left;
+ padding: 9px 9px;
+ height: 15px;
+ text-decoration: none;
+ border-bottom: none;
+ color: #ffffff;
+}
+
+#menuContainer a:hover {
+ color: #ffffff;
+ background: #230D8C;
+}
+
+#menuContainer a.selected {
+ color: #8C100D;
+ background: #230D8C;
+}
+
+
+/*---[ content ]-------------------------------------------------------------*/
+
+#contentContainer {
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ clear: both;
+}
+
+#content {
+ margin: 0px;
+ padding: 10px;
+}
+
+div.title {
+ font-weight: bold;
+ padding: 10px 0px;
+}
+
+div.description {
+ padding-bottom: 10px;
+}
+
+
+/*---[ table ]---------------------------------------------------------------*/
+
+table.output {
+ width: 100%;
+}
+
+table.output tr th {
+ text-align: left;
+ font-weight: normal;
+ padding: 4px;
+ background: url(../img/buttonBG.gif) repeat-x left top;
+ border-right: 1px solid #FFFFFF;
+}
+
+table.output tr td {
+ padding: 2px;
+ white-space: pre;
+}
+
+table.output tr td.path {
+ width: 500px;
+}
+
+table.output tr td.smallColumn {
+ width: 50px;
+ white-space: nowrap;
+}
+
+
+/* ---[ form tags ]-------------------------------------------------------- */
+
+form {
+ display: inline;
+}
+
+div.buttons {
+ padding: 10px 0px 10px 0px;
+}
+
+input, textarea, select {
+ margin: 0px;
+ padding: 0px;
+}
+
+.button {
+ cursor: pointer;
+ border: outset 1px #ccc;
+ background: #999999;
+ color: #666666;
+ font-weight: bold;
+ padding: 1px 2px;
+ background: url(../img/buttonBG.gif) repeat-x left top;
+}
Added: z3c.profiler/trunk/src/z3c/profiler/browser/profiler.pt
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/browser/profiler.pt (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/browser/profiler.pt 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,256 @@
+<div tal:define="stats view/listStats">
+ <form method="post" action="./doProfile"
+ tal:attributes="action view/action">
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td valign="top">
+ <h4>Start Profiler</h4>
+ </td>
+ <td valign="top">
+ <h4>Report Settings</h4>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <div>
+ <div>
+ <input type="text" size="2" name="calls:int"
+ tal:attributes="value request/calls|string:2" />
+ <input type="submit" class="button" name="profiler.install" value="Enable"
+ tal:attributes="name view/profilerButton/name;
+ value view/profilerButton/value" />
+ <input type="submit" class="button" name="profiler.reload" value="Show Profile"
+ tal:condition="view/showProfileButton" />
+ </div>
+ </div>
+ </td>
+ <td valign="top">
+ <div tal:condition="stats">
+ <table>
+ <tr>
+ <td>
+ Select request:
+ </td>
+ <td>
+ <select name="stats" tal:define="default request/stats|nothing">
+ <option tal:repeat="stat stats"
+ tal:attributes="value stat/uri;
+ selected python:stat['uri'] == default"
+ tal:content="string:${stat/uri} (${stat/calls} calls)"></option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Number of records:
+ </td>
+ <td>
+ <input type="text" name="limit:int" class="textType"
+ tal:attributes="value request/limit|string:500" />
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Mode:
+ </td>
+ <td>
+ <select name="mode"
+ tal:define="default request/mode|string:stats">
+ <option tal:repeat="item python:('stats', 'callees', 'callers')"
+ tal:content="item"
+ tal:attributes="value item; selected python:item == default">
+ </option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Sort on:
+ </td>
+ <td>
+ <select name="sorton"
+ tal:define="default request/sorton|string:time">
+ <option tal:repeat="item python:(
+ ('time', 'internal time'),
+ ('cumulative', 'cumulative time'),
+ ('calls', 'call count'),
+ ('pcalls', 'primitive call count'),
+ ('name', 'function name'),
+ ('file', 'file name'),
+ ('module', 'module name'),
+ ('line', 'line number'),
+ ('nfl', 'name/file/line'),
+ ('stdname', 'standard name'))"
+ tal:attributes="value python:item[0];
+ selected python:item[0] == default"
+ tal:content="python:item[1]"></option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Strip dirs:
+ </td>
+ <td>
+ <input type="checkbox" name="stripdirs:bool" class="checkboxWidget"
+ tal:attributes="checked request/stripdirs|nothing" />
+ </td>
+ </tr>
+ </table>
+ <br />
+ <input type="submit" class="button" name="view_stats" value="Update" />
+ </div>
+ </td>
+ </tr>
+ </table>
+ <div tal:define="data view/statsData">
+ <tal:block condition="data">
+ <div class="title">Stats</div>
+ <div class="description"
+ tal:repeat="line data/summary"
+ tal:content="line">
+ summary
+ </div>
+ <table class="output" width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tal:block repeat="row data/rows">
+ <tr tal:condition="row/thead">
+ <th class="smallColumn" tal:content="row/ncalls">
+ ncalls
+ </th>
+ <th class="smallColumn" tal:content="row/tottime">
+ tottime
+ </th>
+ <th class="smallColumn" tal:content="row/totpercall">
+ totpercall
+ </th>
+ <th class="smallColumn" tal:content="row/cumtime">
+ cumtime
+ </th>
+ <th class="smallColumn" tal:content="row/percall">
+ percall
+ </th>
+ <th class="path" tal:content="row/fn">
+ fn
+ </th>
+ </tr>
+ <tr tal:condition="not:row/thead">
+ <td class="smallColumn" tal:content="row/ncalls">
+ ncalls
+ </td>
+ <td class="smallColumn" tal:content="row/tottime">
+ tottime
+ </td>
+ <td class="smallColumn" tal:content="row/totpercall">
+ totpercall
+ </td>
+ <td class="smallColumn" tal:content="row/cumtime">
+ cumtime
+ </td>
+ <td class="smallColumn" tal:content="row/percall">
+ percall
+ </td>
+ <td class="path" tal:content="row/fn">
+ fn
+ </td>
+ </tr>
+ </tal:block>
+ </table>
+ <div class="title">Bad formated profile data</div>
+ <div class="description"
+ tal:repeat="line data/errors"
+ tal:content="line">
+ error
+ </div>
+ </tal:block>
+ </div>
+ <div tal:define="data view/callesData">
+ <tal:block condition="data">
+ <div class="title">Stats by Callers</div>
+ <div class="description"
+ tal:repeat="line data/summary"
+ tal:content="line">
+ summary
+ </div>
+ <table class="output" border="0" cellspacing="0" cellpadding="0" tal:define="rows data/rows">
+ <tr>
+ <th>
+ Function
+ </th>
+ <th>
+ called...
+ </th>
+ <th>
+ time
+ </th>
+ </tr>
+ <tal:block repeat="row rows">
+ <tr>
+ <td tal:content="row/fn">
+ ncalls
+ </td>
+ <td tal:content="row/caller">
+ fn
+ </td>
+ <td tal:content="row/time">
+ time
+ </td>
+ </tr>
+ </tal:block>
+ </table>
+ <div class="title">Bad formated line or missing time data</div>
+ <div class="description"
+ tal:repeat="line data/errors"
+ tal:content="line">
+ error
+ </div>
+ </tal:block>
+ </div>
+ <div tal:define="data view/callersData">
+ <tal:block condition="data">
+ <div class="title">Stats by Callees</div>
+ <div class="description"
+ tal:repeat="line data/summary"
+ tal:content="line">
+ summary
+ </div>
+ <table class="output" border="0" cellspacing="0" cellpadding="0" tal:define="rows data/rows">
+ <tr>
+ <th width="45%">
+ Function
+ </th>
+ <th width="45%">
+ was called by...
+ </th>
+ <th width="10%">
+ time
+ </th>
+ </tr>
+ <tal:block repeat="row rows">
+ <tr>
+ <td tal:content="row/fn">
+ ncalls
+ </td>
+ <td tal:content="row/caller">
+ fn
+ </td>
+ <td tal:content="row/time">
+ time
+ </td>
+ </tr>
+ </tal:block>
+ </table>
+ <div class="title">Bad formated line or missing time data</div>
+ <div class="description"
+ tal:repeat="line data/errors"
+ tal:content="line">
+ error
+ </div>
+ </tal:block>
+ </div>
+ <pre tal:condition="view/printOutput"
+ tal:content="view/printOutput"></pre>
+ <div tal:condition="not:stats">
+ No data available.
+ </div>
+ </form>
+</div>
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/profiler.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/browser/profiler.py
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/browser/profiler.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/browser/profiler.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,224 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: __init__.py 72087 2007-01-18 01:03:33Z rogerineichen $
+"""
+__docformat__ = "reStructuredText"
+
+import sys
+from cStringIO import StringIO
+
+from zope.traversing.browser import absoluteURL
+
+from z3c.pagelet import browser
+from z3c.profiler.wsgi import getStats
+from z3c.profiler.wsgi import listStats
+from z3c.profiler.wsgi import installProfiler
+from z3c.profiler.wsgi import uninstallProfiler
+
+
+class ProfilerPagelet(browser.BrowserPagelet):
+ """Profiler page.
+
+ It whould be so easy with z3c.form, but I decided to depend on
+ less packages as possible and not using z3c.form and other packages.
+ Forgive me the z3c.pagelet usage but it's so nice to do layout things
+ without METAL macros ;-)
+
+ Note: I didn't internationalize the profiler, should we?
+
+ The stats output is horrible for formatting in html, but let's try to
+ support a nice table instead of the ugly print out whihc needs a
+ monitor with at least 3000px width.
+ """
+
+ doProfile = False
+ _statsData = {}
+ _callersData = {}
+ _callesData = {}
+ _printOutput = None
+
+ @property
+ def action(self):
+ try:
+ return '%s/doProfile' % absoluteURL(self.context, self.request)
+ except TypeError, e:
+ return './doProfile'
+
+ @property
+ def profilerButton(self):
+ if self.doProfile:
+ return {'name':'profiler.uninstall', 'value': 'Stop'}
+ else:
+ return {'name':'profiler.install', 'value': 'Start'}
+
+ @property
+ def showProfileButton(self):
+ if self.doProfile:
+ return True
+ else:
+ return False
+
+ @property
+ def statsData(self):
+ return self._statsData
+
+ @property
+ def callesData(self):
+ return self._callersData
+
+ @property
+ def callersData(self):
+ return self._callesData
+
+ @property
+ def printOutput(self):
+ return self._printOutput
+
+ def listStats(self):
+ return listStats()
+
+ def process(self):
+ aborted = False
+ stats = getStats()
+
+ if not stats:
+ return ''
+
+ uri = self.request.get('stats', None)
+
+ info = stats.get(uri)
+ if not info:
+ info = stats.items()[0][1]
+
+ stats = info[0]
+
+ output = StringIO()
+
+ stripdirs = self.request.get('stripdirs', False)
+ if stripdirs:
+ stats.strip_dirs()
+
+ sorton = self.request.get('sorton', 'time')
+ stats.sort_stats(sorton)
+
+ mode = self.request.get('mode', 'stats')
+ limit = int(self.request.get('limit', 500))
+
+ stdout = sys.stdout
+ sys.stdout = output
+
+ try:
+ getattr(stats, 'print_%s'%mode)(limit)
+ finally:
+ sys.stdout = stdout
+
+ output.seek(0)
+ data = output
+
+ info = {}
+ rows = []
+ info['rows'] = rows
+ info['summary'] = []
+ info['errors'] = []
+ append = rows.append
+ lines = data.readlines()
+
+ if mode == 'stats':
+ for i, line in enumerate(lines):
+ try:
+ ncalls, tottime, totpercall, cumtime, percall, fn = line.split()
+ d = {}
+ d['ncalls'] = ncalls
+ d['tottime'] = tottime
+ d['totpercall'] = totpercall
+ d['cumtime'] = cumtime
+ d['percall'] = percall
+ d['fn'] = fn
+ if ncalls == 'ncalls':
+ d['thead'] = True
+ else:
+ d['thead'] = False
+ append(d)
+ except ValueError, e:
+ if i < 4:
+ info['summary'].append(line)
+ else:
+ # skip lines at the end and parser errors
+ info['errors'].append(line)
+ except Exception, e:
+ aborted = True
+
+ self._statsData = info
+
+ else:
+ for i, line in enumerate(lines):
+ try:
+ d = {}
+ if '...' in line:
+ # skip header line
+ continue
+ varius = line.split()
+ if len(varius) == 0:
+ continue
+ if len(varius) == 1:
+ d['fn'] = ''
+ d['caller'] = varius[0]
+ d['time'] = ''
+ elif len(varius) == 2:
+ d['fn'] = ''
+ d['caller'] = varius[0]
+ d['time'] = varius[1]
+ elif len(varius) == 3:
+ d['fn'] = varius[0]
+ d['caller'] = varius[1]
+ d['time'] = varius[2]
+ if len(varius) >3:
+ continue
+ append(d)
+ except ValueError, e:
+ if i < 4:
+ if not 'Function' in line:
+ # append to summary, but skip header
+ info['summary'].append(line)
+ else:
+ # skip lines at the end and parser errors
+ info['errors'].append(line)
+ except Exception, e:
+ print ""
+ print e
+ aborted = True
+
+ if mode == 'callers':
+ self._callersData = info
+
+ if mode == 'callees':
+ self._callesData = info
+
+ if aborted:
+ self._statsData = {}
+ self._callersData = {}
+ self._callesData = {}
+ output.seek(0)
+ self._printOutput = output.getvalue()
+
+ def update(self):
+ self.process()
+ calls = int(self.request.get('calls', 2))
+ if 'profiler.install' in self.request:
+ installProfiler(calls)
+ self.doProfile = True
+ elif 'profiler.uninstall' in self.request:
+ uninstallProfiler(calls)
+ self.doProfile = False
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/profiler.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/browser/template.pt
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/browser/template.pt (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/browser/template.pt 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
+ i18n:domain="z3c">
+<head>
+<title>Profiler</title>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+<meta http-equiv="cache-control" content="no-cache" />
+<meta http-equiv="pragma" content="no-cache" />
+<link rel="stylesheet" href="profiler.css" type="text/css" media="screen"
+ tal:attributes="href context/++resource++profiler.css" />
+<link rel="icon" type="image/png"
+ tal:attributes="href context/++resource++favicon.png" />
+</head>
+<body>
+<div id="layoutWrapper">
+ <div id="headerContainer">
+ <img id="logo" src="logo.gif" width="234" height="50" alt="logo"
+ tal:attributes="src context/++resource++img/logo.gif" />
+ </div
+ ><div id="menuContainer" tal:content="structure provider:IMenuProvider">
+ <ul>
+ <li>
+ <a href="#" class="selected">Profiler</a>
+ </li>
+ <li>
+ <a href="#">Credits</a>
+ </li>
+ </ul>
+ </div>
+ <div id="contentContainer">
+ <div id="content">
+ <tal:block content="structure provider:pagelet">
+ content
+ </tal:block>
+ </div>
+ </div>
+</div>
+</body>
+</html>
Property changes on: z3c.profiler/trunk/src/z3c/profiler/browser/template.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/configure.zcml
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/configure.zcml (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/configure.zcml 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,15 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ i18n_domain="z3c">
+
+ <!-- Profiler skin -->
+ <interface
+ interface="z3c.profiler.skin.IProfilerBrowserSkin"
+ type="zope.publisher.interfaces.browser.IBrowserSkinType"
+ name="Profiler"
+ />
+
+ <include package=".browser" />
+
+</configure>
Property changes on: z3c.profiler/trunk/src/z3c/profiler/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/ftesting.zcml
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/ftesting.zcml (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/ftesting.zcml 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,29 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ i18n_domain="demo">
+
+ <include file="setup.zcml" />
+
+
+ <securityPolicy
+ component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy"
+ />
+
+ <role id="zope.Manager" title="Manager" />
+ <grantAll role="zope.Manager" />
+ <grantAll role="zope.Anonymous" />
+
+ <principal
+ id="zope.manager"
+ title="Manager"
+ login="Manager"
+ password="password"
+ />
+
+ <grant
+ role="zope.Manager"
+ principal="zope.manager"
+ />
+
+ </configure>
Property changes on: z3c.profiler/trunk/src/z3c/profiler/ftesting.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/interfaces.py
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/interfaces.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/interfaces.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,23 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: __init__.py 72087 2007-01-18 01:03:33Z rogerineichen $
+"""
+
+__docformat__ = "reStructuredText"
+
+import zope.contentprovider.interfaces
+
+class IMenuProvider(zope.contentprovider.interfaces.IContentProvider):
+ """Menu provider."""
Property changes on: z3c.profiler/trunk/src/z3c/profiler/interfaces.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/layer.py
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/layer.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/layer.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,22 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: __init__.py 72087 2007-01-18 01:03:33Z rogerineichen $
+"""
+
+import z3c.layer.pagelet
+
+
+class IProfilerBrowserLayer(z3c.layer.pagelet.IPageletBrowserLayer):
+ """The Profile browser layer."""
Property changes on: z3c.profiler/trunk/src/z3c/profiler/layer.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/setup.zcml
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/setup.zcml (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/setup.zcml 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,129 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:meta="http://namespaces.zope.org/meta"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ xmlns:z3c="http://namespaces.zope.org/z3c"
+ i18n_domain="demo">
+
+ <!-- Turn on the devmode -->
+ <meta:provides feature="devmode" />
+
+ <!-- load meta configuration for exclude -->
+ <include package="zc.configuration" file="meta.zcml" />
+
+ <!-- exclude will prevent from include -->
+ <exclude package="zope.app.authentication" file="ftpplugins.zcml" />
+ <exclude package="zope.app.authentication" file="groupfolder.zcml" />
+ <exclude package="zope.app.authentication" file="principalfolder.zcml" />
+ <exclude package="zope.app.authentication.browser" />
+ <exclude package="zope.app.authentication.browser" file="configure.zcml" />
+ <exclude package="zope.app.authentication.browser" file="groupfolder.zcml" />
+ <exclude package="zope.app.authentication.browser" file="httpplugins.zcml" />
+ <exclude package="zope.app.authentication.browser" file="principalfolder.zcml" />
+ <exclude package="zope.app.authentication.browser" file="session.zcml" />
+ <exclude package="zope.app.broken" file="browser.zcml" />
+ <exclude package="zope.app.container.browser" />
+ <exclude package="zope.app.error.browser" />
+ <exclude package="zope.app.folder.browser" />
+ <exclude package="zope.app.i18n.browser" />
+ <exclude package="zope.app.securitypolicy.browser" />
+ <exclude package="zope.app.session" file="browser.zcml" />
+ <exclude package="zope.dublincore.browser" />
+
+
+ <!-- meta configure -->
+ <include package="zope.app.component" file="meta.zcml" />
+ <include package="zope.app.component.browser" file="meta.zcml" />
+ <include package="zope.app.container.browser" file="meta.zcml" />
+ <include package="zope.app.pagetemplate" file="meta.zcml" />
+ <include package="zope.app.publication" file="meta.zcml" />
+ <include package="zope.app.publisher" file="meta.zcml" />
+ <include package="zope.app.security" file="meta.zcml" />
+ <include package="zope.i18n" file="meta.zcml" />
+ <include package="zope.security" file="meta.zcml" />
+ <include package="zope.securitypolicy" file="meta.zcml" />
+ <include package="zope.viewlet" file="meta.zcml" />
+
+
+ <!-- load 3rd party meta configuration -->
+ <include package="z3c.macro" file="meta.zcml" />
+ <include package="z3c.pagelet" file="meta.zcml" />
+ <include package="z3c.template" file="meta.zcml" />
+ <include package="z3c.zrtresource" file="meta.zcml" />
+
+
+ <!-- vocabulary setup, that's bad and weird, because this is meta configuration -->
+ <include package="zope.app.schema" />
+
+
+ <!-- bootstrap Database -->
+ <include package="zope.app.appsetup" />
+ <include package="zope.app.zopeappgenerations" />
+
+ <!-- zope server -->
+ <include package="zope.app.server" />
+ <include package="zope.app.twisted" />
+ <include package="zope.app.wsgi" />
+
+
+ <!-- zope packages -->
+ <include package="zope.annotation" />
+ <include package="zope.component" />
+ <include package="zope.contentprovider" />
+ <include package="zope.dublincore" />
+ <include package="zope.error" />
+ <include package="zope.location" />
+ <include package="zope.publisher" />
+ <include package="zope.securitypolicy" />
+ <include package="zope.session" />
+ <include package="zope.traversing" />
+ <include package="zope.traversing.browser" />
+
+
+ <!-- zope app package configuration -->
+ <include package="zope.app.authentication" />
+ <include package="zope.app.broken" />
+ <include package="zope.app.component" />
+ <include package="zope.app.container" />
+ <include package="zope.app.folder" />
+ <include package="zope.app.generations" file="subscriber.zcml" />
+ <include package="zope.app.http" />
+ <include package="zope.app.publication" />
+ <include package="zope.app.publisher" />
+ <include package="zope.app.publisher.browser" />
+ <include package="zope.app.security" />
+ <include package="zope.app.securitypolicy" />
+ <include package="zope.app.session" />
+
+ <include package="z3c.layer.minimal" />
+ <include package="z3c.layer.pagelet" />
+ <include package="z3c.macro" />
+ <include package="z3c.pagelet" />
+ <include package="z3c.profiler" />
+
+
+ <browser:defaultView name="index.html" />
+ <browser:defaultSkin name="Profiler" />
+
+ <!-- needs cleanup in zope package configuration -->
+ <!-- Setup charset negotiation -->
+ <adapter
+ factory="zope.publisher.http.HTTPCharsets"
+ for="zope.publisher.interfaces.http.IHTTPRequest"
+ provides="zope.i18n.interfaces.IUserPreferredCharsets"
+ />
+
+ <!-- Setup charset negotiation -->
+ <adapter
+ factory="zope.app.publisher.browser.ModifiableBrowserLanguages"
+ for="zope.publisher.interfaces.http.IHTTPRequest"
+ provides="zope.i18n.interfaces.IModifiableUserPreferredLanguages"
+ />
+
+ <class class="zope.publisher.http.HTTPRequest">
+ <implements
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
+ />
+ </class>
+
+ </configure>
Property changes on: z3c.profiler/trunk/src/z3c/profiler/setup.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/skin.py
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/skin.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/skin.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,23 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: __init__.py 72087 2007-01-18 01:03:33Z rogerineichen $
+"""
+__docformat__ = "reStructuredText"
+
+import z3c.profiler.layer
+
+
+class IProfilerBrowserSkin(z3c.profiler.layer.IProfilerBrowserLayer):
+ """The ``Profiler`` skin."""
Property changes on: z3c.profiler/trunk/src/z3c/profiler/skin.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/testing.py
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/testing.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/testing.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,25 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: testing.py 77310 2007-07-02 18:14:46Z srichter $
+"""
+__docformat__ = "reStructuredText"
+
+import os
+from zope.app.testing.functional import ZCMLLayer
+
+
+TestLayer = ZCMLLayer(
+ os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
+ __name__, 'TestLayer', allow_teardown=True)
Property changes on: z3c.profiler/trunk/src/z3c/profiler/testing.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/tests.py
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/tests.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/tests.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,41 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""z3c.profiler Test Module
+
+$Id:$
+"""
+__docformat__ = "reStructuredText"
+
+import unittest
+from zope.testing import doctest
+from zope.app.testing import placelesssetup
+
+from z3c.profiler import testing
+
+
+def test_suite():
+ suites = []
+ append = suites.append
+ suite = unittest.TestSuite((
+ doctest.DocFileSuite('README.txt',
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
+ ))
+ suite.layer = testing.TestLayer
+ append(suite)
+ return unittest.TestSuite(suites)
+
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: z3c.profiler/trunk/src/z3c/profiler/tests.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/wsgi.py
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/wsgi.py (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/wsgi.py 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,90 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id: __init__.py 72087 2007-01-18 01:03:33Z rogerineichen $
+"""
+
+import time
+import profile
+import pstats
+from threading import RLock
+
+from zope.app.wsgi import WSGIPublisherApplication
+
+#from z3c.profiler import stats
+
+_lock = RLock()
+_calls = 1
+_stats = {}
+
+
+def monkey_call(self, environ, start_response):
+ if (environ.get('HTTP_REFERER', '').endswith('doProfile') or
+ environ.get('REQUEST_URI', '').endswith('doProfile')):
+ return orig_call(self, environ, start_response)
+
+ prof = profile.Profile(time.time)
+ response = prof.runcall(orig_call, self, environ, start_response)
+
+ lock= _lock
+
+ lock.acquire()
+ try:
+ global _stats
+
+ uri = environ.get('REQUEST_URI', '')
+
+ if _stats.has_key(uri):
+ _stats[uri][0].add(prof)
+ _stats[uri][2] = _stats[uri][2] + 1
+ else:
+ _stats[uri] = ([pstats.Stats(prof), environ, 1])
+ finally:
+ global _calls
+ if _calls > 0:
+ _calls = _calls - 1
+
+ if _calls <= 0:
+ WSGIPublisherApplication.__call__ = orig_call
+
+ lock.release()
+
+ return response
+
+
+orig_call = WSGIPublisherApplication.__call__
+
+
+def getStats():
+ return _stats
+
+
+def listStats():
+ stats = []
+ for uri, info in getStats().items():
+ stats.append({'uri': uri, 'calls': info[2]})
+ return stats
+
+
+def installProfiler(calls):
+ global _calls, _stats
+
+ _calls = calls
+ _stats = {}
+
+ WSGIPublisherApplication.__call__ = monkey_call
+
+
+def uninstallProfiler(calls):
+ WSGIPublisherApplication.__call__ = orig_call
Property changes on: z3c.profiler/trunk/src/z3c/profiler/wsgi.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.profiler/trunk/src/z3c/profiler/z3c.profiler-configure.zcml
===================================================================
--- z3c.profiler/trunk/src/z3c/profiler/z3c.profiler-configure.zcml (rev 0)
+++ z3c.profiler/trunk/src/z3c/profiler/z3c.profiler-configure.zcml 2008-01-21 10:01:44 UTC (rev 83050)
@@ -0,0 +1,6 @@
+<configure
+ xmlns:zcml="http://namespaces.zope.org/zcml">
+
+ <include package="z3c.profiler" />
+
+</configure>
Property changes on: z3c.profiler/trunk/src/z3c/profiler/z3c.profiler-configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list