[Checkins] SVN: zc.zodbactivitylog/branches/dev/ First cut implementation.

Jim Fulton jim at zope.com
Fri May 4 09:49:27 EDT 2007


Log message for revision 75436:
  First cut implementation.
  

Changed:
  _U  zc.zodbactivitylog/branches/dev/
  U   zc.zodbactivitylog/branches/dev/README.txt
  U   zc.zodbactivitylog/branches/dev/buildout.cfg
  U   zc.zodbactivitylog/branches/dev/setup.py
  A   zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/
  A   zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/__init__.py
  A   zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/configure.zcml
  A   zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/zope3.py

-=-

Property changes on: zc.zodbactivitylog/branches/dev
___________________________________________________________________
Name: svn:ignore
   - develop-eggs
bin
parts

   + develop-eggs
bin
parts
zodb.log


Modified: zc.zodbactivitylog/branches/dev/README.txt
===================================================================
--- zc.zodbactivitylog/branches/dev/README.txt	2007-05-04 13:07:03 UTC (rev 75435)
+++ zc.zodbactivitylog/branches/dev/README.txt	2007-05-04 13:49:26 UTC (rev 75436)
@@ -1,7 +1,45 @@
 ***********************
-Title Here
+ZODB Activity Log
 ***********************
 
+XXX Need tests!
+
+This package provides an activity log that lets you track database
+activity.  
+
+Just:
+
+- put the package in your path 
+
+- Add::
+
+    <include package="zc.zodbactivitylog" />
+
+  to your ZCML
+
+- Add a log entry to your zope.conf:
+
+  ::
+    <logger>
+       name zc.zodbactivitylog
+       propagate false
+
+      <logfile>
+        path ${buildout:directory}/zodb.log
+        format %(asctime)s %(message)s
+      </logfile>
+    </logger>
+  
+  setting the path option appropriately.
+
+There is an output log entry for each connection.  Each entry has a
+time, a number of reads, and a number of writes.
+
+XXX The log entries don't contain database names.  This package will
+need to be updated for multiple databases.  Maybe I'll do that when I
+write tests.
+
+
 Changes
 *******
 

Modified: zc.zodbactivitylog/branches/dev/buildout.cfg
===================================================================
--- zc.zodbactivitylog/branches/dev/buildout.cfg	2007-05-04 13:07:03 UTC (rev 75435)
+++ zc.zodbactivitylog/branches/dev/buildout.cfg	2007-05-04 13:49:26 UTC (rev 75436)
@@ -1,2 +1,63 @@
 [buildout]
 develop = .
+parts = instance
+
+[zope3]
+recipe = zc.recipe.zope3checkout
+url = svn://svn.zope.org/repos/main/Zope3/trunk
+
+[app]
+recipe = zc.zope3recipes:app
+eggs = zc.zodbactivitylog
+#servers = zserver
+site.zcml =
+  <include package="zope.app.zcmlfiles" />
+  <include package="zope.app.securitypolicy" />
+  <include package="zope.app.securitypolicy" file="meta.zcml" />
+  <include package="zope.app.authentication" />
+  <include package="zope.app.twisted" />
+  <securityPolicy
+    component="zope.app.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" />
+  <grantAll role="zope.Manager" />
+  <unauthenticatedPrincipal
+    id="zope.anybody"
+    title="Unauthenticated User" 
+    />
+  <principal
+      id="zope.manager"
+      title="Manager"
+      login="jim"
+      password_manager="SHA1"
+      password="40bd001563085fc35165329ea1ff5c5ecbdbbeef"
+      />
+  <grant
+      role="zope.Manager"
+      principal="zope.manager"
+      />
+  <include package="zc.zodbactivitylog" />
+
+[instance]
+recipe = zc.zope3recipes:instance
+application = app
+zope.conf =
+   ${database:zconfig}
+
+    
+
+    <logger>
+       name zc.zodbactivitylog
+       propagate false
+
+      <logfile>
+        path ${buildout:directory}/zodb.log
+        format %(asctime)s %(message)s
+      </logfile>
+    </logger>
+   
+
+[database]
+recipe = zc.recipe.filestorage

Modified: zc.zodbactivitylog/branches/dev/setup.py
===================================================================
--- zc.zodbactivitylog/branches/dev/setup.py	2007-05-04 13:07:03 UTC (rev 75435)
+++ zc.zodbactivitylog/branches/dev/setup.py	2007-05-04 13:49:26 UTC (rev 75436)
@@ -4,11 +4,11 @@
 """
 
 setup(
-    name = ''
+    name = 'zc.zodbactivitylog',
     version = '0.1',
     author = 'Jim Fulton',
     author_email = 'jim at zope.com',
-    description = '',
+    description = 'ZODB Activity Monitor that just logs',
     license = 'ZPL 2.1',
     
     packages = find_packages('src'),

Added: zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/__init__.py
===================================================================
--- zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/__init__.py	2007-05-04 13:07:03 UTC (rev 75435)
+++ zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/__init__.py	2007-05-04 13:49:26 UTC (rev 75436)
@@ -0,0 +1,43 @@
+##############################################################################
+#
+# Copyright (c) 2006 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.
+#
+##############################################################################
+"""ZODB Activity Monitor that Just logs
+
+This is somewhat of a temporary hack.  ZODB should really generate events.
+Then we could do this as an event subscriber.
+
+Unfortunately, this is complicated by the api for getting connection
+statitics. This really needs to get cleaned up.
+
+$Id$
+"""
+
+import logging
+
+logger = logging.getLogger(__name__)
+
+class ActivityMonitor:
+
+    def __init__(self, base=None):
+        self._base = base
+
+    def closedConnection(self, conn):
+        loads, stores = conn.getTransferCounts(False)
+        if self._base is not None:
+            self._base.closedConnection(conn)
+        conn.getTransferCounts(True) # Make sure connection counts are cleared
+        logger.info("%s %s", loads, stores)
+
+    def __getattr__(self, name):
+        return getattr(self._base, name)
+


Property changes on: zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/configure.zcml
===================================================================
--- zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/configure.zcml	2007-05-04 13:07:03 UTC (rev 75435)
+++ zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/configure.zcml	2007-05-04 13:49:26 UTC (rev 75436)
@@ -0,0 +1,5 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+  <subscriber handler=".zope3.register" />
+
+</configure>


Property changes on: zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/configure.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/zope3.py
===================================================================
--- zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/zope3.py	2007-05-04 13:07:03 UTC (rev 75435)
+++ zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/zope3.py	2007-05-04 13:49:26 UTC (rev 75436)
@@ -0,0 +1,28 @@
+##############################################################################
+#
+# Copyright (c) 2006 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.
+#
+##############################################################################
+"""Zope 3 setup support
+"""
+
+import ZODB.interfaces
+import zope.component
+import zc.zodbactivitylog
+import zope.app.appsetup.interfaces
+
+
+ at zope.component.adapter(zope.app.appsetup.interfaces.IDatabaseOpenedEvent)
+def register(opened_event):
+    for name, db in zope.component.getUtilitiesFor(ZODB.interfaces.IDatabase):
+        db.setActivityMonitor(
+            zc.zodbactivitylog.ActivityMonitor(db.getActivityMonitor())
+            )


Property changes on: zc.zodbactivitylog/branches/dev/src/zc/zodbactivitylog/zope3.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native



More information about the Checkins mailing list