From jinty at codespeak.net Mon Apr 3 00:17:17 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Mon Apr 3 00:17:19 2006
Subject: [z3-checkins] r25241 - z3/sqlos/trunk/src/sqlos
Message-ID: <20060402221717.298A3100E1@code0.codespeak.net>
Author: jinty
Date: Mon Apr 3 00:17:15 2006
New Revision: 25241
Modified:
z3/sqlos/trunk/src/sqlos/configure.zcml
Log:
Oops, didnt run the tests properly, removing the zcml refernce to the removed sybase adapter.
Modified: z3/sqlos/trunk/src/sqlos/configure.zcml
==============================================================================
--- z3/sqlos/trunk/src/sqlos/configure.zcml (original)
+++ z3/sqlos/trunk/src/sqlos/configure.zcml Mon Apr 3 00:17:15 2006
@@ -90,13 +90,6 @@
/>
-
-
-
-
Author: jinty
Date: Mon Apr 3 00:21:40 2006
New Revision: 25242
Added:
z3/sqlos/trunk/patch-test.py (contents, props changed)
Modified:
z3/sqlos/trunk/makefile
Log:
You should now just be able to download the source and run "make test". if I havnt forgotten somethign that is.
Modified: z3/sqlos/trunk/makefile
==============================================================================
--- z3/sqlos/trunk/makefile (original)
+++ z3/sqlos/trunk/makefile Mon Apr 3 00:21:40 2006
@@ -2,7 +2,8 @@
CSV=${HERE}/csv
ZP=${HERE}/../
ZH=${HERE}/../../
-PYTHON=python
+PYTHON=python2.4
+z3includes=Zope3/zopeskel/etc/package-includes
all : test clean
@@ -17,11 +18,16 @@
coverage_sorted : coverage sorted
-test :
- export PYTHONPATH=${ZP} && cd ${ZH} && $(PYTHON) test.py -vpf --all sqlos
-
-clean :
+.PHONY: clean
+clean:
find . \( -name '*~' -o -name '*.py[co]' -o -name '*.bak' -o -name '#*#' -o -name '\.#*' \) -exec rm {} \; -print
+ $(PYTHON) setup.py clean
+
+.PHONY: realclean
+realclean: clean
+ rm -rf dist
+ rm -rf build
+ rm -rf Zope3
reindent :
~/src/reindent.py -r -v .
@@ -39,22 +45,26 @@
Zope3:
$(MAKE) z3-checkout
-Zope3/package-includes/sqlos-meta.zcml: Zope3 includes/sqlos-meta.zcml
- cp includes/sqlos-meta.zcml Zope3/package-includes
-
-Zope3/package-includes/sqlos-configure.zcml: Zope3 includes/sqlos-configure.zcml
- cp includes/sqlos-configure.zcml Zope3/package-includes
+$(z3includes)/sqlos-%.zcml: includes/sqlos-%.zcml Zope3
+ cp $< $@
-Zope3/package-includes/sqlos-ftesting.zcml: Zope3 includes/sqlos-ftesting.zcml
- cp includes/sqlos-ftesting.zcml Zope3/package-includes
+.PHONY: sqlos-meta
+sqlos-meta: $(z3includes)/sqlos-meta.zcml $(z3includes)/sqlos-configure.zcml $(z3includes)/sqlos-ftesting.zcml
-.PHONY: z3-build
-z3-build: Zope3
+.PHONY: develop
+develop: Zope3 sqlos-meta
cd Zope3 && $(MAKE) PYTHON=$(PYTHON) inplace
+ touch Zope3/src/easy-install.pth
+ PYTHONPATH=Zope3/src $(PYTHON) setup.py develop -S Zope3/src --install-dir Zope3/src
-.PHONY: test-dist
-test-dist: z3-update z3-build \
- Zope3/package-includes/sqlos-meta.zcml\
- Zope3/package-includes/sqlos-configure.zcml\
- Zope3/package-includes/sqlos-ftesting.zcml
- cd releases && $(PYTHON) SQLOS-test.py
+.PHONY: patch
+patch:
+ # This is butttt ugly pul hopefully temporary
+ set - e;\
+ if [ `grep 'site.addsitedir(src)' Zope3/test.py -c` == 0 ]; then\
+ cat patch-test.py | patch -p0;\
+ fi
+
+.PHONY: testall
+test: develop patch
+ cd Zope3 && $(PYTHON) test.py --test-path=../src -s sqlos
Added: z3/sqlos/trunk/patch-test.py
==============================================================================
--- (empty file)
+++ z3/sqlos/trunk/patch-test.py Mon Apr 3 00:21:40 2006
@@ -0,0 +1,13 @@
+Index: Zope3/test.py
+===================================================================
+--- Zope3/test.py (revision 65897)
++++ Zope3/test.py (working copy)
+@@ -26,6 +26,8 @@
+ # add src to path
+ src = os.path.join(here, 'src')
+ sys.path.insert(0, src) # put at beginning to avoid one in site_packages
++import site
++site.addsitedir(src)
+
+ from zope.testing import testrunner
+
From reebalazs at codespeak.net Mon Apr 3 09:44:25 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Mon Apr 3 09:44:26 2006
Subject: [z3-checkins] r25244 -
z3/jsonserver/branch/merge/concatresource/compression
Message-ID: <20060403074425.44185100E9@code0.codespeak.net>
Author: reebalazs
Date: Mon Apr 3 09:44:23 2006
New Revision: 25244
Modified:
z3/jsonserver/branch/merge/concatresource/compression/css.py
z3/jsonserver/branch/merge/concatresource/compression/javascript.py
Log:
Has to use safe option for compression
Modified: z3/jsonserver/branch/merge/concatresource/compression/css.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/compression/css.py (original)
+++ z3/jsonserver/branch/merge/concatresource/compression/css.py Mon Apr 3 09:44:23 2006
@@ -5,7 +5,7 @@
from thirdparty.packer import CSSPacker
-csspacker_full = CSSPacker('full')
+csspacker_full = CSSPacker('safe')
def compress(data):
return csspacker_full.pack(data)
Modified: z3/jsonserver/branch/merge/concatresource/compression/javascript.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/compression/javascript.py (original)
+++ z3/jsonserver/branch/merge/concatresource/compression/javascript.py Mon Apr 3 09:44:23 2006
@@ -4,7 +4,7 @@
from thirdparty.packer import JavascriptPacker
-jspacker_full = JavascriptPacker('full')
+jspacker_full = JavascriptPacker('safe')
def compress(data):
return jspacker_full.pack(data)
From reebalazs at codespeak.net Mon Apr 3 15:59:37 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Mon Apr 3 15:59:38 2006
Subject: [z3-checkins] r25255 - z3/jsonserver/branch/merge/concatresource
Message-ID: <20060403135937.83A0C100FB@code0.codespeak.net>
Author: reebalazs
Date: Mon Apr 3 15:59:35 2006
New Revision: 25255
Modified:
z3/jsonserver/branch/merge/concatresource/__init__.py
z3/jsonserver/branch/merge/concatresource/concatfileresource.py
z3/jsonserver/branch/merge/concatresource/configure.zcml
z3/jsonserver/branch/merge/concatresource/interfaces.py
Log:
Allow utility mechanism to extend list of files
- Check if files exist on configuration, to report unexistant resource files
on startup.
- add the utility hook to allow extend filelist by other components
- hack the module to be aliased to under "Products", this allows the product
to be imported multiple times.
Modified: z3/jsonserver/branch/merge/concatresource/__init__.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/__init__.py (original)
+++ z3/jsonserver/branch/merge/concatresource/__init__.py Mon Apr 3 15:59:35 2006
@@ -2,3 +2,8 @@
Product init
'''
+# alias myself to Products, directly
+import sys, Products
+if not hasattr(Products, 'concatresource'):
+ # only 1st import is aliased.
+ Products.concatresource = sys.modules['Products.concatresource'] = sys.modules[globals()['__name__']]
Modified: z3/jsonserver/branch/merge/concatresource/concatfileresource.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/concatfileresource.py (original)
+++ z3/jsonserver/branch/merge/concatresource/concatfileresource.py Mon Apr 3 15:59:35 2006
@@ -8,30 +8,81 @@
from zope.interface import implements
from interfaces import IContextFile
+# we are aliased to Products, hence the following absolute import
+from Products.concatresource.interfaces import IConcatResourceAddon
from fileresource import File
from compression import compress
+import time
+import zope.component
+from zope.component.exceptions import ComponentLookupError
class ConcatFiles(object):
- 'A resource that concatenates files and compresses the result'
+ '''A resource that concatenates files and compresses the result
+
+ It is also possible to extend the statically given list via
+ a utility.
+ '''
implements(IContextFile)
def __init__(self, pathlist, name):
# Path is now a list.
assert isinstance(pathlist, (list, tuple))
- self.pathlist = pathlist
+ # check all files, just to raise error if don't exist
+ for path in pathlist:
+ file(path, 'rb').close()
+ #
+ self.pathlist_base = pathlist
self.__name__ = name
- # Init a list of files.
- self.content = [File(path, name) for path in pathlist]
+ # markers for pathlist modification
+ self.pathlist = []
+ self.fileslist_changed = None
+ self.fileslist = []
+ def getPathList(self):
+ 'Gets the extended pathlist'
+ # we allow the list to be extended via an utility
+ try:
+ registry = zope.component.getUtility(IConcatResourceAddon, self.__name__)
+ except ComponentLookupError:
+ extend = []
+ else:
+ extend = registry.getAddonFiles()
+ pathlist = self.pathlist_base + extend
+ return pathlist
+
+ def getFilesList(self):
+ 'Gets the list of files'
+ ## # XXX We have two choices:
+ ## # 1. We only calculate the list once, on startup
+ ## # that is, we suppose that the file resource is
+ ## # called up after the extension reg has been finished
+ ## # and that it never changes later.
+ ## # 2. but it also could be like this to allow changes later:
+ pathlist = self.getPathList()
+ if pathlist != self.pathlist:
+ ##if not self.pathlist:
+ ##pathlist = self.getPathList()
+ # mark pathlist modification
+ self.pathlist = pathlist
+ self.fileslist_changed = time.time()
+ fileslist = self.fileslist = [File(path, self.__name__) for path in pathlist]
+ else:
+ fileslist = self.fileslist
+ return fileslist
+
def getLastMod(self):
- return max([f.getLastMod() for f in self.content])
+ # We take in consideration that the pathlist
+ # itself could have changed too.
+ return max([f.getLastMod() for f in self.getFilesList()] +
+ [self.fileslist_changed])
def getContents(self):
- assert self.content, 'Must contain at least one resource.'
- result = self.content[0].getContents()
+ fileslist = self.getFilesList()
+ assert fileslist, 'Must contain at least one resource.'
+ result = fileslist[0].getContents()
content_type = result['content_type']
data = [result['data']]
- for subres in self.content[1:]:
+ for subres in fileslist[1:]:
d = subres.getContents()
# all elements must have the same content type.
assert d['content_type'] == content_type
Modified: z3/jsonserver/branch/merge/concatresource/configure.zcml
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/configure.zcml (original)
+++ z3/jsonserver/branch/merge/concatresource/configure.zcml Mon Apr 3 15:59:35 2006
@@ -7,6 +7,6 @@
/>
-
+
Modified: z3/jsonserver/branch/merge/concatresource/interfaces.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/interfaces.py (original)
+++ z3/jsonserver/branch/merge/concatresource/interfaces.py Mon Apr 3 15:59:35 2006
@@ -22,3 +22,20 @@
def purgeData(self):
'Purges the cached data'
+
+class IConcatResourceAddon(Interface):
+ '''Utility to register addons
+
+ This can be used to dynamically extend components for a given resource.
+ We don't provide implementation for this here, but other
+ components can implement this to provide dynamic add-ons.
+
+ The name of the utility should be the name of the resource.
+ '''
+
+ def getAddonFiles(request):
+ '''Returns a list of addon files.
+ This will be concatenated to the end of the static list.
+ '''
+
+
From jinty at codespeak.net Wed Apr 5 14:48:34 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Wed Apr 5 14:48:36 2006
Subject: [z3-checkins] r25377 - z3/sqlos/trunk
Message-ID: <20060405124834.C3851101DB@code0.codespeak.net>
Author: jinty
Date: Wed Apr 5 14:48:32 2006
New Revision: 25377
Added:
z3/sqlos/trunk/sampleapp.py (contents, props changed)
Modified:
z3/sqlos/trunk/makefile
Log:
Add a sampleapp script that allows people to run the functional testing suite as a sample application. Not quite thoroughly tested yet...
Modified: z3/sqlos/trunk/makefile
==============================================================================
--- z3/sqlos/trunk/makefile (original)
+++ z3/sqlos/trunk/makefile Wed Apr 5 14:48:32 2006
@@ -4,6 +4,7 @@
ZH=${HERE}/../../
PYTHON=python2.4
z3includes=Zope3/zopeskel/etc/package-includes
+Z3BRANCH=trunk
all : test clean
@@ -36,7 +37,7 @@
.PHONY: z3-checkout
z3-checkout:
- -test -d Zope3 || svn co svn://svn.zope.org/repos/main/Zope3/trunk Zope3
+ -test -d Zope3 || svn co svn://svn.zope.org/repos/main/Zope3/$(Z3BRANCH) Zope3
.PHONY: z3-update
z3-update: z3-checkout
@@ -51,9 +52,12 @@
.PHONY: sqlos-meta
sqlos-meta: $(z3includes)/sqlos-meta.zcml $(z3includes)/sqlos-configure.zcml $(z3includes)/sqlos-ftesting.zcml
-.PHONY: develop
-develop: Zope3 sqlos-meta
+.PHONY: Zope3-build
+Zope3-build: Zope3
cd Zope3 && $(MAKE) PYTHON=$(PYTHON) inplace
+
+.PHONY: develop
+develop: Zope3-build sqlos-meta
touch Zope3/src/easy-install.pth
PYTHONPATH=Zope3/src $(PYTHON) setup.py develop -S Zope3/src --install-dir Zope3/src
@@ -68,3 +72,11 @@
.PHONY: testall
test: develop patch
cd Zope3 && $(PYTHON) test.py --test-path=../src -s sqlos
+
+Zope3/principals.zcml: Zope3 Zope3/sample_principals.zcml
+ cp Zope3/sample_principals.zcml $@
+
+.PHONY: run-sample
+run-sample: develop Zope3/principals.zcml
+ cp includes/sqlos-ftesting.zcml $(z3includes)/sqlos.testing-configure.zcml
+ sampleapp.py ; rm $(z3includes)/sqlos.testing-configure.zcml
Added: z3/sqlos/trunk/sampleapp.py
==============================================================================
--- (empty file)
+++ z3/sqlos/trunk/sampleapp.py Wed Apr 5 14:48:32 2006
@@ -0,0 +1,79 @@
+#!/usr/bin/env python2.4
+##############################################################################
+#
+# Copyright (c) 2001, 2002 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.
+#
+##############################################################################
+"""Start script for Zope3: loads configuration and starts the server.
+
+$Id: z3.py 40235 2005-11-18 21:30:31Z srichter $
+"""
+import os
+import sys
+
+basepath = filter(None, sys.path)
+
+def run(argv=list(sys.argv)):
+
+ if sys.version_info < ( 2,3,5 ):
+ print """\
+ ERROR: Your python version is not supported by Zope3.
+ Zope3 needs Python 2.3.5 or greater. You are running:""" + sys.version
+ sys.exit(1)
+
+ # Refuse to run without principals.zcml
+ if not os.path.exists('principals.zcml'):
+ print """\
+ ERROR: You need to create principals.zcml
+
+ The file principals.zcml contains your "bootstrap" user
+ database. You aren't going to get very far without it. Start
+ by copying sample_principals.zcml and then modify the
+ example principal and role settings.
+ """
+ sys.exit(1)
+
+ # setting python paths
+ program = argv[0]
+ if "--build" in argv:
+ argv.remove("--build")
+ from distutils.util import get_platform
+ PLAT_SPEC = "%s-%s" % (get_platform(), sys.version[0:3])
+ src = os.path.join("build", "lib.%s" % PLAT_SPEC)
+ else:
+ src = 'src'
+
+ here = os.path.dirname(os.path.abspath(program))
+ srcdir = os.path.abspath(src)
+ sys.path = [srcdir] + basepath
+ sys.path[:] = [p for p in sys.path if os.path.abspath(p) != here]
+
+ # Register the paths
+ import site
+ site.addsitedir(srcdir)
+
+ # setup a subscriber to create the sampleperson tables
+ def setupTestingTables(event):
+ from sqlos.testing import sampleperson
+ sampleperson.createTestingTables()
+
+ from zope.app.appsetup.interfaces import IDatabaseOpenedEvent
+ from zope.component import getGlobalSiteManager
+ gsm = getGlobalSiteManager()
+ gsm.subscribe([IDatabaseOpenedEvent], None, setupTestingTables)
+
+ from zope.app.twisted.main import main
+ main(argv[1:])
+
+
+if __name__ == '__main__':
+ os.chdir('Zope3')
+ run()
From jinty at codespeak.net Wed Apr 5 23:09:42 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Wed Apr 5 23:09:44 2006
Subject: [z3-checkins] r25418 - z3/sqlos/trunk/src/sqlos
Message-ID: <20060405210942.D4A8410238@code0.codespeak.net>
Author: jinty
Date: Wed Apr 5 23:09:40 2006
New Revision: 25418
Modified:
z3/sqlos/trunk/src/sqlos/configure.zcml
Log:
Remove the option to add a SQLObject container. It is really useless as it can contain nothing.
Modified: z3/sqlos/trunk/src/sqlos/configure.zcml
==============================================================================
--- z3/sqlos/trunk/src/sqlos/configure.zcml (original)
+++ z3/sqlos/trunk/src/sqlos/configure.zcml Wed Apr 5 23:09:40 2006
@@ -5,13 +5,6 @@
-
-
@@ -47,6 +40,8 @@
factory=".container.SQLObjectNameChooser"
/>
+
+
Author: jinty
Date: Wed Apr 5 23:26:55 2006
New Revision: 25420
Modified:
z3/sqlos/trunk/src/sqlos/container.py
z3/sqlos/trunk/src/sqlos/ftests/adding.txt
z3/sqlos/trunk/src/sqlos/testing/sampleperson.py
Log:
Proibit the sample people (almost like flower people) from being added to any container but a IPersonContainer. Also, unrelatedly, make an event subscriber that will create the testing tables.
Modified: z3/sqlos/trunk/src/sqlos/container.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/container.py (original)
+++ z3/sqlos/trunk/src/sqlos/container.py Wed Apr 5 23:26:55 2006
@@ -59,13 +59,14 @@
class SQLObjectNameChooser(NameChooser):
-
+ # XXX: This needs unit tests...
+
def chooseName(self, name, obj):
if ISQLObject.providedBy(obj):
# Look for the SQLObject class our object is from, so get all
# allowed factories
for name, factory in zapi.getFactoriesFor(ISQLObject):
- if checkFactory(self, None, factory):
+ if checkFactory(self.context, None, factory):
# get the sqlobject class
utility = zapi.queryUtility(IISQLObject, name)
if utility is None:
Modified: z3/sqlos/trunk/src/sqlos/ftests/adding.txt
==============================================================================
--- z3/sqlos/trunk/src/sqlos/ftests/adding.txt (original)
+++ z3/sqlos/trunk/src/sqlos/ftests/adding.txt Wed Apr 5 23:26:55 2006
@@ -19,6 +19,8 @@
Go to the main interface and add a SQLObject MultiContainer
>>> browser.open('http://localhost/manage')
+ >>> 'SamplePerson' not in str(browser.contents)
+ True
>>> browser.getLink('SQLObject Multi Container').click()
>>> browser.getControl(name='new_value').value = 'multicontainer1'
>>> browser.getControl('Apply').click()
Modified: z3/sqlos/trunk/src/sqlos/testing/sampleperson.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/testing/sampleperson.py (original)
+++ z3/sqlos/trunk/src/sqlos/testing/sampleperson.py Wed Apr 5 23:26:55 2006
@@ -1,6 +1,6 @@
from sqlobject import *
import transaction
-from zope.interface import implements, classProvides
+from zope.interface import implements, classProvides, Interface
from zope.schema import TextLine, Text, Datetime
from zope.app.container import constraints
@@ -9,6 +9,10 @@
from sqlos.interfaces.container import ISQLObjectContainer
from sqlos.container import SQLObjectContainer, SQLIsolatedContainer
+def createTestingTablesSubscriber(obj):
+ # An event subscriber that can be used to create the testing tables
+ createTestingTables()
+
def createTestingTables():
"""Creates the tables of the SQLObject calsses defined here."""
transaction.get().commit()
@@ -36,18 +40,14 @@
description=u"The user's password")
-class SamplePerson(SQLOS):
-
- implements(IPerson)
+class IPersonContainer(ISQLObjectContainer):
- fullname = StringCol(length=50, notNull=1)
- username = StringCol(length=20, notNull=1)
- password = StringCol(length=20, notNull=1)
+ constraints.contains(IPerson)
-class IPersonContainer(ISQLObjectContainer):
+class IPersonContained(Interface):
- constraints.contains(IPerson)
+ constraints.containers(IPersonContainer)
class SamplePersonContainer(SQLObjectContainer):
@@ -55,6 +55,15 @@
implements(IPersonContainer)
+class SamplePerson(SQLOS):
+
+ implements(IPerson, IPersonContained)
+
+ fullname = StringCol(length=50, notNull=1)
+ username = StringCol(length=20, notNull=1)
+ password = StringCol(length=20, notNull=1)
+
+
class SampleIsolatedPerson(SQLOS):
classProvides(IISQLObjectIsolated)
@@ -119,7 +128,7 @@
owner = StringCol(length=20, notNull=1)
-class IMultiContainer(ISQLObjectContainer):
+class IMultiContainer(IPersonContainer):
constraints.contains(IDog, IPerson)
From jinty at codespeak.net Wed Apr 5 23:28:49 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Wed Apr 5 23:28:50 2006
Subject: [z3-checkins] r25422 - in z3/sqlos/trunk: . includes src/sqlos
Message-ID: <20060405212849.0F21D10238@code0.codespeak.net>
Author: jinty
Date: Wed Apr 5 23:28:44 2006
New Revision: 25422
Added:
z3/sqlos/trunk/includes/sqlos.ftesting-configure.zcml
- copied, changed from r25354, z3/sqlos/trunk/includes/sqlos-ftesting.zcml
z3/sqlos/trunk/src/sqlos/sampleapp.zcml (contents, props changed)
Removed:
z3/sqlos/trunk/patch-test.py
z3/sqlos/trunk/sampleapp.py
Modified:
z3/sqlos/trunk/makefile
z3/sqlos/trunk/src/sqlos/README.txt
Log:
Re-do the sample application in a better way and actually document it.
Copied: z3/sqlos/trunk/includes/sqlos.ftesting-configure.zcml (from r25354, z3/sqlos/trunk/includes/sqlos-ftesting.zcml)
==============================================================================
--- z3/sqlos/trunk/includes/sqlos-ftesting.zcml (original)
+++ z3/sqlos/trunk/includes/sqlos.ftesting-configure.zcml Wed Apr 5 23:28:44 2006
@@ -1 +1 @@
-
+
Modified: z3/sqlos/trunk/makefile
==============================================================================
--- z3/sqlos/trunk/makefile (original)
+++ z3/sqlos/trunk/makefile Wed Apr 5 23:28:44 2006
@@ -30,11 +30,6 @@
rm -rf build
rm -rf Zope3
-reindent :
- ~/src/reindent.py -r -v .
-
-reindent_clean : reindent clean
-
.PHONY: z3-checkout
z3-checkout:
-test -d Zope3 || svn co svn://svn.zope.org/repos/main/Zope3/$(Z3BRANCH) Zope3
@@ -46,7 +41,7 @@
Zope3:
$(MAKE) z3-checkout
-$(z3includes)/sqlos-%.zcml: includes/sqlos-%.zcml Zope3
+$(z3includes)/%.zcml: includes/%.zcml Zope3
cp $< $@
.PHONY: sqlos-meta
@@ -61,22 +56,13 @@
touch Zope3/src/easy-install.pth
PYTHONPATH=Zope3/src $(PYTHON) setup.py develop -S Zope3/src --install-dir Zope3/src
-.PHONY: patch
-patch:
- # This is butttt ugly pul hopefully temporary
- set - e;\
- if [ `grep 'site.addsitedir(src)' Zope3/test.py -c` == 0 ]; then\
- cat patch-test.py | patch -p0;\
- fi
-
.PHONY: testall
-test: develop patch
+test: develop
cd Zope3 && $(PYTHON) test.py --test-path=../src -s sqlos
Zope3/principals.zcml: Zope3 Zope3/sample_principals.zcml
cp Zope3/sample_principals.zcml $@
-.PHONY: run-sample
-run-sample: develop Zope3/principals.zcml
- cp includes/sqlos-ftesting.zcml $(z3includes)/sqlos.testing-configure.zcml
- sampleapp.py ; rm $(z3includes)/sqlos.testing-configure.zcml
+.PHONY: run-sampleapp
+run-sampleapp: develop Zope3/principals.zcml $(z3includes)/sqlos.ftesting-configure.zcml
+ cd Zope3; ./z3.py
Deleted: /z3/sqlos/trunk/patch-test.py
==============================================================================
--- /z3/sqlos/trunk/patch-test.py Wed Apr 5 23:28:44 2006
+++ (empty file)
@@ -1,13 +0,0 @@
-Index: Zope3/test.py
-===================================================================
---- Zope3/test.py (revision 65897)
-+++ Zope3/test.py (working copy)
-@@ -26,6 +26,8 @@
- # add src to path
- src = os.path.join(here, 'src')
- sys.path.insert(0, src) # put at beginning to avoid one in site_packages
-+import site
-+site.addsitedir(src)
-
- from zope.testing import testrunner
-
Deleted: /z3/sqlos/trunk/sampleapp.py
==============================================================================
--- /z3/sqlos/trunk/sampleapp.py Wed Apr 5 23:28:44 2006
+++ (empty file)
@@ -1,79 +0,0 @@
-#!/usr/bin/env python2.4
-##############################################################################
-#
-# Copyright (c) 2001, 2002 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.
-#
-##############################################################################
-"""Start script for Zope3: loads configuration and starts the server.
-
-$Id: z3.py 40235 2005-11-18 21:30:31Z srichter $
-"""
-import os
-import sys
-
-basepath = filter(None, sys.path)
-
-def run(argv=list(sys.argv)):
-
- if sys.version_info < ( 2,3,5 ):
- print """\
- ERROR: Your python version is not supported by Zope3.
- Zope3 needs Python 2.3.5 or greater. You are running:""" + sys.version
- sys.exit(1)
-
- # Refuse to run without principals.zcml
- if not os.path.exists('principals.zcml'):
- print """\
- ERROR: You need to create principals.zcml
-
- The file principals.zcml contains your "bootstrap" user
- database. You aren't going to get very far without it. Start
- by copying sample_principals.zcml and then modify the
- example principal and role settings.
- """
- sys.exit(1)
-
- # setting python paths
- program = argv[0]
- if "--build" in argv:
- argv.remove("--build")
- from distutils.util import get_platform
- PLAT_SPEC = "%s-%s" % (get_platform(), sys.version[0:3])
- src = os.path.join("build", "lib.%s" % PLAT_SPEC)
- else:
- src = 'src'
-
- here = os.path.dirname(os.path.abspath(program))
- srcdir = os.path.abspath(src)
- sys.path = [srcdir] + basepath
- sys.path[:] = [p for p in sys.path if os.path.abspath(p) != here]
-
- # Register the paths
- import site
- site.addsitedir(srcdir)
-
- # setup a subscriber to create the sampleperson tables
- def setupTestingTables(event):
- from sqlos.testing import sampleperson
- sampleperson.createTestingTables()
-
- from zope.app.appsetup.interfaces import IDatabaseOpenedEvent
- from zope.component import getGlobalSiteManager
- gsm = getGlobalSiteManager()
- gsm.subscribe([IDatabaseOpenedEvent], None, setupTestingTables)
-
- from zope.app.twisted.main import main
- main(argv[1:])
-
-
-if __name__ == '__main__':
- os.chdir('Zope3')
- run()
Modified: z3/sqlos/trunk/src/sqlos/README.txt
==============================================================================
--- z3/sqlos/trunk/src/sqlos/README.txt (original)
+++ z3/sqlos/trunk/src/sqlos/README.txt Wed Apr 5 23:28:44 2006
@@ -48,6 +48,8 @@
Dependencies
------------
+ + setuptools >= 0.6a11
+
+ SQLObject >= 0.7
Place the sqlobject package somewhere in python's sys.path
@@ -107,6 +109,32 @@
connection and any registered class you wish.
+A Sample Application
+--------------------
+
+The functional test setup for sqlos is really a sample application. You can
+run and play with this to see how sqlos works.
+
+First install a Z3 database adapter, create a database, edit
+src/sqlos/ftesting.zcml to change the connection settings as
+described below in "Setting up a connection for SQLObject".
+
+NOTE: This currently does not work with the default testing database
+ (memory based SQLite) due to threading issues.
+
+Then, from a checkout of sqlos run:
+
+ $ make run-sampleapp
+
+This should download Zope3 install sqlos and set up the functional
+test suite as a sample application. You can then log into zope3 on
+http://localhost:8080 with gandalf:123.
+
+Try adding a "SQLObject MultiContainer" and then some people.
+
+NOTE: changing debug=1 in src/sqlos/adapter.py will cause the SQL
+ executed to be printed on the terminal
+
Setting up a connection for SQLObject
-------------------------------------
Added: z3/sqlos/trunk/src/sqlos/sampleapp.zcml
==============================================================================
--- (empty file)
+++ z3/sqlos/trunk/src/sqlos/sampleapp.zcml Wed Apr 5 23:28:44 2006
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
From jinty at codespeak.net Thu Apr 6 12:04:09 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 6 12:04:10 2006
Subject: [z3-checkins] r25435 - z3/sqlos/trunk/Zope2/FiveSQLOS
Message-ID: <20060406100409.22ADE10223@code0.codespeak.net>
Author: jinty
Date: Thu Apr 6 12:04:07 2006
New Revision: 25435
Modified:
z3/sqlos/trunk/Zope2/FiveSQLOS/wrapper.py
Log:
Fix an important bug that was uncovered by the changes to the testing harness in sqlos.
Modified: z3/sqlos/trunk/Zope2/FiveSQLOS/wrapper.py
==============================================================================
--- z3/sqlos/trunk/Zope2/FiveSQLOS/wrapper.py (original)
+++ z3/sqlos/trunk/Zope2/FiveSQLOS/wrapper.py Thu Apr 6 12:04:07 2006
@@ -25,6 +25,7 @@
from zope.app.container.constraints import checkFactory
from zope.interface import implements, providedBy, directlyProvides
from sqlos.interfaces import ISQLObject, IISQLObject
+from zope.app.exception.interfaces import UserError
from Products.FiveSQLOS.interfaces import IFiveSQLObject
@@ -80,10 +81,12 @@
# Look for the SQLObject class our object is from, so get all
# allowed factories
for name, factory in zapi.getFactoriesFor(ISQLObject):
- if checkFactory(self, None, factory):
+ if checkFactory(self.aq_parent, None, factory):
# get the sqlobject class
- factory = zapi.getUtility(IISQLObject, name)
- if obj.sqlmeta.table == factory.sqlmeta.table:
+ utility = zapi.queryUtility(IISQLObject, name)
+ if utility is None:
+ continue
+ if obj.sqlmeta.table == utility.sqlmeta.table:
# if the tables names are the same, we assume that the
# sqlobject is an instance of that class, perhaps that
# is wrong
From jinty at codespeak.net Thu Apr 6 21:38:45 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 6 21:38:46 2006
Subject: [z3-checkins] r25463 - in z3/sqlos/trunk: doc/examples src/sqlos
Message-ID: <20060406193845.46DA71024C@code0.codespeak.net>
Author: jinty
Date: Thu Apr 6 21:38:38 2006
New Revision: 25463
Removed:
z3/sqlos/trunk/doc/examples/
Modified:
z3/sqlos/trunk/src/sqlos/README.txt
Log:
Rip out the example because it broke and was frustrating first time users. Being untested it is just too much maintainence to fix. Anyway, now we use our functional test setup as an example application and, well, that is tested.
Modified: z3/sqlos/trunk/src/sqlos/README.txt
==============================================================================
--- z3/sqlos/trunk/src/sqlos/README.txt (original)
+++ z3/sqlos/trunk/src/sqlos/README.txt Thu Apr 6 21:38:38 2006
@@ -138,9 +138,6 @@
Setting up a connection for SQLObject
-------------------------------------
-NOTE: There is a fully worked out example package in the
- doc/examples/sqlos_sample directory.
-
This example is not complete yet (XXX), but should give you an idea::
Author: jinty
Date: Fri Apr 7 02:01:23 2006
New Revision: 25467
Modified:
z3/sqlos/trunk/src/sqlos/__init__.py
z3/sqlos/trunk/src/sqlos/interfaces/__init__.py
Log:
Move some strange, untested and probably un-necessary class implements closer to where the interfaces are defined.
Modified: z3/sqlos/trunk/src/sqlos/__init__.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/__init__.py (original)
+++ z3/sqlos/trunk/src/sqlos/__init__.py Fri Apr 7 02:01:23 2006
@@ -13,27 +13,8 @@
__metaclass__ = type
from datetime import datetime, date
-from zope.interface import classImplements
from zope.app import zapi
-from zope.security.checker import NamesChecker, NoProxy, defineChecker
-
-from sqlobject.dbconnection import DBConnection, DBAPI
-from sqlobject import _mysql, _postgres, _sybase
-from sqlobject.main import SQLObject, SelectResults
-from sqlobject.sqlbuilder import registerConverter, \
- SQLObjectTable
-from sqlos.interfaces import IDBConnection, IDBAPI, ISQLConnection
-from sqlos.interfaces import IISQLObject, ISQLObject, ISelectResults
-
-defineChecker(SQLObjectTable, NoProxy)
-
-classImplements(DBConnection, IDBConnection)
-classImplements(DBAPI, IDBAPI)
-classImplements(_mysql.builder(), ISQLConnection)
-classImplements(_postgres.builder(), ISQLConnection)
-classImplements(_sybase.builder(), ISQLConnection)
-classImplements(SQLObject, ISQLObject)
-classImplements(SelectResults, ISelectResults)
+from sqlobject.sqlbuilder import registerConverter
from _sqlos import SQLOS
Modified: z3/sqlos/trunk/src/sqlos/interfaces/__init__.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/interfaces/__init__.py (original)
+++ z3/sqlos/trunk/src/sqlos/interfaces/__init__.py Fri Apr 7 02:01:23 2006
@@ -11,11 +11,17 @@
"""
from zope.schema import TextLine
from zope.interface import Interface, Attribute
-from sqlobject import NoDefault
from zope.component import getService, ComponentLookupError
+from zope.interface import classImplements
+from zope.security.checker import NamesChecker, NoProxy, defineChecker
from zope.schema.vocabulary import SimpleVocabulary
from zope.schema import Choice, List
from zope.app.annotation.interfaces import IAttributeAnnotatable
+from sqlobject import NoDefault
+from sqlobject.dbconnection import DBConnection, DBAPI
+from sqlobject import _mysql, _postgres, _sybase
+from sqlobject.main import SQLObject, SelectResults
+from sqlobject.sqlbuilder import SQLObjectTable
class IConnectionName(Interface):
"""A marker interface for providing a connection name"""
@@ -248,7 +254,7 @@
class IISQLObjectIsolated(IISQLObject):
"""Support for using this class in isolated containers.
-
+
This interface is necessary to move the SQL query logic to the SQLOS class
as it can be implemented in various ways in the class.
"""
@@ -335,3 +341,17 @@
def next():
""" Iterator """
+
+# XXX: Why do we need these????
+
+defineChecker(SQLObjectTable, NoProxy)
+
+classImplements(DBConnection, IDBConnection)
+classImplements(DBAPI, IDBAPI)
+classImplements(_mysql.builder(), ISQLConnection)
+classImplements(_postgres.builder(), ISQLConnection)
+classImplements(_sybase.builder(), ISQLConnection)
+classImplements(SQLObject, ISQLObject)
+classImplements(SelectResults, ISelectResults)
+
+
From jinty at codespeak.net Fri Apr 7 02:03:50 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Fri Apr 7 02:03:58 2006
Subject: [z3-checkins] r25468 - z3/sqlos/trunk/src/sqlos
Message-ID: <20060407000350.2629910249@code0.codespeak.net>
Author: jinty
Date: Fri Apr 7 02:03:40 2006
New Revision: 25468
Modified:
z3/sqlos/trunk/src/sqlos/__init__.py
Log:
Deprecate the unused (in sqlos) sqlos.caller
Modified: z3/sqlos/trunk/src/sqlos/__init__.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/__init__.py (original)
+++ z3/sqlos/trunk/src/sqlos/__init__.py Fri Apr 7 02:03:40 2006
@@ -52,3 +52,4 @@
factory."
deprecated("getFactory", msg)
+deprecated("caller", "sqlos.caller is deprecated and will be removed after sqlos 0.2")
From jinty at codespeak.net Fri Apr 7 02:17:11 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Fri Apr 7 02:17:13 2006
Subject: [z3-checkins] r25469 - in z3/sqlos/trunk/src/sqlos: . auth ftests
Message-ID: <20060407001711.8666010251@code0.codespeak.net>
Author: jinty
Date: Fri Apr 7 02:17:08 2006
New Revision: 25469
Modified:
z3/sqlos/trunk/src/sqlos/__init__.py
z3/sqlos/trunk/src/sqlos/auth/__init__.py
z3/sqlos/trunk/src/sqlos/connection.py
z3/sqlos/trunk/src/sqlos/container.py
z3/sqlos/trunk/src/sqlos/ftests/test_transaction.py
Log:
Remove users of zapi.
Modified: z3/sqlos/trunk/src/sqlos/__init__.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/__init__.py (original)
+++ z3/sqlos/trunk/src/sqlos/__init__.py Fri Apr 7 02:17:08 2006
@@ -13,7 +13,7 @@
__metaclass__ = type
from datetime import datetime, date
-from zope.app import zapi
+import zope.component
from sqlobject.sqlbuilder import registerConverter
from _sqlos import SQLOS
@@ -41,14 +41,14 @@
def getFactory(name, context=None, default=None):
# XXX - deprecated, goes away after sqlos 0.2
- return zapi.queryUtility(IISQLObject, name, default=default, context=context)
+ return zope.component.queryUtility(IISQLObject, name, default=default, context=context)
from zope.deprecation import deprecated
msg = "getFactory is depreciated and will go away after sqlos 0.2 you should \
replace this with a direct call to \
-zapi.getUtility(IISQLObject, name, context=context) if you need the \
+zope.component.getUtility(IISQLObject, name, context=context) if you need the \
functionailty of a SQLObject class, or \
-zapi.getUtility(IFactory, name, context=context) if you want to use it as a \
+zope.component.getUtility(IFactory, name, context=context) if you want to use it as a \
factory."
deprecated("getFactory", msg)
Modified: z3/sqlos/trunk/src/sqlos/auth/__init__.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/auth/__init__.py (original)
+++ z3/sqlos/trunk/src/sqlos/auth/__init__.py Fri Apr 7 02:17:08 2006
@@ -13,7 +13,7 @@
from zope.interface import implements
-from zope.app import zapi
+import zope.component
from zope.app.pluggableauth.interfaces import ILoginPasswordPrincipalSource
from zope.app.pluggableauth import SimplePrincipal
Modified: z3/sqlos/trunk/src/sqlos/connection.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/connection.py (original)
+++ z3/sqlos/trunk/src/sqlos/connection.py Fri Apr 7 02:17:08 2006
@@ -15,7 +15,7 @@
import warnings
from zope.component import ComponentLookupError
-from zope.app import zapi
+import zope.component
from zope.app.rdb.interfaces import IZopeDatabaseAdapter
from zope.thread import local
@@ -79,7 +79,7 @@
name = self.name
if name is None:
try:
- ut = zapi.getUtility(IConnectionName)
+ ut = zope.component.getUtility(IConnectionName)
except ComponentLookupError:
return self
if ut is None:
@@ -91,7 +91,7 @@
# try get the connection from the cache, or make a new one
conn = conn_cache.queryConnection(name)
if conn is None:
- zda = zapi.getUtility(IZopeDatabaseAdapter, name)
+ zda = zope.component.getUtility(IZopeDatabaseAdapter, name)
try:
conn = IZopeSQLConnection(zda())
except ComponentLookupError:
Modified: z3/sqlos/trunk/src/sqlos/container.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/container.py (original)
+++ z3/sqlos/trunk/src/sqlos/container.py Fri Apr 7 02:17:08 2006
@@ -18,7 +18,7 @@
from zope.interface import implements
from zope.component import IFactory
from zope import deprecation
-from zope.app import zapi
+import zope.component
from zope.app.container.interfaces import IContained
from zope.app.container.contained import ContainedProxy
from zope.app.container.contained import Contained
@@ -65,10 +65,10 @@
if ISQLObject.providedBy(obj):
# Look for the SQLObject class our object is from, so get all
# allowed factories
- for name, factory in zapi.getFactoriesFor(ISQLObject):
+ for name, factory in zope.component.getFactoriesFor(ISQLObject):
if checkFactory(self.context, None, factory):
# get the sqlobject class
- utility = zapi.queryUtility(IISQLObject, name)
+ utility = zope.component.queryUtility(IISQLObject, name)
if utility is None:
continue
if obj.sqlmeta.table == utility.sqlmeta.table:
@@ -87,7 +87,7 @@
pass
def _allowedFactories(self):
- for name, factory in zapi.getFactoriesFor(ISQLObject):
+ for name, factory in zope.component.getFactoriesFor(ISQLObject):
if checkFactory(self, None, factory):
yield name
allowedFactories = deprecation.deprecated(_allowedFactories,
@@ -95,9 +95,9 @@
' please use _getAllowedIISQLObjectUtilities instead.')
def _getAllowedIISQLObjectUtilities(self):
- for name, factory in zapi.getFactoriesFor(ISQLObject):
+ for name, factory in zope.component.getFactoriesFor(ISQLObject):
if checkFactory(self, None, factory):
- utility = zapi.queryUtility(IISQLObject, name)
+ utility = zope.component.queryUtility(IISQLObject, name)
# Someone might have registered a factory implementing
# IISQLObject using for whatever reason.
# in this case queryUtility returns None and we can just
@@ -212,7 +212,7 @@
def allowedFactories(self):
# Ignore all factories not implementing ISQLObjectIsolated
for f in SQLObjectContainer._allowedFactories(self):
- implemented = zapi.getFactoryInterfaces(f)
+ implemented = zope.component.getFactoryInterfaces(f)
if implemented.isOrExtends(ISQLObjectIsolated):
yield f
allowedFactories = deprecation.deprecated(allowedFactories,
Modified: z3/sqlos/trunk/src/sqlos/ftests/test_transaction.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/ftests/test_transaction.py (original)
+++ z3/sqlos/trunk/src/sqlos/ftests/test_transaction.py Fri Apr 7 02:17:08 2006
@@ -16,7 +16,7 @@
from transaction import get, begin
from zope.app.testing.functional import BrowserTestCase
-from zope.app import zapi
+import zope.component
from zope.app.rdb.interfaces import IZopeDatabaseAdapter
from sqlos.interfaces import IConnectionName
@@ -98,8 +98,8 @@
This is a regression test for if the cache makes breaks the isolation
between threads.
"""
- ut = zapi.getUtility(IConnectionName)
- adapter = zapi.queryUtility(IZopeDatabaseAdapter, ut.name)
+ ut = zope.component.getUtility(IConnectionName)
+ adapter = zope.component.queryUtility(IZopeDatabaseAdapter, ut.name)
if adapter.getDSN() == 'dbi://:memory:':
import warnings
warnings.warn('Warning, not testing Cache Isolation')
@@ -130,8 +130,8 @@
happen even if the thread is not the main thread. (Just in case some
dodo only registers the cache clearer in the main thread.)
"""
- ut = zapi.getUtility(IConnectionName)
- adapter = zapi.queryUtility(IZopeDatabaseAdapter, ut.name)
+ ut = zope.component.getUtility(IConnectionName)
+ adapter = zope.component.queryUtility(IZopeDatabaseAdapter, ut.name)
if adapter.getDSN() == 'dbi://:memory:':
import warnings
warnings.warn('Warning, not testing Cache Isolation')
From reebalazs at codespeak.net Sun Apr 9 21:37:11 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Sun Apr 9 21:37:11 2006
Subject: [z3-checkins] r25638 - z3/jsonserver/branch/zope2_test
Message-ID: <20060409193711.0F0F310169@code0.codespeak.net>
Author: reebalazs
Date: Sun Apr 9 21:37:09 2006
New Revision: 25638
Modified:
z3/jsonserver/branch/zope2_test/configure.zcml
Log:
include browser package was missing
Modified: z3/jsonserver/branch/zope2_test/configure.zcml
==============================================================================
--- z3/jsonserver/branch/zope2_test/configure.zcml (original)
+++ z3/jsonserver/branch/zope2_test/configure.zcml Sun Apr 9 21:37:09 2006
@@ -8,6 +8,7 @@
+
-
-
-
-
From regebro at codespeak.net Tue Apr 11 20:25:57 2006
From: regebro at codespeak.net (regebro@codespeak.net)
Date: Tue Apr 11 20:25:58 2006
Subject: [z3-checkins] r25706 - z3/CMFonFive/trunk
Message-ID: <20060411182557.9581510177@code0.codespeak.net>
Author: regebro
Date: Tue Apr 11 20:25:57 2006
New Revision: 25706
Modified:
z3/CMFonFive/trunk/CHANGES.txt
z3/CMFonFive/trunk/fiveactionstool.py
z3/CMFonFive/trunk/version.txt
Log:
The generated id of the icons is now consistent.
Modified: z3/CMFonFive/trunk/CHANGES.txt
==============================================================================
--- z3/CMFonFive/trunk/CHANGES.txt (original)
+++ z3/CMFonFive/trunk/CHANGES.txt Tue Apr 11 20:25:57 2006
@@ -1,7 +1,17 @@
CMFonFive Product Changelog
+ CMFonFive 1.3.3 (2005-04-11)
+
+ - The id of the action is now generated from the last part of the interface
+ the menu item is defined for, and the last part of the action. This should
+ generate enough uniqueness so that action id's does not clash too much, while
+ never generating two different ids.
+
+ The reason for this change is that it enables you to add icons with the CMF
+ ActionIconsTool.
+
CMFonFive 1.3.2 (2005-02-22)
-
+
- GenericSetup calls all action providers with both object and info
as None, which resulted in an attribute error.
Modified: z3/CMFonFive/trunk/fiveactionstool.py
==============================================================================
--- z3/CMFonFive/trunk/fiveactionstool.py (original)
+++ z3/CMFonFive/trunk/fiveactionstool.py Tue Apr 11 20:25:57 2006
@@ -21,13 +21,52 @@
from Products.CMFCore.Expression import Expression
from Products.CMFCore.utils import UniqueObject
+from zope.interface import providedBy
from zope.app import zapi
from zope.app.publisher.interfaces.browser import IBrowserMenu
-from zope.app.publisher.browser.menu import getMenu
-
+from zope.app.publisher.interfaces.browser import IBrowserSubMenuItem
+from zope.security.proxy import removeSecurityProxy
+
def _listMenuIds():
return [id for id, utility in zapi.getUtilitiesFor(IBrowserMenu)]
+def getMenu(id, object, request):
+ """Return menu item entries in a TAL-friendly form."""
+ menu = zapi.getUtility(IBrowserMenu, id)
+
+ result = []
+ for name, item in zapi.getAdapters((object, request),
+ menu.getMenuItemType()):
+ if item.available():
+ result.append(item)
+
+ # Now order the result. This is not as easy as it seems.
+ #
+ # (1) Look at the interfaces and put the more specific menu entries
+ # to the front.
+ # (2) Sort unabigious entries by order and then by title.
+ ifaces = list(providedBy(removeSecurityProxy(object)).__iro__)
+ result = [(ifaces.index(item._for or Interface),
+ item.order, item.title, item) for item in result]
+ result.sort()
+
+ res = []
+ for index, order, title, item in result:
+ identifier = '%s_%s' % (item._for.__identifier__.split('.')[-1],
+ item.action.split('/')[-1])
+ identifier = identifier.replace(' ', '_').lower()
+ res.append({'title': item.title,
+ 'description': item.description,
+ 'action': item.action,
+ 'selected': (item.selected() and u'selected') or u'',
+ 'icon': item.icon,
+ 'extra': item.extra,
+ 'submenu': (IBrowserSubMenuItem.providedBy(item) and
+ getMenu(item.submenuId, object, request)) or None,
+ 'identifier': identifier,
+ })
+ return res
+
from Products.Five import security
import zope.thread
@@ -61,10 +100,8 @@
# from the object_id and the action url. That is sure
# to be unique.
action = str(entry['action'])
- if object is None:
- act_id = 'action_%s' % action
- else:
- act_id = 'action_%s_%s' % (object.getId(), action)
+ meta_type = getattr(object, 'meta_type', '')
+ act_id = entry['identifier']
if entry.get('filter') is None:
filter = None
Modified: z3/CMFonFive/trunk/version.txt
==============================================================================
--- z3/CMFonFive/trunk/version.txt (original)
+++ z3/CMFonFive/trunk/version.txt Tue Apr 11 20:25:57 2006
@@ -1 +1 @@
-CMFonFive-1.3.2
+CMFonFive-1.3.3
From regebro at codespeak.net Wed Apr 12 12:01:34 2006
From: regebro at codespeak.net (regebro@codespeak.net)
Date: Wed Apr 12 12:01:35 2006
Subject: [z3-checkins] r25714 - z3/CMFonFive/trunk
Message-ID: <20060412100134.7A74910149@code0.codespeak.net>
Author: regebro
Date: Wed Apr 12 12:01:34 2006
New Revision: 25714
Modified:
z3/CMFonFive/trunk/CHANGES.txt
z3/CMFonFive/trunk/version.txt
Log:
Decided not to release it now, but before CPS 3.4.1 (or if somebody asks me too).
Modified: z3/CMFonFive/trunk/CHANGES.txt
==============================================================================
--- z3/CMFonFive/trunk/CHANGES.txt (original)
+++ z3/CMFonFive/trunk/CHANGES.txt Wed Apr 12 12:01:34 2006
@@ -1,6 +1,6 @@
CMFonFive Product Changelog
- CMFonFive 1.3.3 (2005-04-11)
+ CMFonFive 1.3.3 (unreleased)
- The id of the action is now generated from the last part of the interface
the menu item is defined for, and the last part of the action. This should
Modified: z3/CMFonFive/trunk/version.txt
==============================================================================
--- z3/CMFonFive/trunk/version.txt (original)
+++ z3/CMFonFive/trunk/version.txt Wed Apr 12 12:01:34 2006
@@ -1 +1 @@
-CMFonFive-1.3.3
+CMFonFive-1.3.2+
From jinty at codespeak.net Thu Apr 13 00:15:54 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 00:15:56 2006
Subject: [z3-checkins] r25747 - z3/sqlos/trunk/src/sqlos
Message-ID: <20060412221554.C8161101A9@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 00:15:53 2006
New Revision: 25747
Modified:
z3/sqlos/trunk/src/sqlos/README.txt
Log:
Be consistent
Modified: z3/sqlos/trunk/src/sqlos/README.txt
==============================================================================
--- z3/sqlos/trunk/src/sqlos/README.txt (original)
+++ z3/sqlos/trunk/src/sqlos/README.txt Thu Apr 13 00:15:53 2006
@@ -13,21 +13,21 @@
``sqlos`` is a toolkit for using SQLObject_ (an Object Relational
Mapper) inside Zope 3 or Zope 2. It tries to take care of many of the
fiddly details that always seem to take a lot of time. The major ways
-it helps are::
+it helps are:
- * Integrates the Zope transaction system and SQLObject, allowing
- SQLObject to be used in lazyUpdate mode.
+ + Integrates the Zope transaction system and SQLObject, allowing
+ SQLObject to be used in lazyUpdate mode.
+
+ + Uses Zope Database adapters in SQLObject.
- * Uses Zope Database adapters in SQLObject.
+ + Provide zcml configuration directives.
- * Provide zcml configuration directives.
+ + Provide ZODB persistent objects that can act as a "window" into
+ the database.
- * Provide ZODB persistent objects that can act as a "window" into
- the database.
+ + A testing infrastructure for testing SQLObject based applications.
- * A testing infrastructure for testing SQLObject based applications.
-
- * Caches SQLObjects and database connections to improve performance.
+ + Caches SQLObjects and database connections to improve performance.
.. _SQLObject: http://sqlobject.org
From jinty at codespeak.net Thu Apr 13 01:05:58 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 01:05:59 2006
Subject: [z3-checkins] r25751 - in z3/sqlos/trunk/src/sqlos: . auth
Message-ID: <20060412230558.84476101AF@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 01:05:56 2006
New Revision: 25751
Removed:
z3/sqlos/trunk/src/sqlos/annotations.py
z3/sqlos/trunk/src/sqlos/attributeannotations.py
z3/sqlos/trunk/src/sqlos/auth/
Modified:
z3/sqlos/trunk/src/sqlos/configure.zcml
Log:
Rip out sqlos.auth, sqlos.annotations and sqlos.attributeannotations as they were competely untested, prbably broken and nobody stepped up to do anything about it.
Deleted: /z3/sqlos/trunk/src/sqlos/annotations.py
==============================================================================
--- /z3/sqlos/trunk/src/sqlos/annotations.py Thu Apr 13 01:05:56 2006
+++ (empty file)
@@ -1,18 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Enfold Systems LLC. All rights reserved.
-#
-# This software is distributed under the terms of the Zope Public
-# License (ZPL) v2.1. See COPYING.txt for more information.
-#
-##############################################################################
-"""
-$Id: adapter.py 5212 2004-06-21 18:09:05Z philikon $
-"""
-from sqlobject import *
-
-class Annotations(SQLObject):
-
- location = StringCol('location', length=255, notNull=1)
- key = StringCol('key', length=255, notNull=1)
- value = StringCol('value', notNull=0)
Deleted: /z3/sqlos/trunk/src/sqlos/attributeannotations.py
==============================================================================
--- /z3/sqlos/trunk/src/sqlos/attributeannotations.py Thu Apr 13 01:05:56 2006
+++ (empty file)
@@ -1,135 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Enfold Systems LLC. All rights reserved.
-#
-# This software is distributed under the terms of the Zope Public
-# License (ZPL) v2.1. See COPYING.txt for more information.
-#
-##############################################################################
-"""
-$Id: adapter.py 5212 2004-06-21 18:09:05Z philikon $
-"""
-
-import pickle
-
-from sqlobject import *
-from zope.app.interfaces.annotation import IAnnotations
-from zope.app import zapi
-from zope.proxy import removeAllProxies
-from zope.interface import implements
-from zope.app.interfaces.location import ILocation
-from zope.app.location import Location
-
-from sqlos import getFactory
-
-
-class AnnotationProxy(object):
-
- def __init__(self, parent, key, context):
- self.__parent = parent
- self.__key = key
- self.__context = context
-
- def __getattr__(self, name):
- if name in ('_AnnotationProxy__parent',
- '_AnnotationProxy__key',
- '_AnnotationProxy__context'):
- return object.__getattribute__(self, name)
- return getattr(self.__context, name)
-
- def __setattr__(self, name, value):
- if name in ('_AnnotationProxy__parent',
- '_AnnotationProxy__key',
- '_AnnotationProxy__context'):
- object.__setattr__(self, name, value)
- else:
- setattr(self.__context, name, value)
- self.__parent[self.__key] = self.__context
-
- def __setitem__(self, name, value):
- if name in ('_AnnotationProxy__parent',
- '_AnnotationProxy__key',
- '_AnnotationProxy__context'):
- object.__setattr__(self, name, value)
- else:
- self.__context[name] = value
- self.__parent[self.__key] = self.__context
-
-
-class AnnotationSource(Location):
-
- def __init__(self, context):
- self.context = context
- self.location = "%s/%s" % (zapi.getName(zapi.getParent(context)),
- zapi.getName(context))
- self.__parent__ = context
- self.__name__ = '__annotations_source__'
- self.className = 'Annotations'
-
- def __getitem__(self, name):
- factory = getFactory(self.className)
- clause = "location = %r and key = %r" % (str(self.location),
- str(name))
- result = factory.select(clause = clause)
- if not len(result):
- raise KeyError, name
- return AnnotationProxy(self, name, pickle.loads(result[0].value))
-
- def get(self, name, default):
- try:
- item = self[name]
- except KeyError:
- return default
- return item
-
- def __setitem__(self, name, value):
- factory = getFactory(self.className)
- clause = "location = %r and key = %r" % (str(self.location),
- str(name))
- result = factory.select(clause = clause)
- if not len(result):
- item = factory.new(location=self.location,
- key=name,
- value=None)
- else:
- item = result[0]
-
- assert pickle.loads(pickle.dumps(value)) == value
- value = pickle.dumps(value)
- item.value = value
-
-
-class SQLAttributeAnnotations:
- """
- Store annotations in the annotations table, keyed by
- table_name/id on a IAttributeAnnotatable object.
- """
-
- implements(IAnnotations)
-
- def __init__(self, obj):
- self.wrapped_obj = obj
- self.unwrapped_obj = removeAllProxies(obj)
-
- def __getitem__(self, key):
- annotations = AnnotationSource(self.wrapped_obj)
- if annotations is None:
- raise KeyError, key
- return annotations[key]
-
- def __setitem__(self, key, value):
- if ILocation.providedBy(value):
- value.__parent__ = self.unwrapped_obj
-
- annotations = AnnotationSource(self.wrapped_obj)
- annotations[key] = value
-
- def get(self, key, default=None):
- annotations = AnnotationSource(self.wrapped_obj)
- return annotations.get(key, default)
-
- def __getattr__(self, name):
- # this method is for getting methods and attributes of the
- # mapping object used to store annotations.
- annotations = AnnotationSource(self.wrapped_obj)
- return getattr(annotations, name)
Modified: z3/sqlos/trunk/src/sqlos/configure.zcml
==============================================================================
--- z3/sqlos/trunk/src/sqlos/configure.zcml (original)
+++ z3/sqlos/trunk/src/sqlos/configure.zcml Thu Apr 13 01:05:56 2006
@@ -3,8 +3,6 @@
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="sqlos">
-
-
@@ -56,21 +54,6 @@
attribute="contents"
/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Author: jinty
Date: Thu Apr 13 01:27:53 2006
New Revision: 25753
Modified:
z3/sqlos/trunk/src/sqlos/README.txt
Log:
Steal the compatibilty matrix from Five
Modified: z3/sqlos/trunk/src/sqlos/README.txt
==============================================================================
--- z3/sqlos/trunk/src/sqlos/README.txt (original)
+++ z3/sqlos/trunk/src/sqlos/README.txt Thu Apr 13 01:27:53 2006
@@ -17,7 +17,7 @@
+ Integrates the Zope transaction system and SQLObject, allowing
SQLObject to be used in lazyUpdate mode.
-
+
+ Uses Zope Database adapters in SQLObject.
+ Provide zcml configuration directives.
@@ -42,6 +42,17 @@
but it can be used with Zope 2. Heavily leveraging the work by the Five
project, a Zope 2 product (FiveSQLOS) was created to enable this.
+The following table shows which sqlos version can and should be used
+with which Zope 2 and Zope 3 versions.
+
+============ ========
+. Zope 2.9
+------------ --------
+. Zope 3.2
+============ ========
+sqlos 0.2 X
+============ ========
+
.. _FiveSQLOS: http://codespeak.net/svn/z3/sqlos/trunk/Zope2/FiveSQLOS/
From jinty at codespeak.net Thu Apr 13 01:33:49 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 01:33:50 2006
Subject: [z3-checkins] r25754 - z3/www/trunk
Message-ID: <20060412233349.00FF5101B3@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 01:33:47 2006
New Revision: 25754
Modified:
z3/www/trunk/mkwebsite.py
Log:
Remove the Five 1.0.3 release which isnt in the zope.org repository.
Modified: z3/www/trunk/mkwebsite.py
==============================================================================
--- z3/www/trunk/mkwebsite.py (original)
+++ z3/www/trunk/mkwebsite.py Thu Apr 13 01:33:47 2006
@@ -152,8 +152,6 @@
site.registerReleases([
Z3ReleaseResource(
- 'Five', 'svn://svn.zope.org/repos/main/Products.Five/tags/1.0.3'),
- Z3ReleaseResource(
'Five', 'svn://svn.zope.org/repos/main/Products.Five/tags/1.1'),
Z3ReleaseResource(
'Five', 'svn://svn.zope.org/repos/main/Products.Five/tags/1.2.2'),
From jinty at codespeak.net Thu Apr 13 01:37:59 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 01:38:00 2006
Subject: [z3-checkins] r25755 - z3/sqlos/branch/0.2
Message-ID: <20060412233759.3FB25101B3@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 01:37:56 2006
New Revision: 25755
Added:
z3/sqlos/branch/0.2/
- copied from r25754, z3/sqlos/trunk/
Log:
Make a 0.2 maintainence branch.
From jinty at codespeak.net Thu Apr 13 01:42:01 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 01:42:02 2006
Subject: [z3-checkins] r25756 - z3/sqlos/branch/0.2
Message-ID: <20060412234201.44D5C101B3@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 01:41:59 2006
New Revision: 25756
Removed:
z3/sqlos/branch/0.2/setup.cfg
Modified:
z3/sqlos/branch/0.2/makefile
z3/sqlos/branch/0.2/setup.py
Log:
Mark 0.2 as a release.
Modified: z3/sqlos/branch/0.2/makefile
==============================================================================
--- z3/sqlos/branch/0.2/makefile (original)
+++ z3/sqlos/branch/0.2/makefile Thu Apr 13 01:41:59 2006
@@ -4,7 +4,7 @@
ZH=${HERE}/../../
PYTHON=python2.4
z3includes=Zope3/zopeskel/etc/package-includes
-Z3BRANCH=trunk
+Z3BRANCH=branches/0,2
all : test clean
Deleted: /z3/sqlos/branch/0.2/setup.cfg
==============================================================================
--- /z3/sqlos/branch/0.2/setup.cfg Thu Apr 13 01:41:59 2006
+++ (empty file)
@@ -1,2 +0,0 @@
-[egg-info]
-tag_svn_revision = 1
Modified: z3/sqlos/branch/0.2/setup.py
==============================================================================
--- z3/sqlos/branch/0.2/setup.py (original)
+++ z3/sqlos/branch/0.2/setup.py Thu Apr 13 01:41:59 2006
@@ -3,7 +3,7 @@
setup(
name="sqlos",
description="an integration package for Zope3 and SQLObject",
- version="0.1",
+ version="0.2",
license="ZPL",
package_dir={'':'src'},
packages=find_packages('src'),
From jinty at codespeak.net Thu Apr 13 01:50:27 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 01:50:28 2006
Subject: [z3-checkins] r25757 - z3/sqlos/trunk
Message-ID: <20060412235027.604D6101B3@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 01:50:24 2006
New Revision: 25757
Modified:
z3/sqlos/trunk/setup.py
Log:
Add some more metadata to the setup.py
Modified: z3/sqlos/trunk/setup.py
==============================================================================
--- z3/sqlos/trunk/setup.py (original)
+++ z3/sqlos/trunk/setup.py Thu Apr 13 01:50:24 2006
@@ -3,8 +3,17 @@
setup(
name="sqlos",
description="an integration package for Zope3 and SQLObject",
+ long_description="""
+sqlos is a toolkit for using SQLObject (an Object Relational
+Mapper) inside Zope 3 or Zope 2. It tries to take care of many of the
+fiddly details that always seem to take a lot of time.
+""",
+ url='http://codespeak.net/z3/sqlos/',
version="0.1",
license="ZPL",
+ maintainer="SQLOS development team",
+ maintainer_email="z3-sqlos@codespeak.net",
+ platforms=["any"],
package_dir={'':'src'},
packages=find_packages('src'),
zip_safe=False,
From jinty at codespeak.net Thu Apr 13 01:51:48 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 01:51:49 2006
Subject: [z3-checkins] r25758 - z3/sqlos/branch/0.2
Message-ID: <20060412235148.3D75B101B3@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 01:51:46 2006
New Revision: 25758
Modified:
z3/sqlos/branch/0.2/setup.py
Log:
Merge 25757 from trunk.
Modified: z3/sqlos/branch/0.2/setup.py
==============================================================================
--- z3/sqlos/branch/0.2/setup.py (original)
+++ z3/sqlos/branch/0.2/setup.py Thu Apr 13 01:51:46 2006
@@ -3,8 +3,17 @@
setup(
name="sqlos",
description="an integration package for Zope3 and SQLObject",
+ long_description="""
+sqlos is a toolkit for using SQLObject (an Object Relational
+Mapper) inside Zope 3 or Zope 2. It tries to take care of many of the
+fiddly details that always seem to take a lot of time.
+""",
+ url='http://codespeak.net/z3/sqlos/',
version="0.2",
license="ZPL",
+ maintainer="SQLOS development team",
+ maintainer_email="z3-sqlos@codespeak.net",
+ platforms=["any"],
package_dir={'':'src'},
packages=find_packages('src'),
zip_safe=False,
From jinty at codespeak.net Thu Apr 13 20:42:13 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 20:42:15 2006
Subject: [z3-checkins] r25812 - z3/sqlos/branch/0.2
Message-ID: <20060413184213.A6A1D1007D@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 20:42:11 2006
New Revision: 25812
Modified:
z3/sqlos/branch/0.2/makefile
z3/sqlos/branch/0.2/setup.py
Log:
Fix the version no and makefile.
Modified: z3/sqlos/branch/0.2/makefile
==============================================================================
--- z3/sqlos/branch/0.2/makefile (original)
+++ z3/sqlos/branch/0.2/makefile Thu Apr 13 20:42:11 2006
@@ -4,7 +4,7 @@
ZH=${HERE}/../../
PYTHON=python2.4
z3includes=Zope3/zopeskel/etc/package-includes
-Z3BRANCH=branches/0,2
+Z3BRANCH=branches/3.2
all : test clean
Modified: z3/sqlos/branch/0.2/setup.py
==============================================================================
--- z3/sqlos/branch/0.2/setup.py (original)
+++ z3/sqlos/branch/0.2/setup.py Thu Apr 13 20:42:11 2006
@@ -9,7 +9,7 @@
fiddly details that always seem to take a lot of time.
""",
url='http://codespeak.net/z3/sqlos/',
- version="0.2",
+ version="0.2.0",
license="ZPL",
maintainer="SQLOS development team",
maintainer_email="z3-sqlos@codespeak.net",
From jinty at codespeak.net Thu Apr 13 20:46:45 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 20:46:46 2006
Subject: [z3-checkins] r25813 - z3/sqlos/tag/0.2.0
Message-ID: <20060413184645.42FCC10081@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 20:46:41 2006
New Revision: 25813
Added:
z3/sqlos/tag/0.2.0/
- copied from r25812, z3/sqlos/branch/0.2/
Log:
Tag 0.2.0
From jinty at codespeak.net Thu Apr 13 20:54:34 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 20:54:35 2006
Subject: [z3-checkins] r25814 - z3/sqlos/trunk/doc
Message-ID: <20060413185434.6CB3810081@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 20:54:31 2006
New Revision: 25814
Added:
z3/sqlos/trunk/doc/HowToMakeARealease.rst
Log:
Make a release howto.
Added: z3/sqlos/trunk/doc/HowToMakeARealease.rst
==============================================================================
--- (empty file)
+++ z3/sqlos/trunk/doc/HowToMakeARealease.rst Thu Apr 13 20:54:31 2006
@@ -0,0 +1,60 @@
+How to make a SQLOS release
+===========================
+
+Firstly, this document is only a guide, feel free to correct/add to it.
+
+
+Major release
++++++++++++++
+
+Step 1 - Update Documentation
+-----------------------------
+
+Update the documents in the source:
+ 1. trunk/src/sqlos/README.txt - Th compatibility matrix.
+
+
+Step 2 - Make a maintenance branch for the release
+--------------------------------------------------
+
+Copy the branch:
+ 1. `svn cp https://codespeak.net/svn/z3/sqlos/trunk https://codespeak.net/svn/z3/sqlos/branch/x.y`
+
+Check it out:
+ 1. `svn co https://codespeak.net/svn/z3/sqlos/branch/x.y x.y`
+ 2. `cd x.y`
+
+Mark as a release as follows:
+ 1. svn rm setup.cfg
+ 2. update the version number in setup.py
+ 3. set the Z3BRANCH makefile variable so that the makefile points at the
+ compatible zope release branch
+
+Test the branch against Zope3 and Zope2:
+ 1. use `make test` to test the branch against the compatible version of Zope3
+ 2. TODO - develop a procedure for testing against Zope2
+
+
+Step 3 - Tag the branch as a release
+------------------------------------
+
+Copy the branch:
+ 1. `svn cp https://codespeak.net/svn/z3/sqlos/branch/x.y https://codespeak.net/svn/z3/sqlos/tag/x.y.z`
+
+Step 4 - Upload to the python cheese shop
+-----------------------------------------
+
+Simple:
+ 1. `svn co https://codespeak.net/svn/z3/sqlos/tag/x.y.z`
+ 2. cd x.y.z
+ 3. pythonX.X setup.py register sdist bdist_egg upload
+
+Step 5 - Send announcements
+---------------------------
+
+To:
+ z3-sqlos@codespeak.net
+ TODO: More?
+
+Template:
+ TODO
From jinty at codespeak.net Thu Apr 13 21:04:54 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 21:04:55 2006
Subject: [z3-checkins] r25815 - z3/www/trunk
Message-ID: <20060413190454.A110A10080@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 21:04:53 2006
New Revision: 25815
Modified:
z3/www/trunk/mkwebsite.py
Log:
Add a quick link to the sqlos 0.2.0 release.
Modified: z3/www/trunk/mkwebsite.py
==============================================================================
--- z3/www/trunk/mkwebsite.py (original)
+++ z3/www/trunk/mkwebsite.py Thu Apr 13 21:04:53 2006
@@ -225,6 +225,8 @@
('sqlos main', 'index.html'),
]
quick_links = [
+ ('sqlos 0.2.0 release (compatible with SQLObject 0.7)',
+ 'http://cheeseshop.python.org/pypi/sqlos/0.2.0'),
('sqlos 0.1 release (compatible with SQLObject 0.6)',
'release/sqlos-0.1.tgz'),
('svn (the code)',
From jinty at codespeak.net Thu Apr 13 21:16:24 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Thu Apr 13 21:16:25 2006
Subject: [z3-checkins] r25816 - z3/www/trunk
Message-ID: <20060413191624.50EBE1007C@code0.codespeak.net>
Author: jinty
Date: Thu Apr 13 21:16:22 2006
New Revision: 25816
Modified:
z3/www/trunk/mkwebsite.py
Log:
Add a link to the sqlos mailing list.
Modified: z3/www/trunk/mkwebsite.py
==============================================================================
--- z3/www/trunk/mkwebsite.py (original)
+++ z3/www/trunk/mkwebsite.py Thu Apr 13 21:16:22 2006
@@ -223,6 +223,7 @@
def sqlos_site(site, project):
nav_links = [
('sqlos main', 'index.html'),
+ ('mailing list', '/mailman/listinfo/z3-sqlos'),
]
quick_links = [
('sqlos 0.2.0 release (compatible with SQLObject 0.7)',
From jinty at codespeak.net Mon Apr 17 01:46:27 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Mon Apr 17 01:46:30 2006
Subject: [z3-checkins] r25876 - in z3/sqlos/trunk: . src/sqlos
Message-ID: <20060416234627.36781100A3@code0.codespeak.net>
Author: jinty
Date: Mon Apr 17 01:46:21 2006
New Revision: 25876
Modified:
z3/sqlos/trunk/TODO.txt
z3/sqlos/trunk/src/sqlos/README.txt
z3/sqlos/trunk/src/sqlos/_transaction.py
z3/sqlos/trunk/src/sqlos/adapter.py
z3/sqlos/trunk/src/sqlos/connection.py
Log:
Add some documntation
Modified: z3/sqlos/trunk/TODO.txt
==============================================================================
--- z3/sqlos/trunk/TODO.txt (original)
+++ z3/sqlos/trunk/TODO.txt Mon Apr 17 01:46:21 2006
@@ -4,9 +4,6 @@
Features
--------
-* Continuing quest to make sqlos containers more like zope persistent
- containers.
-
* Make it un-necessary to register the db adapter class in zcml. This is
required right now as there is no 'correct' way to tell which database a
IZopeConnection is for.
@@ -15,6 +12,3 @@
Bugs
----
-
-* the sqlos.auth, sqlos.annotations and sqlos.attributeannotations modules
- are completely un-tested and wait for someone to love them.
Modified: z3/sqlos/trunk/src/sqlos/README.txt
==============================================================================
--- z3/sqlos/trunk/src/sqlos/README.txt (original)
+++ z3/sqlos/trunk/src/sqlos/README.txt Mon Apr 17 01:46:21 2006
@@ -59,9 +59,9 @@
Dependencies
------------
- + setuptools >= 0.6a11
+ + setuptools_ >= 0.6a11
- + SQLObject >= 0.7
+ + SQLObject_ >= 0.7
Place the sqlobject package somewhere in python's sys.path
($ZOPEHOME/lib/python is a good location).
@@ -74,6 +74,7 @@
repository.
.. _zopeproducts: http://cvs.zope.org/zopeproducts/
+.. _setuptools: http://www.python.org/pypi/setuptools
Background
Modified: z3/sqlos/trunk/src/sqlos/_transaction.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/_transaction.py (original)
+++ z3/sqlos/trunk/src/sqlos/_transaction.py Mon Apr 17 01:46:21 2006
@@ -7,7 +7,21 @@
# License (ZPL) v2.1. See COPYING.txt for more information.
#
##############################################################################
-"""
+"""Transaction management.
+
+This module integrates Zope and SQLObject's transaction management. It does 3
+things:
+
+ * Creates a thread local cache of SQLObjects so that cached objects do not
+ leak into other threads as they would in pure SQLObject.
+ * Clears the thread local cache at the start of each new transaction.
+ * When an object is modified, it registers itself with the data manager
+ which, in turn, registers a pre-commit hook. This hook sync's the object
+ sending all the SQL down the line before the two phase commit starts.
+
+XXX - There was a reason why we couldn't do this without a data manager, but I
+ cannot remember it now. -jinty
+
$Id$
"""
Modified: z3/sqlos/trunk/src/sqlos/adapter.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/adapter.py (original)
+++ z3/sqlos/trunk/src/sqlos/adapter.py Mon Apr 17 01:46:21 2006
@@ -7,14 +7,18 @@
# License (ZPL) v2.1. See COPYING.txt for more information.
#
##############################################################################
-"""
+"""Connection adapters for sqlos.
+
+These adapters adapt Zope RDB Connections to SQLObject connections by
+sub-classing the SQLObject connection classes.
+
$Id$
"""
__metaclass__ = type
from sqlobject.dbconnection import DBAPI
-from sqlobject import _mysql, _postgres, _sybase, _sqlite
+from sqlobject import _mysql, _postgres, _sqlite
from sqlobject.converters import registerConverter
from sqlobject.mysql import mysqlconnection
from zope.app.rdb.interfaces import DatabaseException
Modified: z3/sqlos/trunk/src/sqlos/connection.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/connection.py (original)
+++ z3/sqlos/trunk/src/sqlos/connection.py Mon Apr 17 01:46:21 2006
@@ -8,6 +8,15 @@
#
##############################################################################
"""
+Connection management.
+
+This module defines the connection descriptor used as the connection in a
+a sqlos SQLObject. This is responsible for getting the Zope connection and
+adapting it to look like a SQLObject connection.
+
+Connections are cached as experience has shown that all the utility and
+adapter utilities have a significant effect on speed.
+
$Id: factory.py 5216 2004-06-21 18:33:07Z dreamcatcher $
"""
__metaclass__ = type
From reebalazs at codespeak.net Tue Apr 18 08:31:59 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Tue Apr 18 08:32:00 2006
Subject: [z3-checkins] r25926 - z3/jsonserver/branch/merge/browser
Message-ID: <20060418063159.8D8A31008F@code0.codespeak.net>
Author: reebalazs
Date: Tue Apr 18 08:31:58 2006
New Revision: 25926
Modified:
z3/jsonserver/branch/merge/browser/json.js
z3/jsonserver/branch/merge/browser/xmlhttp.js
Log:
Critical: in XMLHttp change parameters and headers to Object from Array!
Because it is handled with for(xx in obj), they must be created
as Object. Problem is, that Sarissa puts extra functions in the
Array prototype, and these would come up in the iteration:
- causing an exception at setHeader,
- and snapping a &xxx=xxx...etc part to the end of the json
variable, causing a decode error on the server side.
The problem only instantiated (strangely) when we were logged
in as a plone user, in the kukitportlets demo.
Modified: z3/jsonserver/branch/merge/browser/json.js
==============================================================================
--- z3/jsonserver/branch/merge/browser/json.js (original)
+++ z3/jsonserver/branch/merge/browser/json.js Tue Apr 18 08:31:58 2006
@@ -164,7 +164,7 @@
JSONRPCMethod.prototype.postData = function(url, user, pass, data, timeout, callback) {
var xmlhttp = new XMLHttp(url);
- var header = new Array()
+ var header = new Object()
header["Content-Type"] = "application/json-rpc";
xmlhttp.setHeaders(header);
xmlhttp.user = user;
@@ -291,7 +291,7 @@
var v = [];
for(attr in o) {
if(o[attr] == null) v.push("\"" + attr + "\": null");
- else if(typeof o[attr] == "function"); // skip
+ else if(typeof(o[attr]) == "function"); // skip
else v.push(escapeJSONString(attr) + ": " + toJSON(o[attr]));
}
return "{" + v.join(", ") + "}";
Modified: z3/jsonserver/branch/merge/browser/xmlhttp.js
==============================================================================
--- z3/jsonserver/branch/merge/browser/xmlhttp.js (original)
+++ z3/jsonserver/branch/merge/browser/xmlhttp.js Tue Apr 18 08:31:58 2006
@@ -27,8 +27,8 @@
this.password = null;
this.timeout = null;
this.argString = "";
- this.parameters = new Array();
- this.headers = new Array();
+ this.parameters = new Object();
+ this.headers = new Object();
this.headers['Content-Type'] = 'application/x-www-form-urlencoded'
/* internal status flags */
From reebalazs at codespeak.net Tue Apr 18 17:11:19 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Tue Apr 18 17:11:20 2006
Subject: [z3-checkins] r25954 - z3/jsonserver/branch/merge/browser
Message-ID: <20060418151119.4EC851008E@code0.codespeak.net>
Author: reebalazs
Date: Tue Apr 18 17:11:16 2006
New Revision: 25954
Added:
z3/jsonserver/branch/merge/browser/logging.js
z3/jsonserver/branch/merge/browser/requestmanager.js
Modified:
z3/jsonserver/branch/merge/browser/configure.zcml
z3/jsonserver/branch/merge/browser/json.js
Log:
Add logging and simple support for simple request queue management
Modified: z3/jsonserver/branch/merge/browser/configure.zcml
==============================================================================
--- z3/jsonserver/branch/merge/browser/configure.zcml (original)
+++ z3/jsonserver/branch/merge/browser/configure.zcml Tue Apr 18 17:11:16 2006
@@ -4,9 +4,11 @@
-
\ No newline at end of file
+
Modified: z3/jsonserver/branch/merge/browser/json.js
==============================================================================
--- z3/jsonserver/branch/merge/browser/json.js (original)
+++ z3/jsonserver/branch/merge/browser/json.js Tue Apr 18 17:11:16 2006
@@ -51,6 +51,21 @@
function JSONSupplement(data, id) {
return new json.SupplementWrapper(data, id);
}
+
+// Direct method creation, by creating an implicit proxy
+// if methodName == '' then the url is taken as full url
+function makeJSONRPCMethod(url, methodName, callback, error, timeout, supplementData,
+ requestId, requestManager, user, pass) {
+ if (typeof(methodName) == 'undefined' || methodName == null || methodName == '') {
+ var pieces = url.split('/');
+ methodName = pieces.pop();
+ url = pieces.join('/');
+ }
+ var proxy = new JSONRPC(url);
+ proxy.addMethod(methodName, callback, error, timeout, supplementData,
+ requestId, requestManager, user, pass);
+ return proxy[methodName];
+}
function JSONRPC(url) {
this._url = url;
@@ -63,7 +78,7 @@
return new JSONRPC(url);
}
-JSONRPC.prototype.addMethod = function(name, callback, errHandler, timeout, supplementData, requestId) {
+JSONRPC.prototype.addMethod = function(name, callback, errHandler, timeout, supplementData, requestId, requestManager) {
if (typeof(errHandler) == 'undefined') {
errHandler = null;
}
@@ -76,9 +91,13 @@
if (typeof(requestId) == 'undefined' || requestId == null) {
requestId = "jsonRequest";
}
+ if (typeof(requestManager) == 'undefined' || requestManager == null) {
+ requestManager = _dummyRequestManager;
+ }
var self = this;
if(!self[name]){
- var method = new JSONRPCMethod(this._url, name, callback, errHandler, timeout, supplementData, requestId, this._user, this._password);
+ var method = new JSONRPCMethod(this._url, name, callback, errHandler, timeout, supplementData, requestId,
+ requestManager, this._user, this._password);
self[name] = method;
this._methods.push(method);
}
@@ -92,12 +111,26 @@
}
}
-function JSONRPCMethod(url, methodName, callback, errHandler, timeout, supplementData, requestId, user, pass) {
+function _DummyRequestManager() {
+ }
+
+_DummyRequestManager.prototype.notifyServer = function(method_with_parms, url) {
+ method_with_parms();
+ }
+
+_DummyRequestManager.prototype.receivedResult = function() {
+ }
+
+var _dummyRequestManager = _DummyRequestManager();
+
+function JSONRPCMethod(url, methodName, callback, errHandler, timeout, supplementData, requestId,
+ requestManager, user, pass) {
this.methodName = methodName;
this.callback = callback;
this.errHandler = errHandler;
this.supplementData = supplementData;
this.requestId = requestId;
+ this.requestManager = requestManager;
this.url = url;
this.user = user;
this.password = pass;
@@ -132,26 +165,30 @@
}
if(self.callback) {
var data = self.jsonRequest(requestId, self.methodName, args);
- self.postData(self.url, self.user, self.password, data, timeout, function(resp){
- var res = null;
- var exc = null;
- try {
- res = self.handleResponse(resp);
- } catch(e) {
- if (e.name == 'JSONRPCError' && self.errHandler) {
- exc = e;
+ var do_postdata = function() {
+ self.postData(self.url, self.user, self.password, data, timeout, function(resp){
+ var res = null;
+ var exc = null;
+ try {
+ res = self.handleResponse(resp);
+ } catch(e) {
+ if (e.name == 'JSONRPCError' && self.errHandler) {
+ exc = e;
+ } else {
+ throw(e);
+ }
+ }
+ self.requestManager.receivedResult();
+ if (exc == null) {
+ self.callback(res, supplementData, requestId);
} else {
- throw(e);
+ self.errHandler(exc, supplementData, requestId);
}
- }
- if (exc == null) {
- self.callback(res, supplementData, requestId);
- } else {
- self.errHandler(exc, supplementData, requestId);
- }
- args = null;
- resp = null;
- });
+ args = null;
+ resp = null;
+ });
+ }
+ self.requestManager.notifyServer(do_postdata, self.url + '/' + self.methodName);
} else {
var data = self.jsonRequest(requestId, self.methodName, args);
var resp = self.postData(self.url, self.user, self.password, data, timeout);
@@ -159,7 +196,6 @@
}
}
return fn;
-
}
JSONRPCMethod.prototype.postData = function(url, user, pass, data, timeout, callback) {
Added: z3/jsonserver/branch/merge/browser/logging.js
==============================================================================
--- (empty file)
+++ z3/jsonserver/branch/merge/browser/logging.js Tue Apr 18 17:11:16 2006
@@ -0,0 +1,23 @@
+/* Set up logging with Mochikit, if that is installed */
+
+/* Create jsonrpc namespace */
+
+if (typeof(jsonrpc) == 'undefined') {
+ var jsonrpc = {};
+}
+
+/* check whether the logging stuff of MochiKit is available */
+try {
+ MochiKit.Logging.log('Initializing jsonrpc');
+ jsonrpc.log = MochiKit.Logging.log;
+ jsonrpc.logError = MochiKit.Logging.logError;
+ jsonrpc.logDebug = MochiKit.Logging.logDebug;
+ jsonrpc.logFatal = MochiKit.Logging.logFatal;
+ jsonrpc.logWarning = MochiKit.Logging.logWarning;
+} catch(e) {
+ jsonrpc.log = function(str){};
+ jsonrpc.logError = jsonrpc.log;
+ jsonrpc.logDebug = jsonrpc.log;
+ jsonrpc.logFatal = jsonrpc.log;
+ jsonrpc.logWarning = jsonrpc.log;
+}
Added: z3/jsonserver/branch/merge/browser/requestmanager.js
==============================================================================
--- (empty file)
+++ z3/jsonserver/branch/merge/browser/requestmanager.js Tue Apr 18 17:11:16 2006
@@ -0,0 +1,141 @@
+/* Request manager
+
+This limits the number of outgoing requests. Extra
+requests are stored and sent out on demand.
+
+XXX Requests never, at the moment, time out from the queue
+TODO should take care of this.
+
+It is possible to have more instances and have different methods
+queue up in different queues.
+
+Usage:
+
+- instantiate a queue
+- use it as a parameter for addMethod
+- it will only queue async requests.
+
+Usage manually:
+
+- notifyServer(func, url) , where func is a partial containing
+ all parameters,
+- receivedResult() when result is received or an error is signalled.
+
+*/
+
+jsonrpc.RequestManager = function (name, maxNr) {
+ this.waitingQueue = new jsonrpc.FifoQueue();
+ this.sentNr = 0;
+ if (typeof(name) == undefined) {
+ name = null;
+ }
+ this.name = name;
+ var namestr = '';
+ if (name != null) {
+ namestr = '[' + name + '] '
+ }
+ this.namestr = namestr;
+ if (typeof(maxNr) != undefined && maxNr != null) {
+ this.maxNr = maxNr;
+ }
+}
+
+// max request nr
+jsonrpc.RequestManager.prototype.maxNr = 4;
+
+jsonrpc.RequestManager.prototype.getInfo = function() {
+ return '(RQ: ' + this.sentNr + ' OUT, ' + this.waitingQueue.size() + ' WAI)';
+}
+
+jsonrpc.RequestManager.prototype.log = function(txt) {
+ jsonrpc.logDebug('RequestManager ' + this.namestr + txt + ' ' + this.getInfo());
+}
+
+jsonrpc.RequestManager.prototype.pushWaitingRequest = function(func, url) {
+ this.waitingQueue.push([func, url]);
+}
+
+jsonrpc.RequestManager.prototype.popWaitingRequest = function() {
+ return this.waitingQueue.pop();
+}
+
+jsonrpc.RequestManager.prototype.isWaitingRequestQueueEmpty = function() {
+ return this.waitingQueue.empty();
+}
+
+jsonrpc.RequestManager.prototype.pushSentRequest = function(func, url) {
+ // we do not store the elems, since they are not needed now
+ this.sentNr = this.sentNr + 1;
+}
+
+jsonrpc.RequestManager.prototype.popSentRequest = function() {
+ this.sentNr = this.sentNr - 1;
+}
+
+jsonrpc.RequestManager.prototype.isSentRequestQueueFull = function() {
+ return (this.sentNr >= this.maxNr)
+}
+
+/* request manager notification API */
+
+jsonrpc.RequestManager.prototype.notifyServer = function(func, url) {
+ // func must be a partial (e.g. use Mochikit or wrap up)
+ // here url is only for the logging
+ if (! jsonrpc.requestManager.isSentRequestQueueFull()) {
+ // can be sent if we are not over the limit.
+ this.pushSentRequest(func, url);
+ this.log('Notify server at ' + url);
+ func();
+ } else {
+ this.pushWaitingRequest(func, url);
+ this.log('Queue server notification at ' + url);
+ }
+}
+
+jsonrpc.RequestManager.prototype.receivedResult = function() {
+ // must be called when one result arrived
+ // Mark that we have one less request out.
+ jsonrpc.requestManager.popSentRequest();
+ if (! jsonrpc.requestManager.isWaitingRequestQueueEmpty()) {
+ // see if we can send another request in place of the received one
+ // request is waiting, send it.
+ var waiting = jsonrpc.requestManager.popWaitingRequest();
+ var func = waiting[0];
+ var url = waiting[1];
+ jsonrpc.requestManager.pushSentRequest(func, url);
+ this.log("Send queued notification to server at " + url);
+ func();
+ } else {
+ this.log("Request queue empty.");
+ }
+}
+
+/* simple FIFO queue */
+
+jsonrpc.FifoQueue = function () {
+ this.reset();
+}
+
+jsonrpc.FifoQueue.prototype.reset = function() {
+ this.elements = new Array();
+}
+
+jsonrpc.FifoQueue.prototype.push = function(obj) {
+ this.elements.push(obj);
+}
+
+jsonrpc.FifoQueue.prototype.pop = function() {
+ return this.elements.shift();
+}
+
+jsonrpc.FifoQueue.prototype.empty = function() {
+ return ! this.elements.length;
+}
+
+jsonrpc.FifoQueue.prototype.size = function() {
+ return this.elements.length;
+}
+
+jsonrpc.FifoQueue.prototype.front = function() {
+ return this.elements[0];
+}
From reebalazs at codespeak.net Tue Apr 18 17:24:58 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Tue Apr 18 17:24:59 2006
Subject: [z3-checkins] r25957 - z3/jsonserver/branch/merge/browser
Message-ID: <20060418152458.4EE041009C@code0.codespeak.net>
Author: reebalazs
Date: Tue Apr 18 17:24:57 2006
New Revision: 25957
Modified:
z3/jsonserver/branch/merge/browser/requestmanager.js
Log:
Fix request manager
Modified: z3/jsonserver/branch/merge/browser/requestmanager.js
==============================================================================
--- z3/jsonserver/branch/merge/browser/requestmanager.js (original)
+++ z3/jsonserver/branch/merge/browser/requestmanager.js Tue Apr 18 17:24:57 2006
@@ -81,7 +81,7 @@
jsonrpc.RequestManager.prototype.notifyServer = function(func, url) {
// func must be a partial (e.g. use Mochikit or wrap up)
// here url is only for the logging
- if (! jsonrpc.requestManager.isSentRequestQueueFull()) {
+ if (! this.isSentRequestQueueFull()) {
// can be sent if we are not over the limit.
this.pushSentRequest(func, url);
this.log('Notify server at ' + url);
@@ -95,14 +95,14 @@
jsonrpc.RequestManager.prototype.receivedResult = function() {
// must be called when one result arrived
// Mark that we have one less request out.
- jsonrpc.requestManager.popSentRequest();
- if (! jsonrpc.requestManager.isWaitingRequestQueueEmpty()) {
+ this.popSentRequest();
+ if (! this.isWaitingRequestQueueEmpty()) {
// see if we can send another request in place of the received one
// request is waiting, send it.
- var waiting = jsonrpc.requestManager.popWaitingRequest();
+ var waiting = this.popWaitingRequest();
var func = waiting[0];
var url = waiting[1];
- jsonrpc.requestManager.pushSentRequest(func, url);
+ this.pushSentRequest(func, url);
this.log("Send queued notification to server at " + url);
func();
} else {
From reebalazs at codespeak.net Thu Apr 20 08:24:18 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Thu Apr 20 08:24:21 2006
Subject: [z3-checkins] r26014 - z3/jsonserver/branch/merge/concatresource
Message-ID: <20060420062418.9E24E100C6@code0.codespeak.net>
Author: reebalazs
Date: Thu Apr 20 08:24:15 2006
New Revision: 26014
Modified:
z3/jsonserver/branch/merge/concatresource/concatresource.py
Log:
Adjust Five import to Zope 2.9 / Five 1.3
Modified: z3/jsonserver/branch/merge/concatresource/concatresource.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/concatresource.py (original)
+++ z3/jsonserver/branch/merge/concatresource/concatresource.py Thu Apr 20 08:24:15 2006
@@ -13,7 +13,14 @@
from zope.app.publisher.browser.resource import Resource
else:
__five__ = True
- from Products.Five.resource import Resource
+ try:
+ # Zope 2.8 / Five 1.0.2
+ from Products.Five.resource import Resource
+ __five_pre_1_3_ = True
+ except ImportError:
+ # Zope 2.9 / Five 1.3
+ from Products.Five.browser.resource import Resource
+ __five_pre_1_3__ = False
class GenericResource(BrowserView, Resource):
"""A publishable resource"""
From reebalazs at codespeak.net Thu Apr 20 10:53:49 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Thu Apr 20 10:53:50 2006
Subject: [z3-checkins] r26020 - z3/jsonserver/branch/merge/browser
Message-ID: <20060420085349.DE93410087@code0.codespeak.net>
Author: reebalazs
Date: Thu Apr 20 10:53:48 2006
New Revision: 26020
Modified:
z3/jsonserver/branch/merge/browser/json.js
Log:
Critical fix (self.requestManager has no properties)
Modified: z3/jsonserver/branch/merge/browser/json.js
==============================================================================
--- z3/jsonserver/branch/merge/browser/json.js (original)
+++ z3/jsonserver/branch/merge/browser/json.js Thu Apr 20 10:53:48 2006
@@ -121,7 +121,7 @@
_DummyRequestManager.prototype.receivedResult = function() {
}
-var _dummyRequestManager = _DummyRequestManager();
+var _dummyRequestManager = new _DummyRequestManager();
function JSONRPCMethod(url, methodName, callback, errHandler, timeout, supplementData, requestId,
requestManager, user, pass) {
From reebalazs at codespeak.net Thu Apr 20 12:08:26 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Thu Apr 20 12:08:28 2006
Subject: [z3-checkins] r26026 - z3/jsonserver/branch/zope2_test
Message-ID: <20060420100826.D51C31008D@code0.codespeak.net>
Author: reebalazs
Date: Thu Apr 20 12:08:25 2006
New Revision: 26026
Modified:
z3/jsonserver/branch/zope2_test/jsonrpc.py
Log:
Make the IJsonRequest interface bound in Zope 2.9
In 2.9 I realized that the interface binding does not work
somehow directlyProvides attaches the interfact but it disappears
later where I want to use it for an adapter lookup.
Now we provide the interface in the class level and
override __class__ of the request object on the run.
Modified: z3/jsonserver/branch/zope2_test/jsonrpc.py
==============================================================================
--- z3/jsonserver/branch/zope2_test/jsonrpc.py (original)
+++ z3/jsonserver/branch/zope2_test/jsonrpc.py Thu Apr 20 12:08:25 2006
@@ -21,8 +21,10 @@
from zLOG import LOG, INFO, DEBUG, WARNING, ERROR
from cgi import FieldStorage
import ZPublisher.HTTPResponse
-from zope.interface import directlyProvides, directlyProvidedBy
+##from zope.interface import directlyProvides, directlyProvidedBy
+from zope.interface import implements
from interfaces import IJsonRequest
+from ZPublisher.HTTPRequest import HTTPRequest
# this is used to identify incoming requests
request_content_type = 'application/json-rpc'
@@ -198,6 +200,11 @@
# Patching processInputs of ZPublisher.HTTPRequest
# --
+class JsonRpcRequest(HTTPRequest):
+ 'JSON-RPC HTTP request'
+ # this is just used to force the interface on the object
+ implements(IJsonRequest)
+
re_content_type= re.compile(r'charset\s*=\s*([^;]+)')
def processInputs(self, **kw):
@@ -245,9 +252,13 @@
# set the marker that can be used to check if we are in json mode
other['JSON_MODE'] = self.json_mode = True
# also set the request interface
- interfaces = directlyProvidedBy(self)
- interfaces += IJsonRequest
- directlyProvides(self, interfaces)
+ # XXX this would be good but for some reason gets "swallowed"
+ # by the time we get there, so we override the class instead.
+ # This error first manifested in Zope2.9, it was ok. till 2.8.
+ ##interfaces = directlyProvidedBy(self)
+ ##interfaces += IJsonRequest
+ ##directlyProvides(self, interfaces)
+ self.__class__ = JsonRpcRequest
#
response = Response(response, jsonID)
other['RESPONSE'] = self.response = response
@@ -264,7 +275,6 @@
self.stdin.seek(0)
return self._processInputs_jsonrc_patched(**kw)
-from ZPublisher.HTTPRequest import HTTPRequest
def patch_HTTPRequest():
'This will patch HTTPRequest to enable json-rpc handling'
HTTPRequest._processInputs_jsonrc_patched, HTTPRequest.processInputs = \
From reebalazs at codespeak.net Fri Apr 21 09:32:09 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Fri Apr 21 09:32:12 2006
Subject: [z3-checkins] r26075 - in
z3/jsonserver/branch/merge/concatresource: . compression test
Message-ID: <20060421073209.DC6DB1007D@code0.codespeak.net>
Author: reebalazs
Date: Fri Apr 21 09:32:05 2006
New Revision: 26075
Added:
z3/jsonserver/branch/merge/concatresource/README
Modified:
z3/jsonserver/branch/merge/concatresource/compression/__init__.py
z3/jsonserver/branch/merge/concatresource/compression/css.py
z3/jsonserver/branch/merge/concatresource/compression/javascript.py
z3/jsonserver/branch/merge/concatresource/concatfileresource.py
z3/jsonserver/branch/merge/concatresource/concatresource.py
z3/jsonserver/branch/merge/concatresource/directives.py
z3/jsonserver/branch/merge/concatresource/meta.py
z3/jsonserver/branch/merge/concatresource/test/configure.zcml
Log:
Adding compress_level as attribute, choices are "none", "safe", "full"
Added: z3/jsonserver/branch/merge/concatresource/README
==============================================================================
--- (empty file)
+++ z3/jsonserver/branch/merge/concatresource/README Fri Apr 21 09:32:05 2006
@@ -0,0 +1,72 @@
+
+Objectives
+----------
+
+I made this utility for the works in the jsonserver integration and
+AZAX/kukit. This was meant to be a temporary, lightweight solution but it
+has long term merits too. I needed this because I wanted a solution that
+works right now, works on zope3 and zope 2.8 even (so zc.resourcelibraries
+was not a choice), does not depend on Plone (so ResourceRegistries is out
+too).
+
+The interesting point of the utility is: instead of building registries to
+emit include tags in the HTML, it simply makes one resource that needs to
+be imported in a single line::
+
+
+
+Also:
+
+- it compresses the JS or CSS files with Florian Schulze's compressor
+ from ResourceRegistries
+
+- it contains an utility interface that another component can implement
+ to dynamically extend the list of files (like I did with AZAX). So the
+ "registry" is not really implemented but can be plugged in.
+
+- it is tested (although not much) to work with Zope 2.8, 2.9, 3.1, 3.2
+
+Meanwhile I implemented the cache headers for the resources correctly
+here, the current implementation of caching is broken in Five and I
+believe in Z3 resources as well; beware that I considered the original
+Zope3 code only and did not look at additional utilities. According to my
+observation: in Z3 the original resources attempt to handle the cache
+headers correctly but never really check if the file gets changed on the
+filesystem (only on restart). If this is really a problem and not just I
+believe, then it is fixed in my code.
+
+More information on this issue:
+
+http://article.gmane.org/gmane.comp.web.zope.z3base.general/53
+
+Compression
+-----------
+
+You can use more levels of compressions with the compress_level attribute.
+
+
+
+Some explanation:
+
+- compression is only implemented for JavaScript and CSS
+
+- The default level is "safe", this is useable with all scripts
+
+- The "full" level gives even better compression by taking out all newlines
+ and mangling private variable names, but some preparation must be made
+ in the scripts for that (like putting a ; after }-s I think, and
+ also maybe more).
+
+- Specifying "none" will leave your resource uncompressed. This
+ can be useful for debugging.
+
+
Modified: z3/jsonserver/branch/merge/concatresource/compression/__init__.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/compression/__init__.py (original)
+++ z3/jsonserver/branch/merge/concatresource/compression/__init__.py Fri Apr 21 09:32:05 2006
@@ -14,7 +14,7 @@
default_compress_method = lambda text: text
-def compress(data, content_type):
+def compress(data, content_type, compress_level):
'Returns compressed text for a given content type'
method = compress_methods.get(content_type, default_compress_method)
- return method(data)
+ return method(data, compress_level)
Modified: z3/jsonserver/branch/merge/concatresource/compression/css.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/compression/css.py (original)
+++ z3/jsonserver/branch/merge/concatresource/compression/css.py Fri Apr 21 09:32:05 2006
@@ -5,7 +5,14 @@
from thirdparty.packer import CSSPacker
-csspacker_full = CSSPacker('safe')
+csspacker_safe = CSSPacker('safe')
+csspacker_full = CSSPacker('full')
-def compress(data):
- return csspacker_full.pack(data)
+def compress(data, compress_level):
+ if compress_level == "safe":
+ return csspacker_safe.pack(data)
+ elif compress_level == "full":
+ return csspacker_full.pack(data)
+ else:
+ # none
+ return data
Modified: z3/jsonserver/branch/merge/concatresource/compression/javascript.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/compression/javascript.py (original)
+++ z3/jsonserver/branch/merge/concatresource/compression/javascript.py Fri Apr 21 09:32:05 2006
@@ -4,7 +4,14 @@
from thirdparty.packer import JavascriptPacker
-jspacker_full = JavascriptPacker('safe')
+jspacker_safe = JavascriptPacker('safe')
+jspacker_full = JavascriptPacker('full')
-def compress(data):
- return jspacker_full.pack(data)
+def compress(data, compress_level):
+ if compress_level == "safe":
+ return jspacker_safe.pack(data)
+ elif compress_level == "full":
+ return jspacker_full.pack(data)
+ else:
+ # none
+ return data
Modified: z3/jsonserver/branch/merge/concatresource/concatfileresource.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/concatfileresource.py (original)
+++ z3/jsonserver/branch/merge/concatresource/concatfileresource.py Fri Apr 21 09:32:05 2006
@@ -24,7 +24,7 @@
'''
implements(IContextFile)
- def __init__(self, pathlist, name):
+ def __init__(self, pathlist, name, compress_level):
# Path is now a list.
assert isinstance(pathlist, (list, tuple))
# check all files, just to raise error if don't exist
@@ -33,6 +33,7 @@
#
self.pathlist_base = pathlist
self.__name__ = name
+ self.compress_level = compress_level
# markers for pathlist modification
self.pathlist = []
self.fileslist_changed = None
@@ -88,6 +89,7 @@
assert d['content_type'] == content_type
data.append(d['data'])
result['data'] = '\n'.join(data)
+ result['compress_level'] = self.compress_level
# Do compression on the result
result['data'] = compress(**result)
return result
Modified: z3/jsonserver/branch/merge/concatresource/concatresource.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/concatresource.py (original)
+++ z3/jsonserver/branch/merge/concatresource/concatresource.py Fri Apr 21 09:32:05 2006
@@ -104,9 +104,10 @@
factory = None
resource = None
- def __init__(self, path, name, resource_factory=None, checker=None):
+ def __init__(self, path, name, compress_level, resource_factory=None, checker=None):
self.__name = name
self.__path = path
+ self.__compress_level = compress_level
if resource_factory is not None:
self.resource = resource_factory
# z3 only
@@ -117,7 +118,7 @@
rsrc = self.__rsrc
except AttributeError:
# Delayed creation. That assures that registry is set up by this time.
- rsrc = self.__rsrc = ICachedResource(self.factory(self.__path, self.__name))
+ rsrc = self.__rsrc = ICachedResource(self.factory(self.__path, self.__name, self.__compress_level))
resource = self.resource(rsrc, request)
# z3 only
resource.__name__ = self.__name
Modified: z3/jsonserver/branch/merge/concatresource/directives.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/directives.py (original)
+++ z3/jsonserver/branch/merge/concatresource/directives.py Fri Apr 21 09:32:05 2006
@@ -1,7 +1,7 @@
from zope.interface import Interface
from zope.configuration.fields import GlobalObject, Tokens, Path, \
PythonIdentifier, MessageID
-from zope.schema import TextLine, Text, Id
+from zope.schema import TextLine, Text, Id, Choice
from zope.app.security.fields import Permission
from fields import PathList
from zope.app.component.metadirectives import IBasicViewInformation
@@ -29,3 +29,10 @@
description=u"A space separated list of resource files",
required=True
)
+
+ compress_level = Choice(
+ title=u"Compress level",
+ description=u"Level of compression applied, by default 'safe'.",
+ values=(u'none', u'safe', u'full'),
+ required=False,
+ )
Modified: z3/jsonserver/branch/merge/concatresource/meta.py
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/meta.py (original)
+++ z3/jsonserver/branch/merge/concatresource/meta.py Fri Apr 21 09:32:05 2006
@@ -39,7 +39,7 @@
},
}
-def concatresource(_context, name, files=None, layer=_layer, permission='zope.Public'):
+def concatresource(_context, name, files=None, compress_level='safe', layer=_layer, permission='zope.Public'):
if not files:
raise ConfigurationError(
@@ -78,7 +78,7 @@
checker = NamesChecker(allowed_names, permission)
- factory = res_factory(res, name, resource_factory=new_class, checker=checker)
+ factory = res_factory(res, name, compress_level, resource_factory=new_class, checker=checker)
if __pre_3_2__:
_context.action(
Modified: z3/jsonserver/branch/merge/concatresource/test/configure.zcml
==============================================================================
--- z3/jsonserver/branch/merge/concatresource/test/configure.zcml (original)
+++ z3/jsonserver/branch/merge/concatresource/test/configure.zcml Fri Apr 21 09:32:05 2006
@@ -8,4 +8,11 @@
test2.js"
/>
+
+
From jinty at codespeak.net Fri Apr 21 15:15:08 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Fri Apr 21 15:15:11 2006
Subject: [z3-checkins] r26099 - in z3/sqlos/trunk/src/sqlos: . testing tests
Message-ID: <20060421131508.B733310084@code0.codespeak.net>
Author: jinty
Date: Fri Apr 21 15:14:55 2006
New Revision: 26099
Modified:
z3/sqlos/trunk/src/sqlos/README.txt
z3/sqlos/trunk/src/sqlos/__init__.py
z3/sqlos/trunk/src/sqlos/testing/sampleperson.py
z3/sqlos/trunk/src/sqlos/tests/test_doctests.py
Log:
move sqlos._sqlos to sqlos.zsqlobject and softly deprecate the import of SQLOS from sqlos.
Modified: z3/sqlos/trunk/src/sqlos/README.txt
==============================================================================
--- z3/sqlos/trunk/src/sqlos/README.txt (original)
+++ z3/sqlos/trunk/src/sqlos/README.txt Fri Apr 21 15:14:55 2006
@@ -198,7 +198,7 @@
>>> from zope.interface import implements
>>> from sqlobject import *
- >>> from sqlos import SQLOS
+ >>> from sqlos.zsqlobject import SQLOS
>>> class Person(SQLOS):
... implements(IPerson)
Modified: z3/sqlos/trunk/src/sqlos/__init__.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/__init__.py (original)
+++ z3/sqlos/trunk/src/sqlos/__init__.py Fri Apr 21 15:14:55 2006
@@ -16,7 +16,10 @@
import zope.component
from sqlobject.sqlbuilder import registerConverter
-from _sqlos import SQLOS
+# sqlos.SQLOS is softly deprecated, will go away sometime
+# (after at least one major release with deprecation warnings)
+# import directly from sqlos.zsqlobject
+from sqlos.zsqlobject import SQLOS
def caller(n=1):
"""Return the name of the calling function n levels up in the frame stack.
Modified: z3/sqlos/trunk/src/sqlos/testing/sampleperson.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/testing/sampleperson.py (original)
+++ z3/sqlos/trunk/src/sqlos/testing/sampleperson.py Fri Apr 21 15:14:55 2006
@@ -4,7 +4,7 @@
from zope.schema import TextLine, Text, Datetime
from zope.app.container import constraints
-from sqlos import SQLOS
+from sqlos.zsqlobject import SQLOS
from sqlos.interfaces import ISQLSchema, IISQLObjectIsolated, ISQLObjectIsolated
from sqlos.interfaces.container import ISQLObjectContainer
from sqlos.container import SQLObjectContainer, SQLIsolatedContainer
Modified: z3/sqlos/trunk/src/sqlos/tests/test_doctests.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/tests/test_doctests.py (original)
+++ z3/sqlos/trunk/src/sqlos/tests/test_doctests.py Fri Apr 21 15:14:55 2006
@@ -26,5 +26,5 @@
DocTestSuite('sqlos.container', optionflags=doctest.ELLIPSIS),
DocTestSuite('sqlos.connection'),
DocTestSuite('sqlos._transaction'),
- DocTestSuite('sqlos._sqlos')
+ DocTestSuite('sqlos.zsqlobject')
])
From jinty at codespeak.net Fri Apr 21 15:23:02 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Fri Apr 21 15:23:03 2006
Subject: [z3-checkins] r26100 - z3/sqlos/trunk/src/sqlos
Message-ID: <20060421132302.83ADD10084@code0.codespeak.net>
Author: jinty
Date: Fri Apr 21 15:22:59 2006
New Revision: 26100
Modified:
z3/sqlos/trunk/src/sqlos/__init__.py
Log:
Remove cruft and deprecated code. Also drop an XXX for untested code.
Modified: z3/sqlos/trunk/src/sqlos/__init__.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/__init__.py (original)
+++ z3/sqlos/trunk/src/sqlos/__init__.py Fri Apr 21 15:22:59 2006
@@ -10,10 +10,7 @@
$Id$
"""
-__metaclass__ = type
-
from datetime import datetime, date
-import zope.component
from sqlobject.sqlbuilder import registerConverter
# sqlos.SQLOS is softly deprecated, will go away sometime
@@ -21,14 +18,8 @@
# import directly from sqlos.zsqlobject
from sqlos.zsqlobject import SQLOS
-def caller(n=1):
- """Return the name of the calling function n levels up in the frame stack.
- Ex: caller(0) ==> 'caller'; def f(): return caller(); f() ==> 'f'
- """
- import inspect
- return inspect.getouterframes(inspect.currentframe())[n][3]
-
+## XXX: What are these?? I am sure there are no tests for them. - jinty
def DateTimeConverter(value, db=None):
return repr(value.isoformat())
@@ -40,19 +31,3 @@
return repr(value.isoformat())
registerConverter(date, DateConverter)
-
-
-def getFactory(name, context=None, default=None):
- # XXX - deprecated, goes away after sqlos 0.2
- return zope.component.queryUtility(IISQLObject, name, default=default, context=context)
-
-from zope.deprecation import deprecated
-msg = "getFactory is depreciated and will go away after sqlos 0.2 you should \
-replace this with a direct call to \
-zope.component.getUtility(IISQLObject, name, context=context) if you need the \
-functionailty of a SQLObject class, or \
-zope.component.getUtility(IFactory, name, context=context) if you want to use it as a \
-factory."
-
-deprecated("getFactory", msg)
-deprecated("caller", "sqlos.caller is deprecated and will be removed after sqlos 0.2")
From jinty at codespeak.net Fri Apr 21 15:28:47 2006
From: jinty at codespeak.net (jinty@codespeak.net)
Date: Fri Apr 21 15:28:48 2006
Subject: [z3-checkins] r26101 - z3/sqlos/trunk/src/sqlos
Message-ID: <20060421132847.95ACE10084@code0.codespeak.net>
Author: jinty
Date: Fri Apr 21 15:28:44 2006
New Revision: 26101
Modified:
z3/sqlos/trunk/src/sqlos/container.py
Log:
Remove the deprecated allowedFactories method.
Modified: z3/sqlos/trunk/src/sqlos/container.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/container.py (original)
+++ z3/sqlos/trunk/src/sqlos/container.py Fri Apr 21 15:28:44 2006
@@ -17,7 +17,6 @@
from persistent import Persistent
from zope.interface import implements
from zope.component import IFactory
-from zope import deprecation
import zope.component
from zope.app.container.interfaces import IContained
from zope.app.container.contained import ContainedProxy
@@ -86,14 +85,6 @@
def __init__(self):
pass
- def _allowedFactories(self):
- for name, factory in zope.component.getFactoriesFor(ISQLObject):
- if checkFactory(self, None, factory):
- yield name
- allowedFactories = deprecation.deprecated(_allowedFactories,
- 'allowedFactories is deprecated and will be removed after sqlos 0.2'
- ' please use _getAllowedIISQLObjectUtilities instead.')
-
def _getAllowedIISQLObjectUtilities(self):
for name, factory in zope.component.getFactoriesFor(ISQLObject):
if checkFactory(self, None, factory):
@@ -209,16 +200,6 @@
_container_id = None
- def allowedFactories(self):
- # Ignore all factories not implementing ISQLObjectIsolated
- for f in SQLObjectContainer._allowedFactories(self):
- implemented = zope.component.getFactoryInterfaces(f)
- if implemented.isOrExtends(ISQLObjectIsolated):
- yield f
- allowedFactories = deprecation.deprecated(allowedFactories,
- 'allowedFactories is deprecated and will be removed after sqlos 0.2'
- ' please use _getAllowedIISQLObjectUtilities instead.')
-
def _getAllowedIISQLObjectUtilities(self):
# Ignore all utilities not implementing ISQLObjectIsolated
for name, utility in SQLObjectContainer._getAllowedIISQLObjectUtilities(self):
From reebalazs at codespeak.net Sat Apr 22 11:38:13 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Sat Apr 22 11:38:14 2006
Subject: [z3-checkins] r26122 - z3/jsonserver/branch/merge/utils
Message-ID: <20060422093813.22ACE1008D@code0.codespeak.net>
Author: reebalazs
Date: Sat Apr 22 11:38:12 2006
New Revision: 26122
Added:
z3/jsonserver/branch/merge/utils/
Log:
create utils subdir
From reebalazs at codespeak.net Sat Apr 22 11:38:20 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Sat Apr 22 11:38:21 2006
Subject: [z3-checkins] r26123 - z3/jsonserver/branch/merge/utils
Message-ID: <20060422093820.6EC4310097@code0.codespeak.net>
Author: reebalazs
Date: Sat Apr 22 11:38:18 2006
New Revision: 26123
Added:
z3/jsonserver/branch/merge/utils/pyclient
- copied unchanged from r26122, z3/jsonserver/branch/zope2_test/pyclient.py
Log:
move file to utils
From reebalazs at codespeak.net Sat Apr 22 11:42:03 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Sat Apr 22 11:42:05 2006
Subject: [z3-checkins] r26125 - z3/jsonserver/branch/merge/utils
Message-ID: <20060422094203.DE93710098@code0.codespeak.net>
Author: reebalazs
Date: Sat Apr 22 11:42:02 2006
New Revision: 26125
Modified:
z3/jsonserver/branch/merge/utils/pyclient
Log:
Add comment to pyclient
Modified: z3/jsonserver/branch/merge/utils/pyclient
==============================================================================
--- z3/jsonserver/branch/merge/utils/pyclient (original)
+++ z3/jsonserver/branch/merge/utils/pyclient Sat Apr 22 11:42:02 2006
@@ -1,15 +1,25 @@
+#! /usr/bin/python
'''\
A python client for jsonserver.
-This is a separate file that is not needed for jsonserver to work.
+This is a separate utility that is not needed for jsonserver to work.
It can be used to
- test json components from the command line
- create a standalone python json-rpc client.
-This file needs to import minjson.py, it uses nothing else
-from the server.
+This utility will only work if the following packages are
+importable from python:
+
+ minjson
+ zope.component
+ zope.interface
+
+Since neither minjson nor the zope component architecture
+are distributed as standalone at the moment,
+you have to arrange this yourself (e.g. symlinking to
+site-packages)
'''
import urllib2
From reebalazs at codespeak.net Sat Apr 22 11:47:05 2006
From: reebalazs at codespeak.net (reebalazs@codespeak.net)
Date: Sat Apr 22 11:47:08 2006
Subject: [z3-checkins] r26126 - z3/jsonserver/branch/merge/utils
Message-ID: <20060422094705.EDBAD1009B@code0.codespeak.net>
Author: reebalazs
Date: Sat Apr 22 11:47:04 2006
New Revision: 26126
Added:
z3/jsonserver/branch/merge/utils/tcpwatch (contents, props changed)
Log:
Include tcpwatch original version
Added: z3/jsonserver/branch/merge/utils/tcpwatch
==============================================================================
--- (empty file)
+++ z3/jsonserver/branch/merge/utils/tcpwatch Sat Apr 22 11:47:04 2006
@@ -0,0 +1,1485 @@
+#!/usr/bin/python
+
+#############################################################################
+#
+# Zope Public License (ZPL) Version 2.0
+# -----------------------------------------------
+#
+# This software is Copyright (c) Zope Corporation (tm) and
+# Contributors. All rights reserved.
+#
+# This license has been certified as open source. It has also
+# been designated as GPL compatible by the Free Software
+# Foundation (FSF).
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the
+# following conditions are met:
+#
+# 1. Redistributions in source code must retain the above
+# copyright notice, this list of conditions, and the following
+# disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions, and the following
+# disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. The name Zope Corporation (tm) must not be used to
+# endorse or promote products derived from this software
+# without prior written permission from Zope Corporation.
+#
+# 4. The right to distribute this software or to use it for
+# any purpose does not give you the right to use Servicemarks
+# (sm) or Trademarks (tm) of Zope Corporation. Use of them is
+# covered in a separate agreement (see
+# http://www.zope.com/Marks).
+#
+# 5. If any files are modified, you must cause the modified
+# files to carry prominent notices stating that you changed
+# the files and the date of any change.
+#
+# Disclaimer
+#
+# THIS SOFTWARE IS PROVIDED BY ZOPE CORPORATION ``AS IS''
+# AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+# NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+# NO EVENT SHALL ZOPE CORPORATION OR ITS CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+# DAMAGE.
+#
+#
+# This software consists of contributions made by Zope
+# Corporation and many individuals on behalf of Zope
+# Corporation. Specific attributions are listed in the
+# accompanying credits file.
+#
+#############################################################################
+"""TCPWatch, a connection forwarder and HTTP proxy for monitoring connections.
+
+Requires Python 2.1 or above.
+
+Revision information:
+$Id: tcpwatch.py,v 1.9 2004/06/17 00:03:46 shane Exp $
+"""
+
+from __future__ import nested_scopes
+
+VERSION = '1.3'
+COPYRIGHT = (
+ 'TCPWatch %s Copyright 2001 Shane Hathaway, Zope Corporation'
+ % VERSION)
+
+import sys
+import os
+import socket
+import asyncore
+import getopt
+from time import time, localtime
+
+
+RECV_BUFFER_SIZE = 8192
+show_cr = 0
+
+
+#############################################################################
+#
+# Connection forwarder
+#
+#############################################################################
+
+
+class ForwardingEndpoint (asyncore.dispatcher):
+ """A socket wrapper that accepts and generates stream messages.
+ """
+ _dests = ()
+
+ def __init__(self, conn=None):
+ self._outbuf = []
+ asyncore.dispatcher.__init__(self, conn)
+
+ def set_dests(self, dests):
+ """Sets the destination streams.
+ """
+ self._dests = dests
+
+ def write(self, data):
+ if data:
+ self._outbuf.append(data)
+ self.handle_write()
+
+ def readable(self):
+ return 1
+
+ def writable(self):
+ return not self.connected or len(self._outbuf) > 0
+
+ def handle_connect(self):
+ for d in self._dests:
+ d.write('') # A blank string means the socket just connected.
+
+ def received(self, data):
+ if data:
+ for d in self._dests:
+ d.write(data)
+
+ def handle_read(self):
+ data = self.recv(RECV_BUFFER_SIZE)
+ self.received(data)
+
+ def handle_write(self):
+ if not self.connected:
+ # Wait for a connection.
+ return
+ buf = self._outbuf
+ while buf:
+ data = buf.pop(0)
+ if data:
+ sent = self.send(data)
+ if sent < len(data):
+ buf.insert(0, data[sent:])
+ break
+
+ def handle_close (self):
+ dests = self._dests
+ self._dests = ()
+ for d in dests:
+ d.close()
+ self.close()
+
+ def handle_error(self):
+ t, v = sys.exc_info()[:2]
+ for d in self._dests:
+ if hasattr(d, 'error'):
+ d.error(t, v)
+ self.handle_close()
+
+
+
+class EndpointObserver:
+ """Sends stream events to a ConnectionObserver.
+
+ Streams don't distinguish sources, while ConnectionObservers do.
+ This adapter adds source information to stream events.
+ """
+
+ def __init__(self, obs, from_client):
+ self.obs = obs
+ self.from_client = from_client
+
+ def write(self, data):
+ if data:
+ self.obs.received(data, self.from_client)
+ else:
+ self.obs.connected(self.from_client)
+
+ def close(self):
+ self.obs.closed(self.from_client)
+
+ def error(self, t, v):
+ self.obs.error(self.from_client, t, v)
+
+
+
+class ForwardedConnectionInfo:
+ transaction = 1
+
+ def __init__(self, connection_number, client_addr, server_addr=None):
+ self.opened = time()
+ self.connection_number = connection_number
+ self.client_addr = client_addr
+ self.server_addr = server_addr
+
+ def dup(self):
+ return ForwardedConnectionInfo(self.connection_number,
+ self.client_addr,
+ self.server_addr)
+
+
+
+class ForwardingService (asyncore.dispatcher):
+
+ _counter = 0
+
+ def __init__(self, listen_host, listen_port, dest_host, dest_port,
+ ob