[Zope-Checkins] SVN: Zope/branches/publication-refactor/lib/python/ZPublisher/ Replace the ZPublisher.Publish.publish method with the

2006-04-20 Thread Michael Kerrin
Log message for revision 67177:
  Replace the ZPublisher.Publish.publish method with the
  Zope3 equivalent zope.publisher.publish. This way the
  publish_module_standard and similar are just wrappers
  around the Zope3 method that sets up the request correctly
  and performs some other stuff I don't quite follow.
  
  There is still a lot of work left, for example 11 tests are
  still failing but we can get back to these later.
  

Changed:
  U   Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py
  U   Zope/branches/publication-refactor/lib/python/ZPublisher/BaseResponse.py
  U   Zope/branches/publication-refactor/lib/python/ZPublisher/HTTPResponse.py
  U   Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py
  U   Zope/branches/publication-refactor/lib/python/ZPublisher/Publish.py
  U   Zope/branches/publication-refactor/lib/python/ZPublisher/Test.py
  U   
Zope/branches/publication-refactor/lib/python/ZPublisher/tests/testPublish.py

-=-
Modified: 
Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py
===
--- Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py 
2006-04-20 15:19:17 UTC (rev 67176)
+++ Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py 
2006-04-20 16:18:16 UTC (rev 67177)
@@ -249,10 +249,6 @@
 if not path and not method:
 return response.forbiddenError(self['URL'])
 
-if self.publication.root is not object:
-self.publication.root = object
-
-object = self.publication.getApplication(self)
 roles = getRoles(None, None, object, UNSPECIFIED_ROLES)
 parents.append(object)
 

Modified: 
Zope/branches/publication-refactor/lib/python/ZPublisher/BaseResponse.py
===
--- Zope/branches/publication-refactor/lib/python/ZPublisher/BaseResponse.py
2006-04-20 15:19:17 UTC (rev 67176)
+++ Zope/branches/publication-refactor/lib/python/ZPublisher/BaseResponse.py
2006-04-20 16:18:16 UTC (rev 67177)
@@ -54,6 +54,10 @@
 Output the response body
 self.stdout.write(str(self))
 
+def setResult(self, result):
+IResponse
+self.setBody(result)
+
 def setBody(self, body):
 self.body = body
 

Modified: 
Zope/branches/publication-refactor/lib/python/ZPublisher/HTTPResponse.py
===
--- Zope/branches/publication-refactor/lib/python/ZPublisher/HTTPResponse.py
2006-04-20 15:19:17 UTC (rev 67176)
+++ Zope/branches/publication-refactor/lib/python/ZPublisher/HTTPResponse.py
2006-04-20 16:18:16 UTC (rev 67177)
@@ -180,6 +180,10 @@
 self.stdout = stdout
 self.stderr = stderr
 
+def internalError(self):
+'See IPublisherResponse'
+self.setStatus(500, uThe engines can't take any more, Jim!)
+
 def retry(self):
 Return a response object to be used in a retry attempt
 

Modified: 
Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py
===
--- Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 
2006-04-20 15:19:17 UTC (rev 67176)
+++ Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 
2006-04-20 16:18:16 UTC (rev 67177)
@@ -15,12 +15,14 @@
 import re
 import sys
 import transaction
+import types
 
 from zope.event import notify
 from zope.component import queryUtility
 from zope.interface import implements
 from zope.publisher.interfaces import IRequest, IPublication
 from zope.publisher.interfaces import NotFound, IPublicationRequest
+import zope.publisher.interfaces
 from zope.publisher.browser import BrowserRequest
 from zope.publisher.browser import BrowserResponse
 from zope.publisher.http import StrResult
@@ -35,14 +37,42 @@
 from ZPublisher.mapply import mapply
 from ZPublisher.BaseRequest import RequestContainer
 
+from ZPublisher.HTTPRequest import HTTPRequest
+from ZPublisher.HTTPResponse import HTTPResponse
+from cStringIO import StringIO
+import traceback
+from zope.publisher.http import status_reasons, DirectResult
+from zope.publisher.interfaces import IPublisherRequest
+from zope import component
+
+
 _marker = object()
 
+class Zope3HTTPRequestTraverser(object):
+implements(IPublisherRequest)
+
+def __init__(self, request):
+self.request = request
+
+def traverse(self, object):
+path = self.request.get('PATH_INFO')
+self.request['PARENTS'] = [object]
+
+return self.request.traverse(path, self.request.response,
+ self.request.publication.validated_hook)
+
+## XXX - Five declares that HTTPRequest implements IPublisherRequest
+## but in fact it doesn't, the traverse method API is all wrong.
+## 

[Zope-Checkins] SVN: Zope/branches/publication-refactor/lib/python/zope/ update the externals on this branch in order to get

2006-04-20 Thread Michael Kerrin
Log message for revision 67184:
  update the externals on this branch in order to get
  the small change to the zope.publisher.publish module.
  

Changed:
  _U  Zope/branches/publication-refactor/lib/python/zope/

-=-

Property changes on: Zope/branches/publication-refactor/lib/python/zope
___
Name: svn:externals
   - app  -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/app
cachedescriptors -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/cachedescriptors
component-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/component
configuration-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/configuration
documenttemplate -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/documenttemplate
event-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/event
exceptions   -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/exceptions
hookable -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/hookable
i18n -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/i18n
i18nmessageid-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/i18nmessageid
interface-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/interface
modulealias  -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/modulealias
pagetemplate -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/pagetemplate
proxy-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/proxy
publisher-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/publisher
schema   -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/schema
security -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/security
server   -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/server
structuredtext   -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/structuredtext
tal  -r 40688 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/tal
tales-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/tales
testing  -r 39830 
svn://svn.zope.org/repos/main/zope.testing/trunk/src/zope/testing
thread   -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/thread
deprecation  -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/deprecation
dottedname   -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/dottedname
formlib  -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/formlib
index-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/index
testbrowser  -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/testbrowser

   + app  -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/app
cachedescriptors -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/cachedescriptors
component-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/component
configuration-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/configuration
documenttemplate -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/documenttemplate
event-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/event
exceptions   -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/exceptions
hookable -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/hookable
i18n -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/i18n
i18nmessageid-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/i18nmessageid
interface-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/interface
modulealias  -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/modulealias
pagetemplate -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/pagetemplate
proxy-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/proxy
publisher
svn://svn.zope.org/repos/main/Zope3/branches/publication-refactor2/src/zope/publisher
schema   -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/schema
security -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/security
server   -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/server
structuredtext   -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/structuredtext
tal  -r 40688 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/tal
tales-r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/tales
testing  -r 39830 
svn://svn.zope.org/repos/main/zope.testing/trunk/src/zope/testing
thread   -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/thread
deprecation  -r 40688 
svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/deprecation
dottedname   -r 

[Zope-Checkins] SVN: Products.Five/branches/1.2/ Merge regebro's r66790 from 1.3 branch and bump version number for next

2006-04-20 Thread Philipp von Weitershausen
Log message for revision 67185:
  Merge regebro's r66790 from 1.3 branch and bump version number for next
  1.2.x release.
  

Changed:
  U   Products.Five/branches/1.2/CHANGES.txt
  U   Products.Five/branches/1.2/i18n.py
  U   Products.Five/branches/1.2/version.txt

-=-
Modified: Products.Five/branches/1.2/CHANGES.txt
===
--- Products.Five/branches/1.2/CHANGES.txt  2006-04-20 17:51:42 UTC (rev 
67184)
+++ Products.Five/branches/1.2/CHANGES.txt  2006-04-20 18:06:55 UTC (rev 
67185)
@@ -2,6 +2,12 @@
 Five Changes
 
 
+Five 1.2.4 (XXX)
+
+
+* Made sure LocalizerLanguages class normalized language codes to
+  xx-yy, instead of xx_YY or xx-YY.
+
 Five 1.2.3 (2006-03-31)
 ===
 

Modified: Products.Five/branches/1.2/i18n.py
===
--- Products.Five/branches/1.2/i18n.py  2006-04-20 17:51:42 UTC (rev 67184)
+++ Products.Five/branches/1.2/i18n.py  2006-04-20 18:06:55 UTC (rev 67185)
@@ -20,6 +20,7 @@
 from zope.i18n import interpolate
 from zope.i18n.interfaces import ITranslationDomain, IUserPreferredLanguages
 from zope.i18nmessageid import MessageID
+from zope.i18n.negotiator import normalize_lang
 from zope.app import zapi
 from zope.publisher.browser import BrowserLanguages
 
@@ -68,7 +69,9 @@
 accept_language = self.context.AcceptLanguage
 langs = []
 for lang, node in accept_language.children.items():
-langs.append((node.get_quality(), lang))
+# Localizer may use xx_YY and xx-YY as language codes,
+# while Zope expect xx-yy only, so we normalize the code here.
+langs.append((node.get_quality(), normalize_lang(lang)))
 langs.extend([(n.get_quality(), l) for l, n
   in node.children.items()])
 langs.sort()

Modified: Products.Five/branches/1.2/version.txt
===
--- Products.Five/branches/1.2/version.txt  2006-04-20 17:51:42 UTC (rev 
67184)
+++ Products.Five/branches/1.2/version.txt  2006-04-20 18:06:55 UTC (rev 
67185)
@@ -1 +1 @@
-Five 1.2.3
+Five 1.2.4

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Products.Five/branches/1.2/ Fix traversable bug reported by Jordan Baker (http://codespeak.net/pipermail/z3-five/2006q2/001309.html)

2006-04-20 Thread Philipp von Weitershausen
Log message for revision 67186:
  Fix traversable bug reported by Jordan Baker 
(http://codespeak.net/pipermail/z3-five/2006q2/001309.html)
  

Changed:
  U   Products.Five/branches/1.2/browser/tests/test_traversable.py
  U   Products.Five/branches/1.2/traversable.py

-=-
Modified: Products.Five/branches/1.2/browser/tests/test_traversable.py
===
--- Products.Five/branches/1.2/browser/tests/test_traversable.py
2006-04-20 18:06:55 UTC (rev 67185)
+++ Products.Five/branches/1.2/browser/tests/test_traversable.py
2006-04-20 21:35:51 UTC (rev 67186)
@@ -207,8 +207,8 @@
   ...xmlns:meta=http://namespaces.zope.org/meta;
   ...xmlns:browser=http://namespaces.zope.org/browser;
   ...xmlns:five=http://namespaces.zope.org/five;
-  ... !-- make the zope2.Public permission work --
-  ... meta:redefinePermission from=zope2.Public to=zope.Public /
+  ...   !-- make the zope2.Public permission work --
+  ...   meta:redefinePermission from=zope2.Public to=zope.Public /
   ...   browser:page
   ...   name=eagle
   ...   for=OFS.interfaces.IObjectManager
@@ -216,6 +216,7 @@
   ...   attribute=eagle
   ...   permission=zope2.Public
   ...   /
+  ...   five:traversable class=OFS.Application.Application/
   ... /configure'''
import Products.Five
from Products.Five import zcml
@@ -252,13 +253,32 @@
   The eagle has landed
 
 
+Some weird implementations of __bobo_traverse__, like the one
+found in OFS.Application, raise NotFound.  Five still knows how to
+deal with this, hence views work there too:
+
+   print http(r'''
+  ... GET /eagle HTTP/1.1
+  ...
+  ... ''')
+  HTTP/1.1 200 OK
+  ...
+  The eagle has landed
+
+   print http(r'''
+  ... GET /@@eagle HTTP/1.1
+  ...
+  ... ''')
+  HTTP/1.1 200 OK
+  ...
+  The eagle has landed
+
 Clean up:
 
from zope.app.tests.placelesssetup import tearDown
tearDown()
 
 
-
 def test_suite():
 from Testing.ZopeTestCase import FunctionalDocTestSuite
 return FunctionalDocTestSuite()

Modified: Products.Five/branches/1.2/traversable.py
===
--- Products.Five/branches/1.2/traversable.py   2006-04-20 18:06:55 UTC (rev 
67185)
+++ Products.Five/branches/1.2/traversable.py   2006-04-20 21:35:51 UTC (rev 
67186)
@@ -63,6 +63,14 @@
 return self.__fallback_traverse__(REQUEST, name)
 except (AttributeError, KeyError):
 pass
+except NotFound:
+# OFS.Application.__bobo_traverse__ calls
+# REQUEST.RESPONSE.notFoundError which sets the HTTP
+# status code to 404
+try:
+REQUEST.RESPONSE.setStatus(200)
+except AttributeError:
+pass
 else:
 try:
 return getattr(self, name)

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Products.Five/branches/1.0/traversable.py Merge r67186 from 1.2 branch:

2006-04-20 Thread Philipp von Weitershausen
Log message for revision 67187:
  Merge r67186 from 1.2 branch:
Fix traversable bug reported by Jordan Baker 
(http://codespeak.net/pipermail/z3-five/2006q2/001309.html)
  

Changed:
  U   Products.Five/branches/1.0/traversable.py

-=-
Modified: Products.Five/branches/1.0/traversable.py
===
--- Products.Five/branches/1.0/traversable.py   2006-04-20 21:35:51 UTC (rev 
67186)
+++ Products.Five/branches/1.0/traversable.py   2006-04-20 21:40:52 UTC (rev 
67187)
@@ -63,6 +63,14 @@
 return self.__fallback_traverse__(REQUEST, name)
 except (AttributeError, KeyError):
 pass
+except NotFound:
+# OFS.Application.__bobo_traverse__ calls
+# REQUEST.RESPONSE.notFoundError which sets the HTTP
+# status code to 404
+try:
+REQUEST.RESPONSE.setStatus(200)
+except AttributeError:
+pass
 else:
 try:
 return getattr(self, name)

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Products.Five/branches/1.3/version.txt bump version number

2006-04-20 Thread Philipp von Weitershausen
Log message for revision 67188:
  bump version number
  

Changed:
  U   Products.Five/branches/1.3/version.txt

-=-
Modified: Products.Five/branches/1.3/version.txt
===
--- Products.Five/branches/1.3/version.txt  2006-04-20 21:40:52 UTC (rev 
67187)
+++ Products.Five/branches/1.3/version.txt  2006-04-20 21:42:37 UTC (rev 
67188)
@@ -1 +1 @@
-Five 1.3.4
+Five 1.3.5

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Products.Five/branches/1.2/CHANGES.txt don't forget changes

2006-04-20 Thread Philipp von Weitershausen
Log message for revision 67189:
  don't forget changes
  

Changed:
  U   Products.Five/branches/1.2/CHANGES.txt

-=-
Modified: Products.Five/branches/1.2/CHANGES.txt
===
--- Products.Five/branches/1.2/CHANGES.txt  2006-04-20 21:42:37 UTC (rev 
67188)
+++ Products.Five/branches/1.2/CHANGES.txt  2006-04-20 21:44:37 UTC (rev 
67189)
@@ -5,9 +5,15 @@
 Five 1.2.4 (XXX)
 
 
+Bugfixes
+
+
 * Made sure LocalizerLanguages class normalized language codes to
   xx-yy, instead of xx_YY or xx-YY.
 
+* Fixed a problem with the new traversal look-up order and the root
+  object (OFS.Application.Application).
+
 Five 1.2.3 (2006-03-31)
 ===
 

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Products.Five/branches/1.4/version.txt bump version number

2006-04-20 Thread Philipp von Weitershausen
Log message for revision 67191:
  bump version number
  

Changed:
  U   Products.Five/branches/1.4/version.txt

-=-
Modified: Products.Five/branches/1.4/version.txt
===
--- Products.Five/branches/1.4/version.txt  2006-04-20 21:48:33 UTC (rev 
67190)
+++ Products.Five/branches/1.4/version.txt  2006-04-20 21:51:33 UTC (rev 
67191)
@@ -1 +1 @@
-Five 1.4b
+Five 1.4

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Products.Five/branches/1.4/ Merge r67186 from 1.2 branch:

2006-04-20 Thread Philipp von Weitershausen
Log message for revision 67192:
  Merge r67186 from 1.2 branch:
Fix traversable bug reported by Jordan Baker 
(http://codespeak.net/pipermail/z3-five/2006q2/001309.html)
  

Changed:
  U   Products.Five/branches/1.4/CHANGES.txt
  U   Products.Five/branches/1.4/browser/tests/test_traversable.py
  U   Products.Five/branches/1.4/traversable.py

-=-
Modified: Products.Five/branches/1.4/CHANGES.txt
===
--- Products.Five/branches/1.4/CHANGES.txt  2006-04-20 21:51:33 UTC (rev 
67191)
+++ Products.Five/branches/1.4/CHANGES.txt  2006-04-20 22:02:15 UTC (rev 
67192)
@@ -2,12 +2,18 @@
 Five Changes
 
 
-Five 1.4.0 (unreleased)
-===
+Five 1.4 (unreleased)
+=
 
-* Made sure LocalizerLanguages class normalized language codes to xx-yy, 
instead of
-  xx_YY or xx-YY.
+Bugfixes
+
 
+* Made sure LocalizerLanguages class normalized language codes to
+  xx-yy, instead of xx_YY or xx-YY.
+
+* Fixed a problem with the new traversal look-up order and the root
+  object (OFS.Application.Application).
+
 Five 1.4b (2006-03-31)
 ==
 

Modified: Products.Five/branches/1.4/browser/tests/test_traversable.py
===
--- Products.Five/branches/1.4/browser/tests/test_traversable.py
2006-04-20 21:51:33 UTC (rev 67191)
+++ Products.Five/branches/1.4/browser/tests/test_traversable.py
2006-04-20 22:02:15 UTC (rev 67192)
@@ -207,8 +207,8 @@
   ...xmlns:meta=http://namespaces.zope.org/meta;
   ...xmlns:browser=http://namespaces.zope.org/browser;
   ...xmlns:five=http://namespaces.zope.org/five;
-  ... !-- make the zope2.Public permission work --
-  ... meta:redefinePermission from=zope2.Public to=zope.Public /
+  ...   !-- make the zope2.Public permission work --
+  ...   meta:redefinePermission from=zope2.Public to=zope.Public /
   ...   browser:page
   ...   name=eagle
   ...   for=OFS.interfaces.IObjectManager
@@ -216,6 +216,7 @@
   ...   attribute=eagle
   ...   permission=zope2.Public
   ...   /
+  ...   five:traversable class=OFS.Application.Application/
   ... /configure'''
import Products.Five
from Products.Five import zcml
@@ -252,13 +253,32 @@
   The eagle has landed
 
 
+Some weird implementations of __bobo_traverse__, like the one
+found in OFS.Application, raise NotFound.  Five still knows how to
+deal with this, hence views work there too:
+
+   print http(r'''
+  ... GET /eagle HTTP/1.1
+  ...
+  ... ''')
+  HTTP/1.1 200 OK
+  ...
+  The eagle has landed
+
+   print http(r'''
+  ... GET /@@eagle HTTP/1.1
+  ...
+  ... ''')
+  HTTP/1.1 200 OK
+  ...
+  The eagle has landed
+
 Clean up:
 
from zope.app.testing.placelesssetup import tearDown
tearDown()
 
 
-
 def test_suite():
 from Testing.ZopeTestCase import FunctionalDocTestSuite
 return FunctionalDocTestSuite()

Modified: Products.Five/branches/1.4/traversable.py
===
--- Products.Five/branches/1.4/traversable.py   2006-04-20 21:51:33 UTC (rev 
67191)
+++ Products.Five/branches/1.4/traversable.py   2006-04-20 22:02:15 UTC (rev 
67192)
@@ -63,6 +63,14 @@
 return self.__fallback_traverse__(REQUEST, name)
 except (AttributeError, KeyError):
 pass
+except NotFound:
+# OFS.Application.__bobo_traverse__ calls
+# REQUEST.RESPONSE.notFoundError which sets the HTTP
+# status code to 404
+try:
+REQUEST.RESPONSE.setStatus(200)
+except AttributeError:
+pass
 else:
 try:
 return getattr(self, name)

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/branches/2.9/ Collector #2072: Applied patch to fix problem with overly restrictive __bobo_traverse__ security and tests.

2006-04-20 Thread Alec Mitchell
Log message for revision 67194:
  Collector #2072: Applied patch to fix problem with overly restrictive 
__bobo_traverse__ security and tests.
  

Changed:
  U   Zope/branches/2.9/doc/CHANGES.txt
  U   Zope/branches/2.9/lib/python/OFS/Traversable.py
  U   Zope/branches/2.9/lib/python/OFS/tests/testTraverse.py

-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===
--- Zope/branches/2.9/doc/CHANGES.txt   2006-04-20 22:07:12 UTC (rev 67193)
+++ Zope/branches/2.9/doc/CHANGES.txt   2006-04-21 00:26:11 UTC (rev 67194)
@@ -17,6 +17,9 @@
   Zope 2.9.3 (UNRELEASED)
 
Bugs fixed
+
+  - Collector #2072: Applied patch to fix problem with overly restrictive
+__bobo_traverse__ security and tests.
   
   - Added missing Zope 3 packages: zope.app.intid, zope.app.keyreference, 
 zope.app.session, zope.contentprovider, zope.viewlet  

Modified: Zope/branches/2.9/lib/python/OFS/Traversable.py
===
--- Zope/branches/2.9/lib/python/OFS/Traversable.py 2006-04-20 22:07:12 UTC 
(rev 67193)
+++ Zope/branches/2.9/lib/python/OFS/Traversable.py 2006-04-21 00:26:11 UTC 
(rev 67194)
@@ -201,8 +201,20 @@
 else:
 # Can't determine container
 container = _none
-if not securityManager.validate(
-obj, container, name, next):
+try:
+validated = securityManager.validate(
+   obj, container, name, next)
+except Unauthorized:
+# If next is a simple unwrapped property, it's
+# parentage is indeterminate, but it may have been
+# acquired safely.  In this case validate will
+# raise an error, and we can explicitly check that
+# our value was acquired safely.
+validated = 0
+if container is _none and \
+   guarded_getattr(obj, name, marker) is next:
+validated = 1
+if not validated:
 raise Unauthorized, name
 else:
 if restricted:

Modified: Zope/branches/2.9/lib/python/OFS/tests/testTraverse.py
===
--- Zope/branches/2.9/lib/python/OFS/tests/testTraverse.py  2006-04-20 
22:07:12 UTC (rev 67193)
+++ Zope/branches/2.9/lib/python/OFS/tests/testTraverse.py  2006-04-21 
00:26:11 UTC (rev 67194)
@@ -22,6 +22,7 @@
 import transaction
 import ZODB, Acquisition, transaction
 from AccessControl import SecurityManager, Unauthorized
+from AccessControl.Permissions import access_contents_information
 from AccessControl.SecurityManagement import newSecurityManager
 from AccessControl.SecurityManagement import noSecurityManager
 from Acquisition import aq_base
@@ -102,6 +103,16 @@
 bb_status = 'screechy'
 
 
+class BoboTraversableWithAcquisition(SimpleItem):
+
+   A BoboTraversable class which may use acquisition to find objects.
+   This is similar to how the __bobo_traverse__ added by Five behaves).
+
+
+def __bobo_traverse__(self, request, name):
+return Acquisition.aq_get(self, name)
+
+
 def makeConnection():
 import ZODB
 from ZODB.DemoStorage import DemoStorage
@@ -235,6 +246,58 @@
 self.failUnless(
 bb.restrictedTraverse('manufactured') is 42)
 
+def testBoboTraverseToAcquiredObject(self):
+# Verify it's possible to use a __bobo_traverse__ which retrieves
+# objects by acquisition
+noSecurityManager()
+SecurityManager.setSecurityPolicy( self.oldPolicy )
+bb = BoboTraversableWithAcquisition()
+bb = bb.__of__(self.root)
+self.assertEqual(
+bb.restrictedTraverse('folder1'), bb.folder1)
+self.assertEqual(
+Acquisition.aq_inner(bb.restrictedTraverse('folder1')),
+self.root.folder1)
+
+def testBoboTraverseToAcquiredProtectedObject(self):
+# Verify it's possible to use a __bobo_traverse__ which retrieves
+# objects by acquisition
+noSecurityManager()
+SecurityManager.setSecurityPolicy( self.oldPolicy )
+folder = self.root.folder1
+# restrict the ability to access the retrieved object itself
+folder.manage_permission(access_contents_information, [], 0)
+bb = BoboTraversableWithAcquisition()
+bb = bb.__of__(self.root)
+self.failUnlessRaises(Unauthorized,
+  self.root.folder1.restrictedTraverse, 'folder1')
+
+def testBoboTraverseToAcquiredAttribute(self):
+

[Zope-Checkins] SVN: Zope/trunk/lib/python/OFS/ Merge fix for #2072 into trunk

2006-04-20 Thread Alec Mitchell
Log message for revision 67196:
  Merge fix for #2072 into trunk
  

Changed:
  U   Zope/trunk/lib/python/OFS/Traversable.py
  U   Zope/trunk/lib/python/OFS/tests/testTraverse.py

-=-
Modified: Zope/trunk/lib/python/OFS/Traversable.py
===
--- Zope/trunk/lib/python/OFS/Traversable.py2006-04-21 00:31:16 UTC (rev 
67195)
+++ Zope/trunk/lib/python/OFS/Traversable.py2006-04-21 00:34:55 UTC (rev 
67196)
@@ -206,8 +206,20 @@
 else:
 # Can't determine container
 container = _none
-if not securityManager.validate(
-obj, container, name, next):
+try:
+validated = securityManager.validate(
+   obj, container, name, next)
+except Unauthorized:
+# If next is a simple unwrapped property, it's
+# parentage is indeterminate, but it may have been
+# acquired safely.  In this case validate will
+# raise an error, and we can explicitly check that
+# our value was acquired safely.
+validated = 0
+if container is _none and \
+   guarded_getattr(obj, name, marker) is next:
+validated = 1
+if not validated:
 raise Unauthorized, name
 else:
 if restricted:

Modified: Zope/trunk/lib/python/OFS/tests/testTraverse.py
===
--- Zope/trunk/lib/python/OFS/tests/testTraverse.py 2006-04-21 00:31:16 UTC 
(rev 67195)
+++ Zope/trunk/lib/python/OFS/tests/testTraverse.py 2006-04-21 00:34:55 UTC 
(rev 67196)
@@ -22,6 +22,7 @@
 import transaction
 import ZODB, Acquisition, transaction
 from AccessControl import SecurityManager, Unauthorized
+from AccessControl.Permissions import access_contents_information
 from AccessControl.SecurityManagement import newSecurityManager
 from AccessControl.SecurityManagement import noSecurityManager
 from Acquisition import aq_base
@@ -102,6 +103,16 @@
 bb_status = 'screechy'
 
 
+class BoboTraversableWithAcquisition(SimpleItem):
+
+   A BoboTraversable class which may use acquisition to find objects.
+   This is similar to how the __bobo_traverse__ added by Five behaves).
+
+
+def __bobo_traverse__(self, request, name):
+return Acquisition.aq_get(self, name)
+
+
 def makeConnection():
 import ZODB
 from ZODB.DemoStorage import DemoStorage
@@ -235,6 +246,58 @@
 self.failUnless(
 bb.restrictedTraverse('manufactured') is 42)
 
+def testBoboTraverseToAcquiredObject(self):
+# Verify it's possible to use a __bobo_traverse__ which retrieves
+# objects by acquisition
+noSecurityManager()
+SecurityManager.setSecurityPolicy( self.oldPolicy )
+bb = BoboTraversableWithAcquisition()
+bb = bb.__of__(self.root)
+self.assertEqual(
+bb.restrictedTraverse('folder1'), bb.folder1)
+self.assertEqual(
+Acquisition.aq_inner(bb.restrictedTraverse('folder1')),
+self.root.folder1)
+
+def testBoboTraverseToAcquiredProtectedObject(self):
+# Verify it's possible to use a __bobo_traverse__ which retrieves
+# objects by acquisition
+noSecurityManager()
+SecurityManager.setSecurityPolicy( self.oldPolicy )
+folder = self.root.folder1
+# restrict the ability to access the retrieved object itself
+folder.manage_permission(access_contents_information, [], 0)
+bb = BoboTraversableWithAcquisition()
+bb = bb.__of__(self.root)
+self.failUnlessRaises(Unauthorized,
+  self.root.folder1.restrictedTraverse, 'folder1')
+
+def testBoboTraverseToAcquiredAttribute(self):
+# Verify it's possible to use __bobo_traverse__ to an acquired
+# attribute
+noSecurityManager()
+SecurityManager.setSecurityPolicy( self.oldPolicy )
+folder = self.root.folder1
+folder.stuff = 'stuff here'
+bb = BoboTraversableWithAcquisition()
+bb = bb.__of__(folder)
+self.assertEqual(
+bb.restrictedTraverse('stuff'), 'stuff here')
+
+def testBoboTraverseToAcquiredProtectedAttribute(self):
+# Verify that using __bobo_traverse__ to get an acquired but
+# protected attribute results in Unauthorized
+noSecurityManager()
+SecurityManager.setSecurityPolicy( self.oldPolicy )
+folder = self.root.folder1
+# We protect the the attribute by restricting 

Re: [Zope-dev] Re: cvs.zope.org/Products - svn.zope.org?

2006-04-20 Thread Jens Vagelpohl

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Rocky, since this whole issue seems to have petered out, if you want  
to follow up with the respective product authors and have them  
contact me I'll get them moved. I just don't want to do that without  
having a consensus first.


jens


On 18 Apr 2006, at 11:44, Rocky Burt wrote:


As a Plone developer my favourite two products I'd like to see moved
would be:
  1) ExternalEditor
  2) Basket

'course I've had the discussion with chrism in the past about moving
Basket over...  Chris, what do you think?

- Rocky


On Tue, 2006-18-04 at 09:35 +0200, Jens Vagelpohl wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On 18 Apr 2006, at 08:30, Andreas Jung wrote:




--On 17. April 2006 16:25:10 +0200 Jens Vagelpohl
[EMAIL PROTECTED] wrote:

Wouldn't it make sense to migrate the complete Products hierarchy
from cvs.zope.org to svn.zope.org?


- -1 on migrating everything.

IMHO it would be better to identify those dependencies and
selectively
migrate products as needed. I'd volunteer to do the  migrations, I
have a
well-working test harness and migration scripts  for that purpose
on the
cvs.zope.org box.



We must distinguish between major community projects and private/
commercial projects. If you want to support both we might end up
having most of the stuff on svn.zope.org as well...


Have you looked at what's inside the Products folder on cvs.zope.org?
The important bits are already moved to SVN and then there's a whole
lot of old unmaintained stuff. Now that I looked at what's in there I
am even more against a wholesale move.

I'm assuming the reason you started this discussion is because you
had to fish something out of CVS. We could start by you identifying
what that was.

jens


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFERJbSRAx5nvEhZLIRAslrAJ4kDbIRw1/5l+yyc6j4x0fuWTCvYACdFISH
ORbGazbvlNa7OEdGvWFIByE=
=ribv
-END PGP SIGNATURE-
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


--
Rocky Burt
AdaptiveWave - Content Management as a Service
http://www.adaptivewave.com
Content Management Made Simple


___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFER+s5RAx5nvEhZLIRAopsAKCjtGP4GlDkwsKJvec8OBJhMfkEdgCdHFnB
ZSF1NyFxDZNGgRQ1yra5UR8=
=lP+F
-END PGP SIGNATURE-
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Traversal issue which affects Five

2006-04-20 Thread Dieter Maurer
Andreas Jung wrote at 2006-4-19 20:13 +0200:
--On 19. April 2006 18:38:05 +0200 Dieter Maurer [EMAIL PROTECTED] 
wrote:
 ...
 Do you accept it? ;-)

As release manager I don't have to dig into every problem. Patches + tests 
are of course accepted if there is some consensus that a proposed solution 
solves the open problem. But I don't have to care about the progress of 
every ongoing issue.

In this case, you may want to say something:

  I proposed the introduction of a new feature (__bobo_traverse__
  can tell the containing framework that it should use the default
  by raising a special exception).

  Someone feared that it cannot be added to a micro release as
  it is a new feature (and not only a bug fix).

  I argued that this new feature could be acceptable nevertheless,
  as it affects only components that know about it and use it.
  Otherwise, it is completely inoffensive.

Up to you to decide whether we may break the general rule
(no new features in micro releases) for features of this kind.

-- 
Dieter
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Re: Zope 2.9.3 release

2006-04-20 Thread Dieter Maurer
Tres Seaver wrote at 2006-4-19 15:30 -0400:
 ...
 Is Alec's traversal patch or Dieter's alternative being considered?

I'll note that I have a client who can't move forward from 2.9.1 to
2.9.3 because the changes to traversal semantics in that release break
every view lookup in the application (which was originally built on
2.8.x, and works fine on 2.9.1.

I would like to stress that my alternative does not change traversal
semantics but provides a way for knowing component's 
__bobo_traverse__ to tell the enclosing framework that
__bobo_traverse__ wants to use the default (and not do anything special).
Nothing is changed until a given component uses the feature.

-- 
Dieter
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Re: Zope 2.9.3 release

2006-04-20 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Dieter Maurer wrote:
 Tres Seaver wrote at 2006-4-19 15:30 -0400:
 
...

Is Alec's traversal patch or Dieter's alternative being considered?

I'll note that I have a client who can't move forward from 2.9.1 to
2.9.3 because the changes to traversal semantics in that release break
every view lookup in the application (which was originally built on
2.8.x, and works fine on 2.9.1.
 
 
 I would like to stress that my alternative does not change traversal
 semantics but provides a way for knowing component's 
 __bobo_traverse__ to tell the enclosing framework that
 __bobo_traverse__ wants to use the default (and not do anything special).
 Nothing is changed until a given component uses the feature.

I think the only impact on a site without software which used the
feature would be a tiny performance ding (having to wrap the
'__bobo_traverse__' call with a 'try:...except:' block).  OTOH, since
the contract for '__bobo_traverse__' is already insane (it *has* to
behave differently for publishing traversal than for normal
traversal), perhaps this change would reduce that insanity.

We need to tweak OFS.Traversable as well, given that it calls
'__bobo_traverse__' too.

+1 for including the patch in the release tree.


Tres.
- --
===
Tres Seaver  +1 202-558-7113  [EMAIL PROTECTED]
Palladion Software   Excellence by Designhttp://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFESD65+gerLs4ltQ4RAok2AJ46fLtHeKrVXhHLToawDHaPd3TpyACgkc36
ONg0Bshqri5i8EyQPbZXmbA=
=PB1B
-END PGP SIGNATURE-
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Gaute Amundsen
On Wednesday 19 April 2006 21:47, Tino Wildenhain wrote:
 Gaute Amundsen wrote:
  I want to retrieve the form fields in the order that they where submitted

 I'd say blaming zope for not reading the docs is somewhat arrogant .-)

I have been reading the docs for thee last 3 years my friend.
Could you please specify _which_ docs you are refering to here?
And what do they say that has a bearing on this?

snip
  To painstakingly alter them all to add this sequence ordering
  information, just because zope refuses to do as every other scripting
  system out there that I am aware of, is just out of the queston.

 Sorry, not getting the problem. Last time I saw the formholemail.pl,
 it used named form variables. You can easily access form variables
 by name in Zope.

Hm.. ok.
I have these 100 forms, all over the place. They live in user editable html.
To have to track down and alter them all is out of the question.
Yet the users expect the form fields to appear in their emails in the order 
that they put them on the page.

You seem to know formmail.pl, so you know that part :)

  My best Idea so far, is to use the apache proxying we use anyway, to run
  all requests to this url through a small perl or php proxy, that ads the
  ordering info to the POST.
 
  Does anyone have any better ideas?

 Yes. Give the description of your real problem. With more details please!
 Show example form as it is and where exactly your problem is.


How to retrieve the field order from the http post request.

I am afraid the problem is as abstract as that.
No clever workarounds on the single form level will do.

 I've yet to see a form problem zope cant handle (provided
 the information is actually sent by the browser)

 Regards
 Tino

Glad to hear it.

Tres Seaver told me that zope uses cgi.py
Does that mean that I could override dict in that file, or just for 
FieldStorage, with something like the Ordered Dictionary described at 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
and request.form would keep the order?
Or better maybe just modify FieldStorage along similar lines?

Gaute

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Re: REQUEST.form variables order

2006-04-20 Thread Gaute Amundsen
On Wednesday 19 April 2006 21:26, Tres Seaver wrote:
 Gaute Amundsen wrote:
  I want to retrieve the form fields in the order that they where submitted
snip

 The answer isn't arrogant, and we aren't *preventing* you from gaining
 access to that information.  The implementation which we use for
 extracting the form data from the request is the standard Python
 'cgi.py' module:  it doesn't preserve that information, so we can't pass
 it on to you.  That we accept this state of affairs is a sign that we
 don't share your itch, not that we doubt you have it.

 Given that this is open source, you *can* modify ZPublisher such that it
 uses a different mechanism to parse the form data, and are free to
 submit back such a patch to be included in a future Zope release.


 Tres.

I was waiting for that. fix it yourself. 
Yes, I know. 
Maybe I should have said patronizing instedad...

Zope uses 'cgi.py', that is interesting.
Thank you.

The rest is, sorry to say it, redundant.

Gaute
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Permissions, files and folders

2006-04-20 Thread Stefan H. Holek
I recommend to install DocFinderTab. And there is something at http:// 
api.plone.org/ for those who like such things ;-)


Stefan


On 18. Apr 2006, at 13:21, Erik Billing wrote:


Is there any complete api reference avalible?


--
Anything that happens, happens.  --Douglas Adams


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Tino Wildenhain

Gaute Amundsen schrieb:

On Wednesday 19 April 2006 21:47, Tino Wildenhain wrote:


Gaute Amundsen wrote:


I want to retrieve the form fields in the order that they where submitted


I'd say blaming zope for not reading the docs is somewhat arrogant .-)



I have been reading the docs for thee last 3 years my friend.
Could you please specify _which_ docs you are refering to here?
And what do they say that has a bearing on this?


For example how to construct sane formulars? ;)

snip


To painstakingly alter them all to add this sequence ordering
information, just because zope refuses to do as every other scripting
system out there that I am aware of, is just out of the queston.


Sorry, not getting the problem. Last time I saw the formholemail.pl,
it used named form variables. You can easily access form variables
by name in Zope.



Hm.. ok.
I have these 100 forms, all over the place. They live in user editable html.


Bad concept, but there you are. I bet this isnt the only thing you
want to change while you go to an application server (like zope).


To have to track down and alter them all is out of the question.
Yet the users expect the form fields to appear in their emails in the order 
that they put them on the page.


Well now thats interesting. I see to: cc: subject: and body
elements and their respective form elements. What kind of
other order should be preserved? Its does not matter in which
order mime-headers appear (in fact you dont even see that
in most MUAs)


You seem to know formmail.pl, so you know that part :)


Not the field ordering part. What other elements exist which
need to preserve arbitrary ordering? (Beside the effect
if you have more then one to: oder more then one body
form element (same name) you get a list with ordering
preserved obviously.




My best Idea so far, is to use the apache proxying we use anyway, to run
all requests to this url through a small perl or php proxy, that ads the
ordering info to the POST.

Does anyone have any better ideas?


Yes. Give the description of your real problem. With more details please!
Show example form as it is and where exactly your problem is.




How to retrieve the field order from the http post request.


No, thats not your problem. Thats the solution you are seeking
to what you think is your problem :-) Maybe it is maybe not.
Please show us an example of the situation you are facing.
I believe there can be a simpler solution to it.

Regards
Tino Wildenhain
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Andrew Milton
+---[ Gaute Amundsen ]--
|
| Hm.. ok.
| I have these 100 forms, all over the place. They live in user editable html.
| To have to track down and alter them all is out of the question.
| Yet the users expect the form fields to appear in their emails in the order 
| that they put them on the page.

Render the page with the fields filled and convert to text and place in email.

-- 
Andrew Milton
[EMAIL PROTECTED]
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Gaute Amundsen
On Thursday 20 April 2006 12:09, Tino Wildenhain wrote:
 Gaute Amundsen schrieb:
  On Wednesday 19 April 2006 21:47, Tino Wildenhain wrote:
 Gaute Amundsen wrote:
 I want to retrieve the form fields in the order that they where
  submitted
 
 I'd say blaming zope for not reading the docs is somewhat arrogant .-)
 
  I have been reading the docs for thee last 3 years my friend.
  Could you please specify _which_ docs you are refering to here?
  And what do they say that has a bearing on this?

 For example how to construct sane formulars? ;)

Being didactic now eh? ;)
Well, yes, formularor is quite nice for example, 
but this is someone elses mess, and my job :(

snip
  Hm.. ok.
  I have these 100 forms, all over the place. They live in user editable
  html.

 Bad concept, but there you are. I bet this isnt the only thing you
 want to change while you go to an application server (like zope).

We have been on zope for years, we just wanted to tighten down the security 
after one rather nasty attack, and formmail.pl was the only cgi on the 
server. 

User editable forms the right way, now that is another story.
I think I have settled on a separate forms editor approach, but that is 
still in the future.

  To have to track down and alter them all is out of the question.
  Yet the users expect the form fields to appear in their emails in the
  order that they put them on the page.

 Well now thats interesting. I see to: cc: subject: and body
 elements and their respective form elements. What kind of
 other order should be preserved? Its does not matter in which
 order mime-headers appear (in fact you dont even see that
 in most MUAs)

You missunderstand again I'm afraid. I didn't think I was being that brief..

The order of the form elements that goes into mail headers is ofcourse 
irelevant. I'ts the rest of the form, you know name, adress, street, etc. 
that are the problem. 
It's a purely visual thing, but when you have a form with perhaps 50 fields, 
that the client has carefully grouped and ordered, they can get rather pissed 
if you try to tell them they can only have it in semi-random or alpabetic in 
their mail.

  You seem to know formmail.pl, so you know that part :)

 Not the field ordering part. What other elements exist which
 need to preserve arbitrary ordering? (Beside the effect
 if you have more then one to: oder more then one body
 form element (same name) you get a list with ordering
 preserved obviously.

 My best Idea so far, is to use the apache proxying we use anyway, to run
 all requests to this url through a small perl or php proxy, that ads the
 ordering info to the POST.
 
 Does anyone have any better ideas?
 
 Yes. Give the description of your real problem. With more details please!
 Show example form as it is and where exactly your problem is.
 
  How to retrieve the field order from the http post request.

 No, thats not your problem. Thats the solution you are seeking
 to what you think is your problem :-) Maybe it is maybe not.
 Please show us an example of the situation you are facing.
 I believe there can be a simpler solution to it.

 Regards
 Tino Wildenhain

A smiley or two helps, but now I would say you are bordering on arrogant.
What more do I have to explain to convince you that I understand what the 
problem is?

Gaute
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Gaute Amundsen
On Thursday 20 April 2006 12:15, Andrew Milton wrote:
 +---[ Gaute Amundsen ]--

 | Hm.. ok.
 | I have these 100 forms, all over the place. They live in user editable
 | html. To have to track down and alter them all is out of the question.
 | Yet the users expect the form fields to appear in their emails in the
 | order that they put them on the page.

 Render the page with the fields filled and convert to text and place in
 email.

Hm.. now that is an idea...

I would have to depend on referer I guess, but as long as it degraded 
gracefully..

But, why render the page, when I could just parse it to get the field order?
Fun with regexp, or dom :)

It would be a bit of overhead, but so would a php proxy, and the few high-use 
forms I can rewrite anyway.

I think we are onto something here :-D

Gaute

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Andrew Milton
+---[ Gaute Amundsen ]--
| On Thursday 20 April 2006 12:15, Andrew Milton wrote:
|  +---[ Gaute Amundsen ]--
| 
|  | Hm.. ok.
|  | I have these 100 forms, all over the place. They live in user editable
|  | html. To have to track down and alter them all is out of the question.
|  | Yet the users expect the form fields to appear in their emails in the
|  | order that they put them on the page.
| 
|  Render the page with the fields filled and convert to text and place in
|  email.
| 
| Hm.. now that is an idea...
| 
| I would have to depend on referer I guess, but as long as it degraded 
| gracefully..
| 
| But, why render the page, when I could just parse it to get the field order?
| Fun with regexp, or dom :)

Because you can just throw it at the ZPT or DTML engines, convert to text 
and as a side-effect you get something ready to put into the email?

If you want to write your own parser, feel free.

-- 
Andrew Milton
[EMAIL PROTECTED]
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Gaute Amundsen
On Thursday 20 April 2006 13:23, Andrew Milton wrote:
 +---[ Gaute Amundsen ]--

 | On Thursday 20 April 2006 12:15, Andrew Milton wrote:
 |  +---[ Gaute Amundsen ]--
snip
 | But, why render the page, when I could just parse it to get the field
 | order? Fun with regexp, or dom :)

 Because you can just throw it at the ZPT or DTML engines, convert to text
 and as a side-effect you get something ready to put into the email?

 If you want to write your own parser, feel free.

I should have suspected :)

Any hints to get me statred on the zpt version?

Gaute.
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Andrew Milton
+---[ Gaute Amundsen ]--
| On Thursday 20 April 2006 13:23, Andrew Milton wrote:
|  +---[ Gaute Amundsen ]--
| 
|  | On Thursday 20 April 2006 12:15, Andrew Milton wrote:
|  |  +---[ Gaute Amundsen ]--
| snip
|  | But, why render the page, when I could just parse it to get the field
|  | order? Fun with regexp, or dom :)
| 
|  Because you can just throw it at the ZPT or DTML engines, convert to text
|  and as a side-effect you get something ready to put into the email?
| 
|  If you want to write your own parser, feel free.
| 
| I should have suspected :)
| 
| Any hints to get me statred on the zpt version?

I don't know what you have now, so no not really.

PageTemplate can be imported from Products.PageTemplates
It as a write method that lets you put the html into it.

-- 
Andrew Milton
[EMAIL PROTECTED]
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Gaute Amundsen
On Thursday 20 April 2006 14:01, Andrew Milton wrote:
 +---[ Gaute Amundsen ]--

 | On Thursday 20 April 2006 13:23, Andrew Milton wrote:
 |  +---[ Gaute Amundsen ]--
 | 
 |  | On Thursday 20 April 2006 12:15, Andrew Milton wrote:
 |  |  +---[ Gaute Amundsen ]--
 |
 | snip
 |
 |  | But, why render the page, when I could just parse it to get the field
 |  | order? Fun with regexp, or dom :)
 | 
 |  Because you can just throw it at the ZPT or DTML engines, convert to
 |  text and as a side-effect you get something ready to put into the
 |  email?
 | 
 |  If you want to write your own parser, feel free.
 |
 | I should have suspected :)
 |
 | Any hints to get me statred on the zpt version?

 I don't know what you have now, so no not really.

 PageTemplate can be imported from Products.PageTemplates
 It as a write method that lets you put the html into it.

Thanks.
I will get back to the list when I am done, but it may not happen in a few 
days.

Gaute.
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] zope 2.8.5 becomes unresponsive.

2006-04-20 Thread Erik Myllymaki

Environment is RHEL 3, Zope v2.8.5 (Python 2.3.5).

Every couple of days the zope instance will become unresponsive and require a 
restart. ZMI is inaccessible at these times so I have to do run service 
my_zope_service restart in the usual redhat way.


There is nothing in the logs, and if I do service y_zope_service status I am 
told program running; pid=22671


This is a service under very light load.

I viewed the chanelog for v2.8.6 and didn't see any changes that address this, 
and for various reasons I do not want to move into the v2.9.x builds.


Any guidance appreciated.
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] zope 2.8.5 becomes unresponsive.

2006-04-20 Thread Paul Winkler
On Thu, Apr 20, 2006 at 05:58:29AM -0700, Erik Myllymaki wrote:
 Environment is RHEL 3, Zope v2.8.5 (Python 2.3.5).
 
 Every couple of days the zope instance will become unresponsive and require 
 a restart. ZMI is inaccessible at these times so I have to do run service 
 my_zope_service restart in the usual redhat way.
 
 There is nothing in the logs, and if I do service y_zope_service status I 
 am told program running; pid=22671
 
 This is a service under very light load.
 
 I viewed the chanelog for v2.8.6 and didn't see any changes that address 
 this, and for various reasons I do not want to move into the v2.9.x builds.
 
 Any guidance appreciated.

google for two things:
zope deadlock debugger
debug spinning zope

-- 

Paul Winkler
http://www.slinkp.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Tino Wildenhain

Gaute Amundsen schrieb:
...
The order of the form elements that goes into mail headers is ofcourse 
irelevant. I'ts the rest of the form, you know name, adress, street, etc. 
that are the problem. 
It's a purely visual thing, but when you have a form with perhaps 50 fields, 
that the client has carefully grouped and ordered, they can get rather pissed 
if you try to tell them they can only have it in semi-random or alpabetic in 
their mail.

...

A smiley or two helps, but now I would say you are bordering on arrogant.
What more do I have to explain to convince you that I understand what the 
problem is?


We would have saved time if you provided the very usefull information
first :-)

Now you are building some kind of table/list with
form-field-name: form-field-value  - am I right?

how is it supposed to handle checkboxes, radiobuttons
and select fields?

One possible workaround, if you dont want to touch
ZPublishers form handling would be to run a script
to not only update the forms target (formmail.pl - zopeform)
but split every form element from
input type=text name=foo value= /

into

input type=hidden name=body.name:records value=foo/
input type=text name=body.value:records value= /

which you easily get as list of name/value pairs in
the form variable body.

You can even make this transformation any time a user edits
her HTML source - save the users source in a property and
transform this source via some regex or HTML parser
to what you really want here.

Moderate work and you can even add some sanity checks :-)

If you can provide some typical samples of the HTML you
are facing I believe you even can get help with the
transformation script.

Regards
Tino
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Python Generators and Zope question

2006-04-20 Thread Palermo, Tom



All,

I have a site that uses 
CookieCrumbler for user login. I need to track how many incorrectlogin 
attempts a user makes. I am trying to use a python generator to do this but it 
makes Zope hang when I try to do an invalid login (eg. no password or incorrect 
password). Here's a snippet:

def 
make_counter(x): while 
1: yield 
x x = x + 
1

 counter = 
make_counter(1)

 
security.declarePublic('getUnauthorizedURL') def 
getUnauthorizedURL(self): 
''' Redirects to the login 
page. 
''' req = 
self.REQUEST resp = 
req['RESPONSE'] attempt = 
getattr(req, '_cookie_auth', 
ATTEMPT_NONE) if attempt == 
ATTEMPT_NONE: 
# An anonymous user was denied access to 
something. 
page_id = 
self.auto_login_page 
retry = '' elif attempt == 
ATTEMPT_LOGIN: 
# The login attempt failed. Try 
again. 
page_id = 
self.auto_login_page 
#retry = 
'1' retry 
= counter.next()

I added the make_counter 
function. It seems the culprit is the retry = counter.next() bit. I tried doing 
this same thing with the make_counter function in an External method and then 
calling it from a python script like so:
counter = 
context.make_counter(1)
return 
counter.next()

In that case, an unauthorized 
exception is raised complaining about next. I can however, just return the 
counter which gives me generator object at 0xb48d56cc. Am I calling the 
next method incorrectly or is there something else I'm missing or being dumb 
about?

Thanks,
Tom 
Palermo
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Tino Wildenhain

Gaute Amundsen schrieb:

On Thursday 20 April 2006 13:23, Andrew Milton wrote:


+---[ Gaute Amundsen ]--

| On Thursday 20 April 2006 12:15, Andrew Milton wrote:
|  +---[ Gaute Amundsen ]--


snip


| But, why render the page, when I could just parse it to get the field
| order? Fun with regexp, or dom :)

Because you can just throw it at the ZPT or DTML engines, convert to text
and as a side-effect you get something ready to put into the email?

If you want to write your own parser, feel free.



I should have suspected :)

Any hints to get me statred on the zpt version?


No, you would not do this in ZPT. ZPT is the templating
engine. You write your logic in python. External Method
for example if you dont want to write a complete product.

import re

fe=re.compile(rinput.*?name=\(.*?)\.*?,re.DOTALL|re.MULTILINE|re.IGNORECASE)

def formparser(self):
src=self.document_src()
if self.has_Property('formelements'):
self.manage_changeProperties(formelements=fe.findall(src))
else:
self.manage_addProperty('formelements',
 fe.findall(src),
 lines)



put this in an external method and call it after the user updated
the HTML of her formular on the object (ZPT, DTML) which holds
that HTML. When you get the form request, just use something like:

[dict(element=e,value=request.form.get(e) for e in 
context.formdocument.getProperty('formelements') if request.form.has_key(e)]


which gives you the form elements in a nice list with their
respective values. Advantage: this makes it impossible
for an attacker to just supply more/other form fields
then originally were in the form.

Regards
Tino Wildenhain
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Automatically adding properties (keywords) to folders

2006-04-20 Thread Terry Jones
I'd like to set up a folder in Zope with the property that when an object
is put into it, the object has a keyword added to it automatically (and
when the object is moved out of the folder, the keyword is removed).

If you could do this, you would have a nice way to maintain a collection of
such folders and have their contents appear elsewhere in a collection of
Plone Smart Folders (using keyword criteria).

Can anyone tell me how I should best go about doing this?

I can imagine writing some python to run once in a while, find all the
contents of the folder, add the keywords, etc. But that's far from being an
ideal solution.

Any pointers would be much appreciated.

Regards,
Terry
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Gaute Amundsen
On Thursday 20 April 2006 15:46, Tino Wildenhain wrote:
 Gaute Amundsen schrieb:
 ...

  The order of the form elements that goes into mail headers is ofcourse
  irelevant. I'ts the rest of the form, you know name, adress, street, etc.
  that are the problem.
  It's a purely visual thing, but when you have a form with perhaps 50
  fields, that the client has carefully grouped and ordered, they can get
  rather pissed if you try to tell them they can only have it in
  semi-random or alpabetic in their mail.

 ...

  A smiley or two helps, but now I would say you are bordering on arrogant.
  What more do I have to explain to convince you that I understand what the
  problem is?

 We would have saved time if you provided the very usefull information
 first :-)

Well, it's amazing how what seems clear to one can be quite opaque to another.
I will try to be more explicit next time.

 Now you are building some kind of table/list with
 form-field-name: form-field-value  - am I right?

 how is it supposed to handle checkboxes, radiobuttons
 and select fields?

Hm.. I can't recall how I did that. I just made a reiplemetation of how 
formmail.pl did it.
But anything it does, it does looping thru request.form, so I dont think this 
is relevant. 

 One possible workaround, if you dont want to touch
 ZPublishers form handling would be to run a script
 to not only update the forms target (formmail.pl - zopeform)

I use apache proxy rewrite for that, no update needed.

 but split every form element from
 input type=text name=foo value= /

 into

 input type=hidden name=body.name:records value=foo/
 input type=text name=body.value:records value= /

 which you easily get as list of name/value pairs in
 the form variable body.

 You can even make this transformation any time a user edits
 her HTML source - save the users source in a property and
 transform this source via some regex or HTML parser
 to what you really want here.

 Moderate work and you can even add some sanity checks :-)

 If you can provide some typical samples of the HTML you
 are facing I believe you even can get help with the
 transformation script.

 Regards
 Tino

I have considered a number of variations along these lines.
Extracting the ordering information and adding a hidden field is also a 
posibilty. 
But the potential for messups, and big pain, with a script altering large 
amounts of user content, is not inconsiderable I would say.

I still think my own idea of adding a small proxy to transparently add that 
hidden field is rather more elagant.

I expect I will go with Andrew Milton's idea however, since that keeps us 
inside zope, and seems simpler to implement.

I would have prefered to go to the root of the problem, that allways works 
best in the long run, but it seems I have managed to avoid the effort this 
time. 

I still think it is something zope should handle, but for me it is only a sort 
of medium-term stop-gap measure, so it will do.

Thanks for your attention :)

Gaute
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Gaute Amundsen
On Thursday 20 April 2006 17:16, Tino Wildenhain wrote:
  Any hints to get me statred on the zpt version?

 No, you would not do this in ZPT. ZPT is the templating
 engine. You write your logic in python. External Method
 for example if you dont want to write a complete product.

I have the feeling you don't quite understand what  Andrew Milton is 
suggesting. I don't have the time to look into it properly now, but as I 
understand it, that templating engine can be instantiated independently, and 
it's methods called with my own data.

But thank you for the code and the effort :)

I might yet decide to use my own parser to extract the ordering info, but I 
will try the ZPT engine first. It has the potential to render the form even 
closer to how the users made the layout, but I must be able to strip out the 
menus etc.  

Gaute
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread David H




Gaute Amundsen wrote:

  On Thursday 20 April 2006 15:46, Tino Wildenhain wrote:
  
  
Gaute Amundsen schrieb:
...



  The order of the form elements that goes into mail headers is ofcourse
irelevant. I'ts the rest of the form, you know name, adress, street, etc.
that are the problem.
It's a purely visual thing, but when you have a form with perhaps 50
fields, that the client has carefully grouped and ordered, they can get
rather pissed if you try to tell them they can only have it in
semi-random or alpabetic in their mail.
  

...



  A smiley or two helps, but now I would say you are bordering on arrogant.
What more do I have to explain to convince you that I understand what the
problem is?
  

We would have saved time if you provided the very usefull information
first :-)


  
  Well, it's amazing how what seems clear to one can be quite opaque to another.
I will try to be more explicit next time.

  
  
Now you are building some kind of table/list with
form-field-name: form-field-value  - am I right?

how is it supposed to handle checkboxes, radiobuttons
and select fields?


  
  Hm.. I can't recall how I did that. I just made a reiplemetation of how 
formmail.pl did it.
But anything it does, it does looping thru request.form, so I dont think this 
is relevant. 

  
  
One possible workaround, if you dont want to touch
ZPublishers form handling would be to run a script
to not only update the forms target (formmail.pl - zopeform)

  
  
I use apache "proxy rewrite" for that, no update needed.

  
  
but split every form element from
input type="text" name="foo" value="" /

into

input type="hidden" name="body.name:records" value="foo"/
input type="text" name="body.value:records" value="" /

which you easily get as list of name/value pairs in
the form variable "body".

You can even make this transformation any time a user edits
her HTML source - save the users source in a property and
transform this source via some regex or HTML parser
to what you really want here.

Moderate work and you can even add some sanity checks :-)

If you can provide some typical samples of the HTML you
are facing I believe you even can get help with the
transformation script.

Regards
Tino

  
  
I have considered a number of variations along these lines.
Extracting the ordering information and adding a hidden field is also a 
posibilty. 
But the potential for messups, and big pain, with a script altering large 
amounts of user content, is not inconsiderable I would say.

I still think my own idea of adding a small proxy to transparently add that 
"hidden field" is rather more elagant.

I expect I will go with Andrew Milton's idea however, since that keeps us 
inside zope, and seems simpler to implement.

I would have prefered to go to the root of the problem, that allways works 
best in the long run, but it seems I have managed to avoid the effort this 
time. 

I still think it is something zope should handle, but for me it is only a sort 
of medium-term stop-gap measure, so it will do.

Thanks for your attention :)

Gaute
  

Hi Gaute,

I saw this in a Goodman _javascript_ book "Elements: A collection of all
elements w/in a form ... Collection members are sorted in source code
order". So, you could standardize a _javascript_ process
function that loops thru the elements naming each one? 

If such a thing could work that you just need to include the
../_javascript_. 

David


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: Automatically adding properties (keywords) to folders

2006-04-20 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Terry Jones wrote:
 I'd like to set up a folder in Zope with the property that when an object
 is put into it, the object has a keyword added to it automatically (and
 when the object is moved out of the folder, the keyword is removed).
 
 If you could do this, you would have a nice way to maintain a collection of
 such folders and have their contents appear elsewhere in a collection of
 Plone Smart Folders (using keyword criteria).
 
 Can anyone tell me how I should best go about doing this?
 
 I can imagine writing some python to run once in a while, find all the
 contents of the folder, add the keywords, etc. But that's far from being an
 ideal solution.
 
 Any pointers would be much appreciated.

The old way to do that we be to derive your own folder class and
override '_setObject' / '_delObject' to add your semantics.

The new way (for Zope = 2.9) would be to register a subscriber for the
container events which are published automatically.  Something like
(untested)::

  def update_keywords(event):
  keyword = getattr(event.newparent, 'keyword', None)
  event.object.keyword = None
  event.object.reindexObject()

and then in ZCML::

  subscriber
for=zope.app.event.objectevent.ObjectEvent
factory=Products.yourproduct.events.update_keywords


Tres.
- --
===
Tres Seaver  +1 202-558-7113  [EMAIL PROTECTED]
Palladion Software   Excellence by Designhttp://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFER7/g+gerLs4ltQ4RAjcHAJ9WqoFcbrNIC9h3M5jYEZ8Bmq2jMQCeMjSh
7zE2AI2+rNc39s3bhOMsb4E=
=yYJw
-END PGP SIGNATURE-

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


RE: [Zope] Custom 404 - Resource not found

2006-04-20 Thread Andy Yates
  ...
 Changing standard_error_message does not seem change this error page.
 
 Maybe, you made a mistake?

Yes, I made a mistake!  In standard_error_message:

dtml-if error_message
 dtml-var error_message
dtml-else

  h2My TEST  Site Error/h2
...

404 errors hit the dtml-if and other errors, like attribute errors, go
to the dtml-else.   I was just modifying the else.

Thanks!
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: Automatically adding properties (keywords) to folders

2006-04-20 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Terry Jones wrote:
 Hi Tres
 
 Thanks for your answer. Could I trouble you a little bit more please?
 
 I don't know where I'd put these fragments (and the last one seems
 incomplete, perhaps intentionally?). I'm happy to read and code myself, so
 I don't mean to ask for much here, but I'm not sure what to do with your
 suggestion. I read version 2.6 of the zope book, and today found out
 there's a proto-version 2.7, which I'll take a look at.

Note that the new way stuff is only for Zope *later* than 2.8.x.
In that case, you would define the function in a module somewhere on
your $PYTHONPATH (e.g., in $INSTANCE_HOME/lib/python, or in a product)
and then register it in a ZCML file which is included from your
'site.zcml' (in $INSTANCE_HOME/etc).

 Anyway, thanks again.
 
 Terry
 
 | The old way to do that we be to derive your own folder class and
 | override '_setObject' / '_delObject' to add your semantics.
 | 
 | The new way (for Zope = 2.9) would be to register a subscriber for the
 | container events which are published automatically.  Something like
 | (untested)::
 | 
 |   def update_keywords(event):
 |   keyword = getattr(event.newparent, 'keyword', None)
 |   event.object.keyword = None
 |   event.object.reindexObject()
 | 
 | and then in ZCML::
 | 
 |   subscriber
 | for=zope.app.event.objectevent.ObjectEvent
 | factory=Products.yourproduct.events.update_keywords



Tres.
- --
===
Tres Seaver  +1 202-558-7113  [EMAIL PROTECTED]
Palladion Software   Excellence by Designhttp://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFER/Iq+gerLs4ltQ4RAvSAAJ9edkh96NO63lrKF6mkuDeAGYSYWQCgp98g
hp/tu+8LtZFYjJvX3rSxuao=
=m3sh
-END PGP SIGNATURE-

-- 
===
Tres Seaver  +1 202-558-7113  [EMAIL PROTECTED]
Palladion Software   Excellence by Designhttp://palladion.com

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] REQUEST.form variables order

2006-04-20 Thread Dieter Maurer
Gaute Amundsen wrote at 2006-4-19 19:03 +0200:
I want to retrieve the form fields in the order that they where submitted in 
the http POST. I know this has been brought up before, and that the answer is 
You cant.

You might be able to do it.

   Try REQUEST['BODY']. For a POST request, it should
   contain the entity content.

   Of course, you would have to decode it yourself ;-)

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Automatically adding properties (keywords) to folders

2006-04-20 Thread Dieter Maurer
Terry Jones wrote at 2006-4-20 17:30 +0200:
I'd like to set up a folder in Zope with the property that when an object
is put into it, the object has a keyword added to it automatically (and
when the object is moved out of the folder, the keyword is removed).

Thus, you want to customize the folder's _setObject and _delObject.

Define your own Folder class deriving from Zope's standard 'Folder'
and reimplement _setObject and _getObject the way you like.

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Python Generators and Zope question

2006-04-20 Thread Dieter Maurer
Palermo, Tom wrote at 2006-4-20 10:52 -0400:
I have a site that uses CookieCrumbler for user login. I need to track how
many incorrect login attempts a user makes. I am trying to use a python
generator to do this but it makes Zope hang when I try to do an invalid
login (eg. no password or incorrect password). Here's a snippet:

I fear you are on the wrong way.

  You must store the number of incorrect login attempts with
  the user.

  For this, you should use a standard integer (and not a generator).

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Documentation and Books

2006-04-20 Thread Dieter Maurer
Erik Billing wrote at 2006-4-19 23:04 +0200:
Yes, the developers guide I've seen, and the Zope Book of course, they are
both pretty good I guess, but certainly the Zope book seams pretty outdated
if you ask me.

You must look at the 2.7 edition of the Zope book (online).

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Regular Expressions

2006-04-20 Thread April Lekin

Can you use regular expressions in Zope?

I'm trying to do a date match, something like this:

date = re.match(l_date, '\d\d\d\d\/\d\d/\d\d')

Looks like it doesn't like the re.match?

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Regular Expressions

2006-04-20 Thread Dennis Allison

Regular expressions are usually precluded as a potential security risk.  
You can enable imports into Python Scripts (see instructions in the 
source) fairly easily.  Or you can do the regular expression processing
you need in an External Method or Product.

And, of course, you'll need to import re in the module where you 
use it.


On Thu, 20 Apr 2006, April Lekin wrote:

 Can you use regular expressions in Zope?
 
 I'm trying to do a date match, something like this:
 
 date = re.match(l_date, '\d\d\d\d\/\d\d/\d\d')
 
 Looks like it doesn't like the re.match?
 
 ___
 Zope maillist  -  Zope@zope.org
 http://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists - 
  http://mail.zope.org/mailman/listinfo/zope-announce
  http://mail.zope.org/mailman/listinfo/zope-dev )
 

-- 

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Regular Expressions

2006-04-20 Thread Tino Wildenhain
April Lekin wrote:
 Can you use regular expressions in Zope?
 
 I'm trying to do a date match, something like this:
 
 date = re.match(l_date, '\d\d\d\d\/\d\d/\d\d')
 
 Looks like it doesn't like the re.match?

Well, if you look into the zope API documentation
you find all modules you can use in untrusted
(e.g. thru the web) code. re isnt part of the
exposed API. You either write an external method
or a product or you enable modules you think you
can trust to zope scripting. This can be done
by copying Products/PythonScripts/module_access_example.py (or similar)
to yourProductfolder/Yourproduct/__init__.py
and edit it accordingly. Restart zope
and use the modules you want. Make sure you enable
only modules you really can trust.

Regards
Tino Wildenhain
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Zope product update question

2006-04-20 Thread Cyrille Bonnet

Hi there,

I have a question regarding product update.

I have updated a product (ATContentTypes) on the file system. Upon 
restarting the server, the new version of the product appears in red in 
the QuickInstaller (as expected).


Even though I haven't re-installed the product, some changes are picked 
up (for instance, it uses the new schemata for ATDocument).


Is this the expected behaviour?

What is exactly the difference between a non-installed product on the 
file system and an installed product?


Is the only difference that the Install.py is run when you install the 
product??


I am using Zope 2.7.4.0, Python 2.3.4. The versions of ATContentTypes 
are 0.2.0-rc3 (current) and 0.2.1-final (future, uninstalled).


Any help appreciated.

Cheers,

Cyrille

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Zope product update question

2006-04-20 Thread J Cameron Cooper

Cyrille Bonnet wrote:


I have a question regarding product update.

I have updated a product (ATContentTypes) on the file system. Upon 
restarting the server, the new version of the product appears in red in 
the QuickInstaller (as expected).


Even though I haven't re-installed the product, some changes are picked 
up (for instance, it uses the new schemata for ATDocument).


Is this the expected behaviour?


Of course. Whatever Python code exists will take effect whenever it's 
loaded.


What is exactly the difference between a non-installed product on the 
file system and an installed product?


Is the only difference that the Install.py is run when you install the 
product??


Yes. Many Products require changes in the ZODB; QI is how this is 
accomodated.


This is really a CMF/Plone question, btw. Better on one of those lists.

--jcc

--
Building Websites with Plone
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Zope product update question

2006-04-20 Thread Jens Vagelpohl

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On 20 Apr 2006, at 22:39, Cyrille Bonnet wrote:


Hi there,

I have a question regarding product update.

I have updated a product (ATContentTypes) on the file system. Upon  
restarting the server, the new version of the product appears in  
red in the QuickInstaller (as expected).


Even though I haven't re-installed the product, some changes are  
picked up (for instance, it uses the new schemata for ATDocument).


Is this the expected behaviour?


Yes. Once the new code is on the file system it will be read in and  
used.


I believe the QuickInstaller does nothing more than execute  
external methods that have special well-known names which then  
trigger whatever Plone magic needs to be triggered to complete the  
upgrade. The QuickInstaller is a special Plone-only item, normal  
Zope product installation does not use it.


jens

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFESAKVRAx5nvEhZLIRArwXAJ0biLjUrcfVI3h+BVI2uBHJ1n9Z/gCgqnCw
pZ6TPGApiF5Uw5iv86fVnu8=
=nPcN
-END PGP SIGNATURE-
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Zope product update question

2006-04-20 Thread Jens Vagelpohl

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On 20 Apr 2006, at 22:51, J Cameron Cooper wrote:
What is exactly the difference between a non-installed product on  
the file system and an installed product?
Is the only difference that the Install.py is run when you install  
the product??


Yes. Many Products require changes in the ZODB; QI is how this is  
accomodated.


This is really a CMF/Plone question, btw. Better on one of those  
lists.


Well, it's a Plone question. CMF does not need/use the QI tool.

There are a lot of packages in the Plone ecosystem that are named  
CMFsomething, but that's a little lie - they would never work on  
CMF alone. To avoid confusion the name should really be  
Plonesomething.


jens

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFESAOPRAx5nvEhZLIRAo9YAJ9A7b4mdEOK0asAPdxtTV7Ef2pLIwCfTOxy
Be+35MyBKBRKFf7TcI2z0X0=
=HZk/
-END PGP SIGNATURE-
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: Zope product update question

2006-04-20 Thread Cyrille Bonnet

Hi guys,

thanks for your replies. It is very helpful.

Essentially, I was trusting the Quick Installer tool too much: files on 
the file system will be used, regardless if you've installed the product 
or not.


Thanks for your help.

Cyrille

Jens Vagelpohl wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On 20 Apr 2006, at 22:39, Cyrille Bonnet wrote:


Hi there,

I have a question regarding product update.

I have updated a product (ATContentTypes) on the file system. Upon  
restarting the server, the new version of the product appears in  red 
in the QuickInstaller (as expected).


Even though I haven't re-installed the product, some changes are  
picked up (for instance, it uses the new schemata for ATDocument).


Is this the expected behaviour?



Yes. Once the new code is on the file system it will be read in and  used.

I believe the QuickInstaller does nothing more than execute  external 
methods that have special well-known names which then  trigger 
whatever Plone magic needs to be triggered to complete the  upgrade. The 
QuickInstaller is a special Plone-only item, normal  Zope product 
installation does not use it.


jens

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFESAKVRAx5nvEhZLIRArwXAJ0biLjUrcfVI3h+BVI2uBHJ1n9Z/gCgqnCw
pZ6TPGApiF5Uw5iv86fVnu8=
=nPcN
-END PGP SIGNATURE-
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )



___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope-DB] Patches to SybaseDA v2.0b2

2006-04-20 Thread Doug Morse
Hi,

In migrating from Sybase 11.0.3 (old, free version for Linux) to Sybase 15
(free Linux Express version), I've had quite a number of troubles getting
SybaseDAv2b2 to work (under Zope 2.5.1).  That said, the problems probably
had more to do with changing from Python 2.1.3 (Redhat 7.2) to Python 2.3.4
(RHEL 4.3).

In particular, the newer Python more stringently checks the parameters
passed to the PyArg_ParseTupleAndKeywords() function.  sys_occ.c in
SybaseDAv2b2 has a very minor (but fatal) error in this regard that, because
of the new checks, cause the somewhat esoteric error message:

  RuntimeError: more keyword list entries than argument specifiers

I've included below patches to two files, db.py and src/sys_occ.c, that fix
this error.

The patches also provide a workaround for the first error I encountered that
stumped me for a bit:

  ct_command(): user api layer: external error: This routine cannot be
  called while results are pending for a command that has been sent to the
  server

This error occurred anytime I tried to access the database (i.e., I could
connect just fine, but could not run any queries).  The solution simply adds
a call to cm.ct_cancel(sy_occ.CS_CANCEL_ALL) early on in the query
method to clear the pending results and hence stop this error from
occurring.

IMPORTANT CAVEAT: This call to cm.ct_cancel() may not be appropriate as a
general solution, as it's possible that the workaround will mess up a
multistep query, such as an INSERT, UPDATE, or DELETE transaction.  The
proper fix would require finding out why SybaseDAv2b2 has some sort of
results pending even at the first call of the query method and then fixing
this by either retrieving the remaining results or cancelling the offending
query.

I presently only require read-only access for rather simply queries
from Zope to Sybase 15, so this workaround is fine for me for now.  If
anyone investigates this further and has a better solution, I'd appreciate
knowing.

I hope this is helpful to some soul or souls out there. :)  Sybase ASE 15 is
a great product, free for Linux for up to 5gb DBs and 2gb RAM, and worthy of
partnering with Zope for the presentation side of things.

Doug

P.S. the patch also corrects the erroneous duplication of the
CS_SUCCEED command entry (noted long ago on this list) and puts a try/catch
block around a call to apply(converters[t], v), also suggested by some
poster either on this or another list.


PATCH #1: db.py

*** db.py   2000-02-02 14:01:34.0 -0600
--- /opt/zope/lib/python/Products/SybaseDAv2/db.py  2006-04-19 
19:00:13.0 -0500
***
*** 178,184 
CS_IMAGE_TYPE=sy_occ.CS_IMAGE_TYPE,
CS_ROW_FAIL=sy_occ.CS_ROW_FAIL,
CS_END_DATA=sy_occ.CS_END_DATA,
-   CS_SUCCEED=sy_occ.CS_SUCCEED,
CS_FMT_UNUSED=sy_occ.CS_FMT_UNUSED,
string_type=_string_types.has_key,
type_map=_type_map,
--- 178,183 
***
*** 196,201 
--- 195,201 
  for query in queries:
  
  failed=0
+ cm.ct_cancel(sy_occ.CS_CANCEL_ALL)
  if cm.ct_command(CS_LANG_CMD, query) != CS_SUCCEED: self._error()
  if cm.ct_send() != CS_SUCCEED: self._error()
  
***
*** 280,287 
  v=x
  else:
  v=buf[0]
! if type(v) is TupleType:
! v=apply(converters[t], v)
  
  row[i]=v
  result.append(tuple(row))
--- 280,295 
  v=x
  else:
  v=buf[0]
! # if type(v) is TupleType:
! # v=apply(converters[t], v)
! try:
! if type(v) is TupleType:
! v=apply(converters[t], v)
! except:
! cm.ct_cancel(sy_occ.CS_CANCEL_ALL)
! raise Error(Results field 
conversion error: converter=%s, v=%s % \
! (str(converters[t]), 
str(v)))
! 
  
  row[i]=v
  result.append(tuple(row))

PATCH #2: src/sy_occ.c

*** src/sy_occ.c2000-02-02 14:01:34.0 -0600
--- /opt/zope/lib/python/Products/SybaseDAv2/src/sy_occ.c   2006-04-20 
00:17:23.0 -0500
***
*** 382,388 
  
static char *kwargs[] = {name,