[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/lib/python/Products/Five/api.py removed pre-Five-1.0 cruft (this file does not belong to Five 1.0)

2005-05-27 Thread Yvo Schubbe
Log message for revision 30528:
  removed pre-Five-1.0 cruft (this file does not belong to Five 1.0)

Changed:
  D   Zope/branches/Zope-2_8-branch/lib/python/Products/Five/api.py

-=-
Deleted: Zope/branches/Zope-2_8-branch/lib/python/Products/Five/api.py
===
--- Zope/branches/Zope-2_8-branch/lib/python/Products/Five/api.py   
2005-05-27 10:53:19 UTC (rev 30527)
+++ Zope/branches/Zope-2_8-branch/lib/python/Products/Five/api.py   
2005-05-27 11:02:49 UTC (rev 30528)
@@ -1,26 +0,0 @@
-##
-#
-# Copyright (c) 2005 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.
-#
-##
-Convenience package for short imports
-
-$Id: api.py 6174 2004-08-25 17:19:28Z faassen $
-
-
-import warnings
-
-warnings.warn('The use of the Products.Five.api module has been deprecated. '
-  'Import directly from Products.Five instead for public API.',
-  DeprecationWarning)
-
-from browser import BrowserView, StandardMacros
-from traversable import Traversable
-from viewable import Viewable

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


[Zope-Checkins] CVS: Zope/doc - CHANGES.txt:1.625.2.334

2005-05-27 Thread Tres Seaver
Update of /cvs-repository/Zope/doc
In directory cvs.zope.org:/tmp/cvs-serv13610/doc

Modified Files:
  Tag: Zope-2_7-branch
CHANGES.txt 
Log Message:

 
   - Collector #889:  made 'and' operator for KeywordIndexes actually
 restrict results as expected (thanks to 'aroda' for the patch!).


=== Zope/doc/CHANGES.txt 1.625.2.333 = 1.625.2.334 ===
--- Zope/doc/CHANGES.txt:1.625.2.333Fri May 20 14:37:02 2005
+++ Zope/doc/CHANGES.txtFri May 27 09:03:49 2005
@@ -14,6 +14,9 @@
 
 Bugs fixed
 
+  - Collector #889:  made 'and' operator for KeywordIndexes actually
+restrict results as expected (thanks to 'aroda' for the patch!).
+
   - Collector #1781: made 'create_mount_points' ZConfig option actually
 work (thanks to Dieter Maurer for the patch).
 

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


[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/ Made 'and' operator for KeywordIndexes actually restrict results as expected.

2005-05-27 Thread Tres Seaver
Log message for revision 30532:
  Made 'and' operator for KeywordIndexes actually restrict results as expected.
  
  Collector #889 -- thanks to 'aroda' for the patch!
  
  

Changed:
  U   Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
  U   
Zope/branches/Zope-2_8-branch/lib/python/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
  U   
Zope/branches/Zope-2_8-branch/lib/python/Products/PluginIndexes/common/UnIndex.py

-=-
Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
===
--- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2005-05-27 14:58:57 UTC 
(rev 30531)
+++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt   2005-05-27 15:54:26 UTC 
(rev 30532)
@@ -22,7 +22,13 @@
 
- Collector #1233: port ZOPE_CONFIG patch from Zope 2.7 to Zope 2.8
 
+  After Zope 2.8.0 b2
 
+Bugs Fixed
+
+  - Collector #889:  made 'and' operator for KeywordIndexes actually
+restrict results as expected (thanks to 'aroda' for the patch!).
+
   Zope 2.8.0 b2 (2005/05/22)
 
 Features added

Modified: 
Zope/branches/Zope-2_8-branch/lib/python/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
===
--- 
Zope/branches/Zope-2_8-branch/lib/python/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
  2005-05-27 14:58:57 UTC (rev 30531)
+++ 
Zope/branches/Zope-2_8-branch/lib/python/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
  2005-05-27 15:54:26 UTC (rev 30532)
@@ -221,6 +221,33 @@
 finally:
 self._ignore_log_errors()
 
+def testCollectorIssue889(self) :
+# Test that collector issue 889 is solved
+values = self._values
+nonexistent = 'foo-bar-baz'
+self._populateIndex()
+# make sure key is not indexed
+result = self._index._index.get(nonexistent, self._marker)
+assert result is self._marker
+# patched _apply_index now works as expected
+record = {'foo' : { 'query': [nonexistent]
+  , 'operator' : 'and'}
+ }
+self._checkApply(record, [])
+record = {'foo' : { 'query': [nonexistent, 'a']
+  , 'operator' : 'and'}
+ }
+# and does not break anything
+self._checkApply(record, [])
+record = {'foo' : { 'query': ['d']
+  , 'operator' : 'and'}
+ }
+self._checkApply(record, values[4:5])
+record = {'foo' : { 'query': ['a', 'e']
+  , 'operator' : 'and'}
+ }
+self._checkApply(record, values[5:7])
+
 def test_suite():
 suite = unittest.TestSuite()
 suite.addTest( unittest.makeSuite( TestKeywordIndex ) )

Modified: 
Zope/branches/Zope-2_8-branch/lib/python/Products/PluginIndexes/common/UnIndex.py
===
--- 
Zope/branches/Zope-2_8-branch/lib/python/Products/PluginIndexes/common/UnIndex.py
   2005-05-27 14:58:57 UTC (rev 30531)
+++ 
Zope/branches/Zope-2_8-branch/lib/python/Products/PluginIndexes/common/UnIndex.py
   2005-05-27 15:54:26 UTC (rev 30532)
@@ -363,10 +363,11 @@
 else: # not a range search
 for key in record.keys:
 set=index.get(key, None)
-if set is not None:
-if isinstance(set, int):
-set = IISet((set,))
-r = set_func(r, set)
+if set is None:
+set = IISet(())
+elif isinstance(set, int):
+set = IISet((set,))
+r = set_func(r, set)
 
 if isinstance(r, int):  r=IISet((r,))
 if r is None:

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


[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PluginIndexes/ Forward port fix for Collector #889 from 2.8 branch.

2005-05-27 Thread Tres Seaver
Log message for revision 30533:
  Forward port fix for Collector #889 from 2.8 branch.

Changed:
  U   
Zope/trunk/lib/python/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
  U   Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py

-=-
Modified: 
Zope/trunk/lib/python/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
===
--- 
Zope/trunk/lib/python/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
 2005-05-27 15:54:26 UTC (rev 30532)
+++ 
Zope/trunk/lib/python/Products/PluginIndexes/KeywordIndex/tests/testKeywordIndex.py
 2005-05-27 15:58:44 UTC (rev 30533)
@@ -221,6 +221,33 @@
 finally:
 self._ignore_log_errors()
 
+def testCollectorIssue889(self) :
+# Test that collector issue 889 is solved
+values = self._values
+nonexistent = 'foo-bar-baz'
+self._populateIndex()
+# make sure key is not indexed
+result = self._index._index.get(nonexistent, self._marker)
+assert result is self._marker
+# patched _apply_index now works as expected
+record = {'foo' : { 'query': [nonexistent]
+  , 'operator' : 'and'}
+ }
+self._checkApply(record, [])
+record = {'foo' : { 'query': [nonexistent, 'a']
+  , 'operator' : 'and'}
+ }
+# and does not break anything
+self._checkApply(record, [])
+record = {'foo' : { 'query': ['d']
+  , 'operator' : 'and'}
+ }
+self._checkApply(record, values[4:5])
+record = {'foo' : { 'query': ['a', 'e']
+  , 'operator' : 'and'}
+ }
+self._checkApply(record, values[5:7])
+
 def test_suite():
 suite = unittest.TestSuite()
 suite.addTest( unittest.makeSuite( TestKeywordIndex ) )

Modified: Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py
===
--- Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py  
2005-05-27 15:54:26 UTC (rev 30532)
+++ Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py  
2005-05-27 15:58:44 UTC (rev 30533)
@@ -363,10 +363,11 @@
 else: # not a range search
 for key in record.keys:
 set=index.get(key, None)
-if set is not None:
-if isinstance(set, int):
-set = IISet((set,))
-r = set_func(r, set)
+if set is None:
+set = IISet(())
+elif isinstance(set, int):
+set = IISet((set,))
+r = set_func(r, set)
 
 if isinstance(r, int):  r=IISet((r,))
 if r is None:

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


[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/lib/python/ Use a properly constructed tag for the Zope3 code.

2005-05-27 Thread Tim Peters
Log message for revision 30543:
  Use a properly constructed tag for the Zope3 code.
  

Changed:
  _U  Zope/branches/Zope-2_8-branch/lib/python/

-=-

Property changes on: Zope/branches/Zope-2_8-branch/lib/python
___
Name: svn:externals
   - zope   
svn://svn.zope.org/repos/main/Zope3/tags/ZopeX3-3.0.0-Zope-2.8-a3/src/zope
ZConfigsvn://svn.zope.org/repos/main/ZConfig/tags/ZConfig-2.3
BTrees svn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/BTrees
Persistencesvn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/Persistence
persistent svn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/persistent
ThreadedAsync  svn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/ThreadedAsync
transactionsvn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/transaction
ZEOsvn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/ZEO
ZODB   svn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/ZODB
ZopeUndo   svn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/ZopeUndo

   + zope   
svn://svn.zope.org/repos/main/Zope3/tags/ZopeX3-3.0.0-Zope-2.8-a4/src/zope
ZConfigsvn://svn.zope.org/repos/main/ZConfig/tags/ZConfig-2.3
BTrees svn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/BTrees
Persistencesvn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/Persistence
persistent svn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/persistent
ThreadedAsync  svn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/ThreadedAsync
transactionsvn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/transaction
ZEOsvn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/ZEO
ZODB   svn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/ZODB
ZopeUndo   svn://svn.zope.org/repos/main/ZODB/tags/3.4.0b1/src/ZopeUndo


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



[Zope-dev] hasattr implementation for Zope?

2005-05-27 Thread Chris Withers

Dieter Maurer wrote:

I strongly argue against it. Fix hasattr in the Zope context,
instead!



  _marker = []
  def hasattr(obj, attr, marker):
  a = getattr(obj, attr, _marker)
  return a is not _marker

  import __builtin__
  __builtin__.hasattr = hasattr

Easy enough, isn't it?

Way easier than to change hasattr anywhere it is now used.


Anyone think putting this in Zope core is a good idea?

If so, where should it go?
Any potential performance implications people can think of?

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk

___
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] hasattr implementation for Zope?

2005-05-27 Thread Paul Winkler
On Fri, May 27, 2005 at 08:53:54AM +0100, Chris Withers wrote:
 Anyone think putting this in Zope core is a good idea?
 
 If so, where should it go?
 Any potential performance implications people can think of?

fwiw, tonight I ran some quick request-per-second tests
(using ab -n 100 -c 10) on a patched vs. an unpatched zope
2.7.6 final.  I was hitting the front page of a CMFDefault site
because I had one handy on my dev box.
(but I should try Plone for this :=)

I wasn't able to see any consistent performance difference.
At first I thought that the patched version was a bit slower
when concurrency was increased to 20, but that only happened
on one run so maybe it was a fluke.

I put the patch in Globals.py for no particular reason.

-- 

Paul Winkler
http://www.slinkp.com
___
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] RAMcache and container vs. context

2005-05-27 Thread Stefan H. Holek
A TALES expression may be prohibitively expensive in any case, no  
matter how simple it is kept. Please make sure to do some comparative  
profiling. Cache keys are recomputed on every call of the script,  
AFAICS. The thought of doing this in restricted Python makes my skin  
crawl.


Stefan


On 26. Mai 2005, at 09:12, Chris Withers wrote:


Paul Winkler wrote:


I kinda wish the RAMCache manager allowed other things than
REQUEST variables for differentiation. Arbitrary TALES expressions
would be nice. Then we could get rid of this hard-coded gunk and
get the same effect by having context/getPhysicalPath as one
of the expressions.
But of course then you'd have the opportunity to kill your
cache performance by making the expressions too expensive.
Ah well, TANSTAAFL and all that. I'll probably just drop the idea.



I still think it's worth it. Crippling everyone on the basis that  
stupid people can hurt themselves is not good logic in my books ;-)


If you could chuck this as a feature request in the collector and  
assign it to me, I'd love to work on it if I ever find the time...


cheers,

Chris


--
Software Engineering is Programming when you can't. --E. W. Dijkstra


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

___
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 )


[Zope-dev] Re: hasattr implementation for Zope?

2005-05-27 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Chris Withers wrote:
 Dieter Maurer wrote:
 
 I strongly argue against it. Fix hasattr in the Zope context,
 instead!


   _marker = []
   def hasattr(obj, attr, marker):
   a = getattr(obj, attr, _marker)
   return a is not _marker

   import __builtin__
   __builtin__.hasattr = hasattr

 Easy enough, isn't it?

 Way easier than to change hasattr anywhere it is now used.
 
 
 Anyone think putting this in Zope core is a good idea?

- -1.  Python's 'hasattr' semantics are *broken by definition*, and will
never be fixed (because of backward compatibility).  Non-Zope Python
programmers will *not* expect or want exceptions raised from 'hasattr'.

As a local patch, this isn't too bad (one could even package it as a
do-nothing-after-initialization product).  However, no redistributed
product code should rely on the presence of a patched 'hasattr', but
should use the 3 argument getattr instead.


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

iD8DBQFClxEU+gerLs4ltQ4RAto2AKDNc44GLkHYn9s2CMvEJrBZnUxaEwCfYK0J
PtE2/G2CkGBec869OOQWmjo=
=1IHS
-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 )


[Zope-dev] Re: [Interested?] New use for Zope+CMF+Archetypes -- startup time improvements

2005-05-27 Thread Dieter Maurer
Dieter Maurer wrote at 2005-5-13 19:26 +0200:
 ... high Zope startup time ...
To overcome this obstacle, we tweaked Zope and fixed Python's import
mechanism such that Zope now starts either out of a ZIP archive
or as a frozen application.
 ...
In more details, we did:

  *  implement a package for a new kind of urls pypackage:
 for package relative access to resources.

 The package monkey patches Python's open, os.listdir,
 os.stat to provide transparent access to
 pypackage: identified resources.

 It currently support package relative access for
 packages loaded from the file system, from a ZIP
 archive and from the executable itself (i.e. frozen packages).
 In the last case, the resources are in a separate ZIP
 archive.

 This package might be interesting for Python as a whole
 as it is not Zope specific.

I have now released this part as independent Python packages
dllimporter and packageresources.

You can find them via

http://www.dieter.handshake.de/pyprojects


In case, they should be included into Zope, I would give them
a dual license (my own BSD-like and ZPL).


-- 
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: hasattr implementation for Zope?

2005-05-27 Thread Tim Peters
[Tres Seaver]
[...]
 - -1.  Python's 'hasattr' semantics are *broken by definition*, and will
 never be fixed (because of backward compatibility).  Non-Zope Python
 programmers will *not* expect or want exceptions raised from 'hasattr'.

 As a local patch, this isn't too bad (one could even package it as a
 do-nothing-after-initialization product).  However, no redistributed
 product code should rely on the presence of a patched 'hasattr', but
 should use the 3 argument getattr instead.

OTOH, defining  importing a utility function-- say, safehasattr()
--would make it all explicit.  That's what ZODB does.  I certainly
agree that changing the behavior of a builtin function by magic is at
best highly dubious practice.
___
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: hasattr implementation for Zope?

2005-05-27 Thread Jim Fulton

Tim Peters wrote:

[Tres Seaver]
[...]


- -1.  Python's 'hasattr' semantics are *broken by definition*, and will
never be fixed (because of backward compatibility).  Non-Zope Python
programmers will *not* expect or want exceptions raised from 'hasattr'.

As a local patch, this isn't too bad (one could even package it as a
do-nothing-after-initialization product).  However, no redistributed
product code should rely on the presence of a patched 'hasattr', but
should use the 3 argument getattr instead.



OTOH, defining  importing a utility function-- say, safehasattr()
--would make it all explicit.  That's what ZODB does.  I certainly
agree that changing the behavior of a builtin function by magic is at
best highly dubious practice.


In fact, consider this vetoed for the Zope core. :)

Jim

--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
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: hasattr implementation for Zope?

2005-05-27 Thread Paul Winkler
On Fri, May 27, 2005 at 09:25:58AM -0400, Jim Fulton wrote:
 Tim Peters wrote:
 OTOH, defining  importing a utility function-- say, safehasattr()
 --would make it all explicit.  That's what ZODB does.  

OK.

(BTW, I just went grepping for this safehasattr() in zope 2.7.6's
ZODB and didn't find anything. What's it called?)
 
There are ~700 calls to hasattr() currently in the Zope core (ouch!).  
Are there cases where the current use of hasattr() is considered safe?
Or since it's broken by design,  should we replace all 700
calls with this hypothetical safe_hasattr()?

While we're on the subject, the other day Dieter Maurer was complaining that:


An incredibly long time ago, I filed a feature request for  
hasattr_unacquired -- together with patch, unit tests and
documentation   
update. I am convinced that such a function in the  
DTML namespace (and therefore always available in restricted code)  
would be much clearer than the aq_inner.aq_explicit dance.

But, unfortunately, the Zope developers decided not to  
accept my patch or the hasattr_unacquired idea
and instead made aq_inner accessible by untrusted code.   
A bad decision! 
As a consequence, you see the nasty code.   


So, assuming we add a safe_hasattr() function, maybe it could take 
an extra keyword arg?

something like:

def safe_hasattr(obj, attr, acquired=True, _marker=[]):
if not acquired:
obj = aq_inner(aq_explicit(obj))
return getattr(obj, attr, _marker) is not _marker

  I certainly
 agree that changing the behavior of a builtin function by magic is at
 best highly dubious practice.
 
 In fact, consider this vetoed for the Zope core. :)

Fine, that nicely reduces the scope of the discussion :-)

-- 

Paul Winkler
http://www.slinkp.com
___
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: hasattr implementation for Zope?

2005-05-27 Thread Jim Fulton

Paul Winkler wrote:

On Fri, May 27, 2005 at 09:25:58AM -0400, Jim Fulton wrote:


Tim Peters wrote:


OTOH, defining  importing a utility function-- say, safehasattr()
--would make it all explicit.  That's what ZODB does.  



OK.

(BTW, I just went grepping for this safehasattr() in zope 2.7.6's
ZODB and didn't find anything. What's it called?)
 
There are ~700 calls to hasattr() currently in the Zope core (ouch!).  
Are there cases where the current use of hasattr() is considered safe?

Or since it's broken by design,  should we replace all 700
calls with this hypothetical safe_hasattr()?

While we're on the subject, the other day Dieter Maurer was complaining that:


An incredibly long time ago, I filed a feature request for  
hasattr_unacquired -- together with patch, unit tests and
documentation   
update. I am convinced that such a function in the  
DTML namespace (and therefore always available in restricted code)  
would be much clearer than the aq_inner.aq_explicit dance.

But, unfortunately, the Zope developers decided not to  
accept my patch or the hasattr_unacquired idea
and instead made aq_inner accessible by untrusted code.   
A bad decision! 
As a consequence, you see the nasty code.   



I'm sure this was an unintentional non-acceptance.  It would be
a lot easier if Dieter became a contributor and checked this in
himself.  I'd be happy to see Dieter's patch accepted.

So, assuming we add a safe_hasattr() function, maybe it could take 
an extra keyword arg?


something like:

def safe_hasattr(obj, attr, acquired=True, _marker=[]):
if not acquired:
obj = aq_inner(aq_explicit(obj))
return getattr(obj, attr, _marker) is not _marker


I'd rather have 2 separate functions.

BTW, I prefer to code things like this in the following way:

  def safe_hasattr():
  marker = object()

  def safe_hasattr(obj, attr):
  return getattr(obj, attr, marker) is not marker

  return safe_hasattr

  safe_hasattr = safe_hasattr()

This way, there aren't any extra arguments or funny
globals to confuse matters.  (I've seen code that broke
because people tried to reuse marker definitions accross
modules.

BTW, I think this function or something like it should be
added to the Python standard library.  Anybody want to
try to get it into 2.5?

Jim

--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
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: hasattr implementation for Zope?

2005-05-27 Thread Tim Peters
[Tim Peters]
 OTOH, defining  importing a utility function-- say, safehasattr()
 --would make it all explicit.  That's what ZODB does.

[Paul Winkler]
 OK.
 
 (BTW, I just went grepping for this safehasattr() in zope 2.7.6's
 ZODB and didn't find anything. What's it called?)

No such thing in ZODB 3.2.  In 3.3+, it's called myhasattr, and is
imported from ZODB.serialize.  It should grow a saner name and move to
ZODB.utils instead:

def myhasattr(obj, name, _marker=object()):
Make sure we don't mask exceptions like hasattr().

We don't want exceptions other than AttributeError to be masked,
since that too often masks other programming errors.
Three-argument getattr() doesn't mask those, so we use that to
implement our own hasattr() replacement.

return getattr(obj, name, _marker) is not _marker
 
 There are ~700 calls to hasattr() currently in the Zope core (ouch!).
 Are there cases where the current use of hasattr() is considered safe?

Almost certainly, although who knows which?  I don't.  As a general
matter, it's hasattr() applied to a _persistent_ object that's
especially nasty.  Asking whether a persistent object has an attribute
can invoke an arbitrary amount of code, including network activity to
fetch the object's state, and potentially raising (say)
ReadConflictError or assorted socket errors.  It's Bad to hide those.

 Or since it's broken by design,  should we replace all 700
 calls with this hypothetical safe_hasattr()?

Spend an hour analyzing each one 0.9 wink.

 [the rest snipped not because it's uninteresting, but
  because I don't know enough to comment]
___
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: hasattr implementation for Zope?

2005-05-27 Thread Paul Winkler
On Fri, May 27, 2005 at 11:52:10AM -0400, Tim Peters wrote:
 Spend an hour analyzing each one 0.9 wink.

Let's compromise. I'll spend 0.9 hours analyzing one of them. ;-)

-- 

Paul Winkler
http://www.slinkp.com
___
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: hasattr implementation for Zope?

2005-05-27 Thread Paul Winkler
On Fri, May 27, 2005 at 11:49:03AM -0400, Jim Fulton wrote:
 BTW, I prefer to code things like this in the following way:
 
   def safe_hasattr():
   marker = object()
 
   def safe_hasattr(obj, attr):
   return getattr(obj, attr, marker) is not marker
 
   return safe_hasattr
 
   safe_hasattr = safe_hasattr()

 This way, there aren't any extra arguments or funny
 globals to confuse matters.  (I've seen code that broke
 because people tried to reuse marker definitions accross
 modules.

Interesting hack. It gets rid of the extra arguments and globals
all right, but it also makes the source a bit less obvious to read.
Does this play nicely with documentation extraction?
AFAICS the docstring must be given on the inner function definition.
 
-- 

Paul Winkler
http://www.slinkp.com
___
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: hasattr implementation for Zope?

2005-05-27 Thread Paul Winkler
On Fri, May 27, 2005 at 12:08:55PM -0400, Paul Winkler wrote:
 On Fri, May 27, 2005 at 11:49:03AM -0400, Jim Fulton wrote:
  BTW, I prefer to code things like this in the following way:
  
def safe_hasattr():
marker = object()
  
def safe_hasattr(obj, attr):
return getattr(obj, attr, marker) is not marker
  
return safe_hasattr
  
safe_hasattr = safe_hasattr()
 
  This way, there aren't any extra arguments or funny
  globals to confuse matters.  (I've seen code that broke
  because people tried to reuse marker definitions accross
  modules.

One more thought... as for funny globals, it seems to me that a 
private global like __marker = [] results in cleaner code than either
your approach or the keyword arg hack.  Anybody who imports a __foo name
deserves whatever problems they get :-)

But of course we don't do it because accessing globals in a method that
might be looped over is slow.  Which, hopefully, will become a non-issue
some day (PEP 267, 268, 280).

-- 

Paul Winkler
http://www.slinkp.com
___
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: hasattr implementation for Zope?

2005-05-27 Thread Jim Fulton

Paul Winkler wrote:

On Fri, May 27, 2005 at 12:08:55PM -0400, Paul Winkler wrote:


On Fri, May 27, 2005 at 11:49:03AM -0400, Jim Fulton wrote:


BTW, I prefer to code things like this in the following way:

 def safe_hasattr():
 marker = object()

 def safe_hasattr(obj, attr):
 return getattr(obj, attr, marker) is not marker

 return safe_hasattr

 safe_hasattr = safe_hasattr()

This way, there aren't any extra arguments or funny
globals to confuse matters.  (I've seen code that broke
because people tried to reuse marker definitions accross
modules.



One more thought... as for funny globals, it seems to me that a 
private global like __marker = [] results in cleaner code than either

your approach or the keyword arg hack.


I don't agree. In my approach, there isn't a global to begin with.

...


But of course we don't do it because accessing globals in a method that
might be looped over is slow.  Which, hopefully, will become a non-issue
some day (PEP 267, 268, 280).


Note that in my version above, marker is a local rather than a global
and gets looked up at local-variable speed.

Jim

--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
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: hasattr implementation for Zope?

2005-05-27 Thread Paul Winkler
On Fri, May 27, 2005 at 01:10:29PM -0400, Jim Fulton wrote:
 Paul Winkler wrote:
 On Fri, May 27, 2005 at 12:08:55PM -0400, Paul Winkler wrote:
 
 On Fri, May 27, 2005 at 11:49:03AM -0400, Jim Fulton wrote:
 
 BTW, I prefer to code things like this in the following way:
 
  def safe_hasattr():
  marker = object()
 
  def safe_hasattr(obj, attr):
  return getattr(obj, attr, marker) is not marker
 
  return safe_hasattr
 
  safe_hasattr = safe_hasattr()
 
 This way, there aren't any extra arguments or funny
 globals to confuse matters.  (I've seen code that broke
 because people tried to reuse marker definitions accross
 modules.
 
 
 One more thought... as for funny globals, it seems to me that a 
 private global like __marker = [] results in cleaner code than either
 your approach or the keyword arg hack.
 
 I don't agree. In my approach, there isn't a global to begin with.

Yeah, but to me, it seems like a nested function definition
and rebinding the name is a bit much bother just to avoid a single 
private global. It adds a bit of mental effort for readers who haven't
seen the idiom before, especially newcomers to python.

 Note that in my version above, marker is a local rather than a global
 and gets looked up at local-variable speed.

Yes, that is very nice.

-- 

Paul Winkler
http://www.slinkp.com
___
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: hasattr implementation for Zope?

2005-05-27 Thread Tim Peters
[Paul Winkler]
 But of course we don't do it because accessing globals in a method that
 might be looped over is slow.  Which, hopefully, will become a non-issue
 some day (PEP 267, 268, 280).

[Jim Fulton]
 Note that in my version above, marker is a local rather than a global
 and gets looked up at local-variable speed.

Nope, it's a cell reference to an enclosing scope, and gets looked
up at cell-dereference speed.  In my experience, that's generally a
bit slower than accessing a module global.  That may have to do with a
quirk of MSVC's code generation; unsure.

Here's a little program that times it 3 ways:


def lookup1(arg, _marker=object()):
return _marker

def lookup2():
_marker = object()
def lookup2(arg):
return _marker
return lookup2
lookup2 = lookup2()

_marker = object()
def lookup3(arg):
return _marker

from time import clock as now # s/clock/time/ on Linux
from itertools import repeat

for f in lookup1, lookup2, lookup3:
start = now()
for dummy in repeat(None, 100):
f(dummy)
finish = now()
print %-8s %.6g % (f.__name__, finish - start)


Under WinXP Python 2.4.1, the global trick (lookup3) is consistently
fastest, and the lexical scope trick (lookup2) is consistently
slowest; this is typical output across 3 runs:

lookup1  0.427597
lookup2  0.450777
lookup3  0.404399

lookup1  0.423195
lookup2  0.471619
lookup3  0.405306

lookup1  0.42321
lookup2  0.448071
lookup3  0.405078

Note that lookup1 has the overhead of installing the default arg into
the locals on each call, which is an expense neither lookup1 nor
lookup3 endure.

measurement-never-agrees-with-anyonewink-ly y'rs  - tim
___
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: hasattr implementation for Zope?

2005-05-27 Thread Jim Fulton

This is amazing.  Really amazing.  I stand corrected.

Jim

Tim Peters wrote:

[Paul Winkler]


But of course we don't do it because accessing globals in a method that
might be looped over is slow.  Which, hopefully, will become a non-issue
some day (PEP 267, 268, 280).



[Jim Fulton]


Note that in my version above, marker is a local rather than a global
and gets looked up at local-variable speed.



Nope, it's a cell reference to an enclosing scope, and gets looked
up at cell-dereference speed.  In my experience, that's generally a
bit slower than accessing a module global.  That may have to do with a
quirk of MSVC's code generation; unsure.

Here's a little program that times it 3 ways:


def lookup1(arg, _marker=object()):
return _marker

def lookup2():
_marker = object()
def lookup2(arg):
return _marker
return lookup2
lookup2 = lookup2()

_marker = object()
def lookup3(arg):
return _marker

from time import clock as now # s/clock/time/ on Linux
from itertools import repeat

for f in lookup1, lookup2, lookup3:
start = now()
for dummy in repeat(None, 100):
f(dummy)
finish = now()
print %-8s %.6g % (f.__name__, finish - start)


Under WinXP Python 2.4.1, the global trick (lookup3) is consistently
fastest, and the lexical scope trick (lookup2) is consistently
slowest; this is typical output across 3 runs:

lookup1  0.427597
lookup2  0.450777
lookup3  0.404399

lookup1  0.423195
lookup2  0.471619
lookup3  0.405306

lookup1  0.42321
lookup2  0.448071
lookup3  0.405078

Note that lookup1 has the overhead of installing the default arg into
the locals on each call, which is an expense neither lookup1 nor
lookup3 endure.

measurement-never-agrees-with-anyonewink-ly y'rs  - tim



--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
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: hasattr implementation for Zope?

2005-05-27 Thread Tim Peters
[Jim Fulton, on cell dereferencing's (lack of) speed]
 This is amazing.  Really amazing.  I stand corrected.

Well, there's no mystery if you look at LOAD_FAST and LOAD_DEREF in
ceval.c; LOAD_DEREF is slower wink.

The relative speed of approaches changes across Python releases too. 
For example, module global lookup benefited enormously from a long
string of heroic optimizations in Python's dict implementation.  I
consider a difference under 10% to be in the noise, and clawing for
one as likely to become a pessimization as to remain an optimization
under the next release; e.g., there are some obvious ways to speed
LOAD_DEREF (although I don't think anyone at present cares enough to
work on that).
___
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: hasattr implementation for Zope?

2005-05-27 Thread Sidnei da Silva
On Fri, May 27, 2005 at 01:49:00PM -0400, Tim Peters wrote:
| Under WinXP Python 2.4.1, the global trick (lookup3) is consistently
| fastest, and the lexical scope trick (lookup2) is consistently
| slowest; this is typical output across 3 runs:


Humm... May not be a surprise for you, but in one specific box here,
lookup1 is faster than lookup3 with python2.3 (consistent across 10 runs):

Python 2.3.5 (#2, May  4 2005, 08:51:39) 
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
[EMAIL PROTECTED] ~
[15:41:01] $ python2.3 ~/test.py 
lookup1  0.632889
lookup2  0.676374
lookup3  0.648941

Python 2.4.1 (#2, May  5 2005, 11:32:06) 
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
[EMAIL PROTECTED] ~
[15:41:15] $ python2.4 ~/test.py 
lookup1  0.58283
lookup2  0.598244
lookup3  0.560118

On my (ld) PowerBook though, lookup3 is consistently faster:

Python 2.3.5 (#2, May  6 2005, 11:52:38) 
[GCC 4.0.0 20050413 (prerelease) (Debian 4.0-0pre11)] on linux2
[EMAIL PROTECTED]:~$ python2.3 test.py
lookup1  2.75203
lookup2  2.83231
lookup3  2.60754

Python 2.4.1 (#2, May  5 2005, 10:40:57) 
[GCC 4.0.0 20050413 (prerelease) (Debian 4.0-0pre11)] on linux2
[EMAIL PROTECTED]:~$ python2.4 test.py
lookup1  2.56144
lookup2  2.65824
lookup3  2.44022

I suspect the compiler might play some role in there 0.125 wink /.

-- 
Sidnei da Silva [EMAIL PROTECTED]
http://awkly.org - dreamcatching :: making your dreams come true
http://www.enfoldsystems.com
http://plone.org/about/team#dreamcatcher

dreid lispachu, parentheses attack!
___
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: hasattr implementation for Zope?

2005-05-27 Thread Paul Winkler
On Fri, May 27, 2005 at 01:49:00PM -0400, Tim Peters wrote:
 Nope, it's a cell reference to an enclosing scope, and gets looked
 up at cell-dereference speed.  In my experience, that's generally a
 bit slower than accessing a module global.  That may have to do with a
 quirk of MSVC's code generation; unsure.

Wow. If so, gcc apparently shares the same quirk.
With python 2.3.5 on my ancient gentoo box,
I get this (after substituting time.time for time.clock):

lookup1  1.55095
lookup2  1.57738
lookup3  1.4966

This is so suprising to me that I went ahead and tried
a couple of variations that I figured *must* be slower:

def lookup4(arg):
# Doesn't get much simpler than this. 
return object()

class C:
   
# ok this one is pretty silly
 
_marker = object()

def lookup5(self, arg):
return self._marker

lookup5 = C().lookup5

lookup1  1.53485
lookup2  1.57811
lookup3  1.47942
lookup4  2.33403
lookup5  2.0232

measurement-never-agrees-with-anyone-except-when-you-wish-it-didn't-ly y'rs,
 - Paul

-- 

Paul Winkler
http://www.slinkp.com
___
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 )


[Zope-dev] Re: hasattr implementation for Zope?

2005-05-27 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Tim Peters wrote:
Vewy strange -- it looks as though OS-level caching matters here:

$ python
Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type help, copyright, credits or license for more information.

$ python test_lookup.py
lookup1  0.91
lookup2  0.45
lookup3  0.4
$ python test_lookup.py
lookup1  0.67
lookup2  0.48
lookup3  0.41
$ python test_lookup.py
lookup1  0.57
lookup2  0.55
lookup3  0.5
$ python test_lookup.py
lookup1  0.45
lookup2  0.44
lookup3  0.4
$ python test_lookup.py
lookup1  0.45
lookup2  0.44
lookup3  0.41
$ python test_lookup.py
lookup1  0.45
lookup2  0.45
lookup3  0.4
\$ python test_lookup.py
lookup1  0.45
lookup2  0.44
lookup3  0.41
$ ~/projects/Zope-CVS/bin/python
Python 2.3.5 (#1, Apr 11 2005, 13:18:06)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type help, copyright, credits or license for more information.

$ ~/projects/Zope-CVS/bin/python test_lookup.py
lookup1  1.24
lookup2  0.59
lookup3  0.48
$ ~/projects/Zope-CVS/bin/python test_lookup.py
lookup1  0.49
lookup2  0.51
lookup3  0.48
$ ~/projects/Zope-CVS/bin/python test_lookup.py
lookup1  0.49
lookup2  0.52
lookup3  0.47
$ ~/projects/Zope-CVS/bin/python test_lookup.py
lookup1  0.5
lookup2  0.51
lookup3  0.47
$ ~/projects/Zope-CVS/bin/python test_lookup.py
lookup1  0.5
lookup2  0.51
lookup3  0.47
$ ~/projects/Zope-CVS/bin/python test_lookup.py
lookup1  0.49
lookup2  0.51
lookup3  0.47

But then again, the same is true for pystones:

$ python ~/projects/Zope-CVS/lib/python2.3/test/pystone.py Pystone(1.1)
time for 5 passes = 1.39
This machine benchmarks at 35971.2 pystones/second
$ python ~/projects/Zope-CVS/lib/python2.3/test/pystone.py
Pystone(1.1) time for 5 passes = 1.15
This machine benchmarks at 43478.3 pystones/second
$ python ~/projects/Zope-CVS/lib/python2.3/test/pystone.py
Pystone(1.1) time for 5 passes = 0.96
This machine benchmarks at 52083.3 pystones/second
$ python ~/projects/Zope-CVS/lib/python2.3/test/pystone.py
Pystone(1.1) time for 5 passes = 0.98
This machine benchmarks at 51020.4 pystones/second
$ python ~/projects/Zope-CVS/lib/python2.3/test/pystone.py
Pystone(1.1) time for 5 passes = 0.96
This machine benchmarks at 52083.3 pystones/second
$ python ~/projects/Zope-CVS/lib/python2.3/test/pystone.py
Pystone(1.1) time for 5 passes = 0.96
This machine benchmarks at 52083.3 pystones/second


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

iD8DBQFCl3Jg+gerLs4ltQ4RAvMfAKC5JP/FOXvDPDCf25CqzisDd/2OZwCfdgNV
yj0HH8oY37wc3urgKLZE21k=
=Y7gD
-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 )


[Zope-dev] Re: hasattr implementation for Zope?

2005-05-27 Thread Tim Peters
We're getting the usual timing results here:  it's a cross-platform,
cross-release crapshoot.  Aiming at (just) a few percent really is
worthless -- modern processors and OSes are too complex to out-think
uniformly in the small, and even if Python variability didn't
contribute to the differences.

[Tres]

 But then again, the same is true for pystones:

 $ python ~/projects/Zope-CVS/lib/python2.3/test/pystone.py Pystone(1.1)
 time for 5 passes = 1.39
 This machine benchmarks at 35971.2 pystones/second
 $ python ~/projects/Zope-CVS/lib/python2.3/test/pystone.py
 Pystone(1.1) time for 5 passes = 1.15
 This machine benchmarks at 43478.3 pystones/second
 ...

My favorite in this respect will always be Win98SE.  Running pystone
after a boot gave a figure almost exactly twice as large (i.e.,
faster) than running pystone a second, third, ... time.  One way to
get back the original speed was to reboot.  The other way was to write
a little Python program that systematically allocated all of RAM,
until it died with MemoryErrror.  It didn't matter how much RAM you
had -- a dozen MB or hundreds, same thing.  This was some kind of
Satanic OS reverse caching, I guess 0.5 wink.
___
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] DTML in Zope 2 vs Zope 3

2005-05-27 Thread Tino Wildenhain
Am Freitag, den 27.05.2005, 00:20 +0200 schrieb Jaroslav Lukesh:
...
 I absolutelly agree with you, it is like my words.
 
 But separation of logic and presentation could be done successfully in DTML
 too. ZPT, which have separation argument is not as easy to make totally

This is even somewhat correct. If people had the discipline to not abuse
the templating to do complicated logic. 
The major drawbacks of DTML are: 

- one namespace (with transparent layers)
- confusing naming of tags, like dtml-var which
  really is dtml-print or something
- and the extra tags for flow control, but probably
  the dtml fans can live with it.
- peoples practice to use dtml-var foo even inside
  html-tags attributes, where dtml-foo; should be used.

 separated design as marketing says, for example see Plone - try to customize
 plone site to absolutelly different custom design - it is near impossible.

Unfortunately Plone is still a bad example for ZPT. It is getting
better but still it has a lot of code and definition in the templates.
Maybe AT would be a way out.

___
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] DTML in Zope 2 vs Zope 3

2005-05-27 Thread Greg Fischer
Wow, thanks for the replies guys.  It's good to hear I am not the only
one who likes DTML.

Tino, thanks for the explanations.  I have some thoughts below on
that, and keep in mind, I am questioning from my own ignorance.

Tino Wrote:
 The major drawbacks of DTML are:
 
 - one namespace (with transparent layers)  
One namespace?  Why do you need more?  I havent had any problems with
one.  Can you give some examples of why this is important or how it
would be useful?

 - confusing naming of tags, like dtml-var which
   really is dtml-print or something
Well I realize that it could be named something else, but it never
occured to me.  I dont think it's confusing.  I mean, in DTML you use
4 tags more than any other, IN, VAR, IF, and CALL.  Simple.  And if
there is one thing I have learned over the few years I have been
programming, it is to keep it simple. Simple works.

 - and the extra tags for flow control, but probably
   the dtml fans can live with it.
Yeah, simple.  We can live with it, particularly since we can call
more detailed functionality from Python.

 - peoples practice to use dtml-var foo even inside
   html-tags attributes, where dtml-foo; should be used.
Hmm.. Never thought of that one as I too just use the full dtml-var
foo.  I can see now that it might make readability a little better to
use dtml, but is there a technical reason for using it that way?

Thank you again for your input Tino.  I can understand the need to
take Zope to another level, its the nature of things to keep them
growing.  And changing Zope to fit the needs of large scale
applications is good, I just hate to see the sacrifice of the smaller
apps needs.  I probably will never get to work on enterprise class
systems, in fact I really dont want to, but Zope works beautifully for
the small web apps and that's what I want to work on.  I wonder what
the ratio is of Zope users who use small apps to those who do large
apps?

Thanks again!

Greg

On 5/26/05, Tino Wildenhain [EMAIL PROTECTED] wrote:
 Am Freitag, den 27.05.2005, 00:20 +0200 schrieb Jaroslav Lukesh:
 ...
  I absolutelly agree with you, it is like my words.
 
  But separation of logic and presentation could be done successfully in DTML
  too. ZPT, which have separation argument is not as easy to make totally
 
 This is even somewhat correct. If people had the discipline to not abuse
 the templating to do complicated logic.
 The major drawbacks of DTML are:
 
 - one namespace (with transparent layers)
 - confusing naming of tags, like dtml-var which
   really is dtml-print or something
 - and the extra tags for flow control, but probably
   the dtml fans can live with it.
 - peoples practice to use dtml-var foo even inside
   html-tags attributes, where dtml-foo; should be used.
 
  separated design as marketing says, for example see Plone - try to customize
  plone site to absolutelly different custom design - it is near impossible.
 
 Unfortunately Plone is still a bad example for ZPT. It is getting
 better but still it has a lot of code and definition in the templates.
 Maybe AT would be a way out.
 
 ___
 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 )
 


-- 
Greg Fischer
1st Byte Solutions
http://www.1stbyte.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] Finding an object in a folder

2005-05-27 Thread Chris Withers

Paul Winkler wrote:


marker = ()
if getattr(some_object, marker) is not marker:


For good measure, I wonder if that should be a [], no a ()?

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk

___
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] DTML in Zope 2 vs Zope 3

2005-05-27 Thread Chris Withers

Tino Wildenhain wrote:

Unfortunately Plone is still a bad example for ZPT. It is getting
better but still it has a lot of code and definition in the templates.
Maybe AT would be a way out.


AT? As in ArcheTypes? You ARE kidding right? I've never seen such bad 
code, and in particular, abuse of ZPT in my entire life...


And DTML sux, you wanna use it, fine, that says something about you. Use 
ZClasses, Plone, AT and XUF at the same time while you're at it. Why not 
dig out LoginManager and ZPatterns too, just for good measure?


Hell, why not just do us all a favour and switch to using Perl where 
you'll be s much happier, and everyone in the community will agree 
with you rather than trying to help you not shoot yourself in the foot ;-)


cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk

___
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] UnicodeDecodeError

2005-05-27 Thread Chris Withers

Dieter Maurer wrote:

  Only the default is latin-1 (as specified by the HTML
  specification).


Indeed, but that should be configurable...

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk

___
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] DTML in Zope 2 vs Zope 3

2005-05-27 Thread Hugo Ramos
On 5/27/05, Chris Withers [EMAIL PROTECTED] wrote:
 AT? As in ArcheTypes? You ARE kidding right? I've never seen such bad
 code, and in particular, abuse of ZPT in my entire life...
 
 And DTML sux, you wanna use it, fine, that says something about you. Use
 ZClasses, Plone, AT and XUF at the same time while you're at it. Why not
 dig out LoginManager and ZPatterns too, just for good measure?
 
 Hell, why not just do us all a favour and switch to using Perl where
 you'll be s much happier, and everyone in the community will agree
 with you rather than trying to help you not shoot yourself in the foot ;-)

Is it me or are you really pissed??? :-)
At least give DTML some credit... It's what made Zope so popular in
the first days because of easy and fast learning curve!!!

Regards
Hugo

-- 
Hugo Ramos - [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] Finding an object in a folder

2005-05-27 Thread Paul Winkler
On Fri, May 27, 2005 at 08:51:58AM +0100, Chris Withers wrote:
 Paul Winkler wrote:
 
 marker = ()
 if getattr(some_object, marker) is not marker:
 
 For good measure, I wonder if that should be a [], no a ()?

What's wrong with a tuple? There's no reason to mutate the marker. 

-- 

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 )


[Zope] Saving the html-code

2005-05-27 Thread Flemming Bjerke
With a dtml-script I renders data from a mysql-database. But, sometimes I 
should like to save the html-code generated by the script. When I try to do 
this with a pythonscript I run into problems with acquiring the html-code 
generated by the dtml-script. I looks like the dtml-script does not get the 
proper namespace. 

How do I solve this?

Flemming

___
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] LDAPUserFolder at Zope root

2005-05-27 Thread Jens Vagelpohl


On May 26, 2005, at 22:34, J Cameron Cooper wrote:


Oscar Figueiredo wrote:


this might be trivial but I just can't find a way to do it.  How  
does one
replace the initial UserFolder at Zope root with a  
LDAPUSerFolder ?  I tried the dummy way : delete the acl_users  
with an intent to instanciate a
LDAPUSerFolder afterwards but that locked me out in a way I could  
do nothing

but recreate a new Zope instance...  skip-authentication-checking in
etc/zope.conf didn't help...



Do not do that. You don't want to get locked out of your Zope  
because of LDAP problems.


The emergency user always works. You can't lock yourself out due to  
LDAP problems. If anyone sees a symptom like that on the current  
LDAPUserFolder version it will be fixed right away because it is a bug.


jens

___
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] DTML in Zope 2 vs Zope 3

2005-05-27 Thread Lennart Regebro
On 5/26/05, Greg Fischer [EMAIL PROTECTED] wrote:
 Is DTML really that much harder to use?

Nah, but it's uglier. Also, the idea is that a web editor that
confirms to the tsandard of ignoring things it doens't understand,
should in theory be usable with TAL, but not with DTML. In practice,
however, HTML editors don't do that.

 I understand the whole idea of separating the logic and the
 presentation, and I guess, is that part of the reason why DTML is not
 as good?  

Well, it used to be. But logic crept into ZPTs as well. The good thing
is to set up all the data in a python script or python method, and
then use the template only to display this data. Zope3 has this
separation built-in, when you create a page with a template it
automatically gets connected to a view which is a python class, and
you can specify your own custom view and set up the data there.

In Zope 2 you have to call a script that creates the data, or
reversely, use the script as the main view and let it call the
template. (I don't know how easy that last thing is with DTML, but the
first one works).

If you do this, the drawbacks of DTML becomes much less painful.
-- 
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
___
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 MailHost Query

2005-05-27 Thread Varun Parange
hi, 

how do i receive mails using Zope mailhost??

		Do You Yahoo!? Yahoo! Small Business - Try our new Resources site!___
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 MailHost Query

2005-05-27 Thread Andreas Jung



--On Freitag, 27. Mai 2005 3:15 Uhr -0700 Varun Parange 
[EMAIL PROTECTED] wrote:



hi,

 how do i receive mails using Zope mailhost??


MailHost is only for *sending* but not for receiving mails. Zope is *not* 
an SMTP server.


-aj




pgpSF9JJiUCyr.pgp
Description: 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] Finding an object in a folder

2005-05-27 Thread Florent Guillaume
Paul Winkler  [EMAIL PROTECTED] wrote:
 On Fri, May 27, 2005 at 08:51:58AM +0100, Chris Withers wrote:
  Paul Winkler wrote:
  
  marker = ()
  if getattr(some_object, marker) is not marker:
  
  For good measure, I wonder if that should be a [], no a ()?
 
 What's wrong with a tuple? There's no reason to mutate the marker. 

The whole point of a marker is that it is unique, so cannot be confused
with a legitimate value of the object examined.

And all empty tuples are equal.

In python 2.3, the idiom most commonly found is to use marker = object().

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of RD
+33 1 40 33 71 59   http://nuxeo.com   [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 )


[Zope] Re: Finding an object in a folder

2005-05-27 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Paul Winkler wrote:
 On Fri, May 27, 2005 at 08:51:58AM +0100, Chris Withers wrote:
 
Paul Winkler wrote:


marker = ()
if getattr(some_object, marker) is not marker:

For good measure, I wonder if that should be a [], no a ()?
 
 
 What's wrong with a tuple? There's no reason to mutate the marker. 

In Python, there is only empty tuple object,  while each empty list is a
distinct object.  For use as a marker, the empty list can't return a
false positive, while the empty tuple can.

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

iD8DBQFClw9J+gerLs4ltQ4RAtyCAJ4y+h+rDtSmo+Sa2n5K+h87z/24DwCgwBFY
9Wrhk9aGMBUPm1DxsOpewec=
=O5re
-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] Namespace for PythonScript

2005-05-27 Thread Dieter Maurer
Hong Yuan wrote at 2005-5-27 00:07 +0800:
If a PythonScript is called from a Page Template, how can it access the 
variables defined using:
   tal:define=global ... /
in the calling script?

It may work to bind the namespace binding.

Not sure, though...

-- 
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] Saving the html-code

2005-05-27 Thread Dieter Maurer
Flemming Bjerke wrote at 2005-5-27 11:20 +0200:
With a dtml-script I renders data from a mysql-database. But, sometimes I 
should like to save the html-code generated by the script. When I try to do 
this with a pythonscript I run into problems with acquiring the html-code 
generated by the dtml-script. I looks like the dtml-script does not get the 
proper namespace. 

Where do you want to store the result and why?

One of the easiest solutions would be caching (e.g. by
a RamCacheManager).


-- 
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] Finding an object in a folder

2005-05-27 Thread Dieter Maurer
Paul Winkler wrote at 2005-5-27 05:07 -0400:
 ...
What's wrong with a tuple? There's no reason to mutate the marker. 

The Python spec allows implementations to identify immutable objects
with the same value. Thus, in principle, two () created
at different times can in fact be the same object.
This would violate our use as a marker.

Python specifies that mutable objects created at different times
are garanteed to be different (as long as both exist).
Therefore, you can use them safely as markers.

-- 
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] Finding an object in a folder

2005-05-27 Thread Dieter Maurer
Paul Winkler wrote at 2005-5-26 19:57 -0400:
 ...
 Make it so! :-)
 
   _marker = []
   def hasattr(obj, attr, marker):

I introduced a bug here (noticed by Alec Mitchell).

The marker argument should have been _marker=_marker.

 ...
Are you currently running zope with a patch like this?

No, because I never really met an hasattr bug (although
I acknowledge that it may happen).

Have you noticed any performance difference?
the zope 2.6 source code contains over 700 calls to hasattr()...

We replace a small C-implemented function with a small Python one.
Although the Python function may be about 10 times slower,
the overall effect is almost surely negligible.

A higher risk comes from the fact that some Python packages may
rely on the broken hasattr behaviour. That's the reason why
the problem is not fixed in Python itself.

-- 
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] Finding an object in a folder

2005-05-27 Thread Paul Winkler
On Fri, May 27, 2005 at 01:58:44PM +0200, Florent Guillaume wrote:
 And all empty tuples are equal.

Not just equal, but all empty tuples are *identical*,
so () is () == True. 

I had no idea this was so :-\
 
 In python 2.3, the idiom most commonly found is to use marker = object().

Thanks for that.

-- 

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] Finding an object in a folder

2005-05-27 Thread Paul Winkler
On Fri, May 27, 2005 at 03:26:04PM +0200, Dieter Maurer wrote:
 A higher risk comes from the fact that some Python packages may
 rely on the broken hasattr behaviour. That's the reason why
 the problem is not fixed in Python itself.

And that's a very good reason not to monkeypatch it.
We can't have arbitrary third-party packages breaking when
they are used with Zope. Such bugs could be maddeningly difficult
to diagnose and find.

Anyway, Jim has made a papal edict on zope-dev:
We will never monkeypatch hasattr in the zope core.

-- 

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] Saving the html-code

2005-05-27 Thread Flemming Bjerke
Fredag den 27. maj 2005 15:33 skrev Dieter Maurer:
 Flemming Bjerke wrote at 2005-5-27 11:20 +0200:
 With a dtml-script I renders data from a mysql-database. But, sometimes I
 should like to save the html-code generated by the script. When I try to
  do this with a pythonscript I run into problems with acquiring the
  html-code generated by the dtml-script. I looks like the dtml-script does
  not get the proper namespace.

 Where do you want to store the result and why?
The actual use was to send the resulting html-file as attachment to 
maililnglist mails. 

 One of the easiest solutions would be caching (e.g. by
 a RamCacheManager).
Well, then I must look at how. Thanks.

Flemming
___
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] Opening .doc files in zope

2005-05-27 Thread Allen Huang
Is there any way to open a .doc files using dtml or script and print them??
		Yahoo! Mail 
Stay connected, organized, and protected. Take the tour___
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] Opening .doc files in zope

2005-05-27 Thread Dennis Allison
On Fri, 27 May 2005, Allen Huang wrote:

 Is there any way to open a .doc files using dtml or script and print them??
 

The short answer is it depends.  To make such files generally available 
you have to convert them to HTML so arbirary browsers can access them.  
You can use MS Word to do the conversion.  If your Zope is running on a 
Windows machine that also has Word, you can manage the conversion 
dynamically using an External Method or a Product (which you'd have to 
write).  Alternatively, you could store the MS Word document in it's XML
form and use that to drive the rendering.   If you are not interested in 
general availability and you users are all running Windows with Word 
installed, you can configure IE, I believe, to render Word documents 
directly.



___
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] DTML in Zope 2 vs Zope 3

2005-05-27 Thread Greg Fischer
Using DTML from WYSIWYG editors is definitely a drawback.  But, how
many of us use them for doing our work?  I might use Dreamweaver to
clean up my sliced web template, but soon as I start my Zope work,
it's all Crimson Editor coding by hand to Zope.  Using Dreamweaver
actually slows me down, it's easier to just code it.  However, from a
newbie perspective, not being able to run my Zope content in my fancy,
drag'n'drop editor really bugged me a long time a go.

Saying DTML sucks is only stating your difference of oppinion.  At
least give us some insight as to why it sucks.  Technical, usability,
or even marketing reasons would be helpful.  But, come on DUH? 
Everybody will have their preference of languages, and even the way
they like to layout the code.  So I understand that some of us like
DTML and some dont.

All that aside, DTML may be ugly, but I dont agree.  I guess beauty is
in the eye of the beholder. :)

Well, aside from the fact that you cant use DTML in WYSIWYG editors, I
still dont understand why it is not good.  If it is simple, easy to
use, and it does the job, and I suppose, if you prefer it, why is it
not good to use?

I've beaten this subject to death, so time to move on.
Thanks for hearing me out.
Greg

On 5/27/05, Lennart Regebro [EMAIL PROTECTED] wrote:
 On 5/26/05, Greg Fischer [EMAIL PROTECTED] wrote:
  Is DTML really that much harder to use?
 
 Nah, but it's uglier. Also, the idea is that a web editor that
 confirms to the tsandard of ignoring things it doens't understand,
 should in theory be usable with TAL, but not with DTML. In practice,
 however, HTML editors don't do that.
 
  I understand the whole idea of separating the logic and the
  presentation, and I guess, is that part of the reason why DTML is not
  as good?
 
 Well, it used to be. But logic crept into ZPTs as well. The good thing
 is to set up all the data in a python script or python method, and
 then use the template only to display this data. Zope3 has this
 separation built-in, when you create a page with a template it
 automatically gets connected to a view which is a python class, and
 you can specify your own custom view and set up the data there.
 
 In Zope 2 you have to call a script that creates the data, or
 reversely, use the script as the main view and let it call the
 template. (I don't know how easy that last thing is with DTML, but the
 first one works).
 
 If you do this, the drawbacks of DTML becomes much less painful.
 --
 Lennart Regebro, Nuxeo http://www.nuxeo.com/
 CPS Content Management http://www.cps-project.org/
 


-- 
Greg Fischer
1st Byte Solutions
http://www.1stbyte.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 )


[Zope] Re: Opening .doc files in zope

2005-05-27 Thread Josef Meile
The short answer is it depends.  To make such files generally available 
you have to convert them to HTML so arbirary browsers can access them.  
You can use MS Word to do the conversion.  If your Zope is running on a 
Windows machine that also has Word, you can manage the conversion 
dynamically using an External Method or a Product (which you'd have to 
write).  Alternatively, you could store the MS Word document in it's XML
form and use that to drive the rendering.   If you are not interested in 
general availability and you users are all running Windows with Word 
installed, you can configure IE, I believe, to render Word documents 
directly.

In addition, you could use the wmWare libraries to convert the word
files to html/pdf, but they don't work well with complicated word
documents. You can download there here:

http://wvware.sourceforge.net   - linux
http://gnuwin32.sourceforge.net/packages/wv.htm - Windows

Regards,
Josef

___
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] DTML in Zope 2 vs Zope 3

2005-05-27 Thread Greg Fischer
Ah you are right.  Just occured to me.  That is kind of a pain in
DTML, but I've learned how to deal with it.  Makes sense.

If I already have an object, say from a form submitted, in the REQUEST
namespace, and I then retrieve data from sql and a column has the same
name, I will have an issue.  Which one is going to display in my var?

I deal with this particular issue by changing my zsql method to return
the column name differently, but there are other times when this may
arise and it is a problem. And this causes you to have to do a bunch
of messy dtml-call REQUEST.set's to set your vars correctly.

I have learned how to deal with these things, but you are right, this
is a problem with DTML and I can see how this exact issue helps make
DTML messy and a little confusing.  Great point.  Thanks.

Greg

On 5/27/05, Lennart Regebro [EMAIL PROTECTED] wrote:
 On 5/27/05, Greg Fischer [EMAIL PROTECTED] wrote:
  Well, aside from the fact that you cant use DTML in WYSIWYG editors, I
  still dont understand why it is not good.
 
 Well, the fact that you get everyting directly into the current
 namespace, especially with DTML-in, and things like that, is the real
 problem. But as noted, by making all data-gathering in a python
 script, the problems with this are less and survivable.
 
 --
 Lennart Regebro, Nuxeo http://www.nuxeo.com/
 CPS Content Management http://www.cps-project.org/
 


-- 
Greg Fischer
1st Byte Solutions
http://www.1stbyte.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] LDAPUserFolder at Zope root

2005-05-27 Thread J Cameron Cooper

Jens Vagelpohl wrote:


On May 26, 2005, at 22:34, J Cameron Cooper wrote:


Oscar Figueiredo wrote:


this might be trivial but I just can't find a way to do it.  How  
does one
replace the initial UserFolder at Zope root with a  LDAPUSerFolder ?  
I tried the dummy way : delete the acl_users  with an intent to 
instanciate a
LDAPUSerFolder afterwards but that locked me out in a way I could  do 
nothing

but recreate a new Zope instance...  skip-authentication-checking in
etc/zope.conf didn't help...



Do not do that. You don't want to get locked out of your Zope  because 
of LDAP problems.



The emergency user always works. You can't lock yourself out due to  
LDAP problems. If anyone sees a symptom like that on the current  
LDAPUserFolder version it will be fixed right away because it is a bug.


Yes, you can always break into Zope that way. But that's not something I 
would want to plan to do, especially when the alternative is so easy.


--jcc

--
Building Websites with Plone
http://plonebook.packtpub.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 )


[Zope] Receiving mails

2005-05-27 Thread Varun Parange
hi,
i have downloaded an SMTP server and using it i can send mails with the help of Zope MailHost

however i would also like to recieve mails how do i do this.
which additional products do i need to download... 

regards,
varun
__Do You Yahoo!?Tired of spam?  Yahoo! Mail has the best spam protection around http://mail.yahoo.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] Receiving mails

2005-05-27 Thread J Cameron Cooper

Varun Parange wrote:

i have downloaded an SMTP server and using it i can send mails with the 
help of Zope MailHost
 
however i would also like to recieve mails how do i do this.

which additional products do i need to download...


I recall some people talking about actually turning Zope into a mail 
server. Frankly, I think that's a little crazy, but it might work. You 
can search the list if you're interested.


A more common usage is to have a POP or IMAP server somewhere and use 
Zope as a client for that. There exist several products for doing 
webmail in Zope.


http://www.pentila.com/produits/WebMail/
http://plonewebmail.openprojects.it/

for instance.

--jcc

--
Building Websites with Plone
http://plonebook.packtpub.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] Receiving mails

2005-05-27 Thread David H

Varun Parange wrote:


hi,
i have downloaded an SMTP server and using it i can send mails with 
the help of Zope MailHost
 
however i would also like to recieve mails how do i do this.

which additional products do i need to download...
 
regards,

varun
 

 


Varun,

I wrote a spam filter using wxpython - but all the incoming mail uses 
standard python libraries:  poplib, rfc822, email.Parser.  Just write an 
external python script to handle. 


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 )


Re: [Zope] Finding an object in a folder

2005-05-27 Thread Paul Winkler
On Tue, May 24, 2005 at 08:59:01PM +0200, Dieter Maurer wrote:
 An incredibly long time ago, I filed a feature request for
 hasattr_unacquired -- together with patch, unit tests and documentation
 update. 

Do you mean this?
http://www.zope.org/Collectors/Zope/742

the unit tests and docs are missing.
But I like the idea.

-- 

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 )


[Zope] XML Content handling questions.

2005-05-27 Thread Nikko Wolf

Three questions, in order of importance (to me):

1) Is it possible to validate an (uploaded) XML file against a schema
  (currently on the Zope server)?
   What, if any, extra packages are needed?I want to use this in my
   upload forms to alert the user if their files are invalid.

2) I also need to serve up web-based forms and allow the user to create
   XML content based on a user-selected schema.  Something
   like what Chiba (http://chiba.sf.net/) is targeting.   Of course,
   though, that isn't a Python/Zope solution.  Has anyone seen anything
   that works?  At this point, installing Tomcat and Chiba is what I
   presume I'll be doing in a couple of weeks

3) Is there a function built-in to Zope that allows merging XML files?
   (ie: all the abc within a list of user-selected files).
   I've got an Extension that works correctly (using the Amara/4Suite
   packages), so an answer here is mostly for me to learn Zope better.


Thanks,
Nikko.

PS: I'm pretty new to Python  Zope, but not web servers or other
programming.

Server:
   Fedora Core 3
   Python 2.3.4
   Zope 2.7.6-final
   Plone 2.0.5
   4Suite 1.0b1
   Amara 1.0b2



___
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] Create a list using DTML.

2005-05-27 Thread Fernando Lujan
On 24/05/05, J Cameron Cooper [EMAIL PROTECTED] wrote:

 Personally, I'd probably just do something like::
   {1,2,3}[1:-1].split(',')
 
This code works as expected... Thanks! :)

--
Fernando Lujan
___
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] DTML in Zope 2 vs Zope 3

2005-05-27 Thread Andrew Milton
+---[ Jonathan Cyr ]--
| Damn users, using all this imperfect software. These Kids Today!  ;-)
| 
| Easy Big Fella, Whooa.
| 

You must be new here We've all learnt to ignore Chris... 

He gets easily confused... or maybe he doesn't take his medication... not
sure, but, ignoring him generally works for the best d8)

-- 
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] XML Content handling questions.

2005-05-27 Thread Andreas Jung

Zope itself has no native XML support. However there are some products like
ParsedXML that provide additional functionality. You might also look at 
Silva CMS

which is provides native XML support.

-aj

--On 27. Mai 2005 14:53:40 -0600 Nikko Wolf [EMAIL PROTECTED] 
wrote:



Three questions, in order of importance (to me):

1) Is it possible to validate an (uploaded) XML file against a schema
   (currently on the Zope server)?
What, if any, extra packages are needed?I want to use this in my
upload forms to alert the user if their files are invalid.

2) I also need to serve up web-based forms and allow the user to create
XML content based on a user-selected schema.  Something
like what Chiba (http://chiba.sf.net/) is targeting.   Of course,
though, that isn't a Python/Zope solution.  Has anyone seen anything
that works?  At this point, installing Tomcat and Chiba is what I
presume I'll be doing in a couple of weeks

3) Is there a function built-in to Zope that allows merging XML files?
(ie: all the abc within a list of user-selected files).
I've got an Extension that works correctly (using the Amara/4Suite
packages), so an answer here is mostly for me to learn Zope better.


Thanks,
Nikko.

PS: I'm pretty new to Python  Zope, but not web servers or other
programming.

Server:
Fedora Core 3
Python 2.3.4
Zope 2.7.6-final
Plone 2.0.5
4Suite 1.0b1
Amara 1.0b2



___
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 )






pgp0qga7DYUCD.pgp
Description: 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 )