Re: [Zope] File upload again

2011-10-14 Thread Peter Bengtsson
How about something like:
dtml-in PyS_csvimport(fcsv.read()) prefix=pys


On 14 October 2011 10:29, Jaroslav Lukesh luk...@seznam.cz wrote:
 Hi all,

 I want upload csv file for direct processing into SQL only, not for save to
 ZODB nor LocalFS. Upload for LocalFS already worked for me.

 So I have form:

 form method=POST enctype=multipart/form-data
        input type=file name=fcsv value= size=50br
        input type=file name=fcsv2 value= size=50br
       input type=submit name=fileupload value=Upload
 /form

 Diagnostic processing:
 dtml-var fcsv.filename::dtml-var fcsv.headers['Content-Type']
 ::dtml-var fcsv
 And what it get:
 data_2011.CSV::application/vnd.ms-excel::

 Su upload worked, but what I can access to data of the uploaded file?

 the dtml-in does not process anything, only displays NO DATA.

    dtml-in PyS_csvimport(fcsv) prefix=pys
        dtml-var pys_itembr
    dtml-else
         NO DATA
    /dtml-in

 PyS_csvimport parse CSV file by line and return array structure like this
 [['',''],['','']].

 If I use TEXTAREA instead of file upload, dtml-in works.

 How to get CSV file content to processing?

 Many thanks,

 Jaroslav Lukesh



 PS: HTTP Request loks like that:

 http://myhost/csvimport/

 POST /csvimport/ HTTP/1.1
 Host: myhost
 (..)
 Content-Type: multipart/form-data;
 boundary=---30333176734664
 Content-Length: 21822
 -30333176734664
 Content-Disposition: form-data; name=fcsv; filename=data_2011.CSV
 Content-Type: application/vnd.ms-excel

 (bulk od CSV data.)
 -30333176734664
 Content-Disposition: form-data; name=fcsv2; filename=data_2011_kd.CSV
 Content-Type: application/vnd.ms-excel

 (bulk od CSV data.)
 -30333176734664
 Content-Disposition: form-data; name=fileupload

 Upload
 -30333176734664--

 HTTP/1.1 200 OK
 Server: Zope/(Zope 2.10.13-final, python 2.4.6, linux2) ZServer/1.1
 Date: Fri, 14 Oct 2011 09:21:48 GMT
 Content-Length: 2389
 Content-Type: text/html; charset=cp1250

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




-- 
Peter Bengtsson,
home www.peterbe.com
fun kwissle.com
work www.mozilla.com
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] 2.13 upgrade problems

2011-06-03 Thread Peter Bengtsson
I'm getting the error below when trying to boot up a zope 2.13.7 using
a Data.fs I took from a zope 2.8.12 instance.
Having Products.ZSQLMethods-2.13.3 installed or not installed doesn't
appear to be relevant.
The fortunate thing, in this instance, is that the SQLMethods in that
instance are not important to me so I'd be happy to delete them if I
could.
However, I tried with ./bin/zopectl debug
 del app.www['id_of_a_zsql_method']
but that raises the same TypeError.

Any ideas?


2011-06-03 11:36:27 ERROR ZODB.Connection Couldn't load state for 0x5528
Traceback (most recent call last):
  File 
/Users/peterbe/dev/ZOPE/Zope2-2.13.7/eggs/ZODB3-3.10.2-py2.6-macosx-10.4-x86_64.egg/ZODB/Connection.py,
line 856, in setstate
self._setstate(obj)
  File 
/Users/peterbe/dev/ZOPE/Zope2-2.13.7/eggs/ZODB3-3.10.2-py2.6-macosx-10.4-x86_64.egg/ZODB/Connection.py,
line 910, in _setstate
self._reader.setGhostState(obj, p)
  File 
/Users/peterbe/dev/ZOPE/Zope2-2.13.7/eggs/ZODB3-3.10.2-py2.6-macosx-10.4-x86_64.egg/ZODB/serialize.py,
line 612, in setGhostState
state = self.getState(pickle)
  File 
/Users/peterbe/dev/ZOPE/Zope2-2.13.7/eggs/ZODB3-3.10.2-py2.6-macosx-10.4-x86_64.egg/ZODB/serialize.py,
line 605, in getState
return unpickler.load()
TypeError: ('argument list must be a tuple', class
'Shared.DC.ZRDB.DA.SQL', None)

-- 
Peter Bengtsson,
home www.peterbe.com
fun donecal.com
work www.mozilla.com
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] MemoryError: out of memory

2011-01-27 Thread Peter Bengtsson
This little something form 2008 might work
http://www.peterbe.com/plog/zope-memory-readings


On 27 January 2011 05:15, Andreas Jung li...@zopyx.com wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 You should monitoring memory usage over time. Obviously something
 in your application is leaking memory.

 - -aj

 Jonathan Salazar Santos schrieb:
 Hi Comunity,

 I have been in troubles with Zope2.10.5-final since 4 moths ago,
 related to the MemoryError: out of memory (in the event.log), every
 three or fourth days (more or less) the Zope starts to say in our web:
 value error: Memory, and stops to serve some pages (not all), usually
 the pages that serve file contents (to download, convert to pdf or
 view online). I solve the problem (when appears) by rebooting the zope
 server, but its not a solutions, because I dont know when the error
 its coming ¿Can you help me to giving me some light to solve the
 problem? I have 2gb of RAM, and the server (FreeBSD) it says
 no-overloaded, just have 2 services, web(zope) and database(mysql). I
 think its something related to the cache memory or kind of (I changed
 some values in config file but not success). See some of my event.log


 Traceback (innermost last):
   Module ZPublisher.Publish, line 119, in publish
   Module ZPublisher.mapply, line 88, in mapply
   Module ZPublisher.Publish, line 42, in call_object
   Module OFS.DTMLMethod, line 144, in __call__
    - DTMLMethod at //index_html used for 
 //suscribete/adminNewsletter
    - URL: http:///index_html/manage_main
    - Physical Path: //index_html
   Module DocumentTemplate.DT_String, line 476, in __call__
   Module OFS.DTMLMethod, line 137, in __call__
    - DTMLMethod at //suscribete/adminNewsletter/third_header
    - URL: http:///suscribete/adminNewsletter/third_header/manage_main
    - Physical Path: //suscribete/adminNewsletter/third_header
   Module DocumentTemplate.DT_String, line 476, in __call__
   Module DocumentTemplate.DT_In, line 703, in renderwob
   Module Products.MailHost.SendMailTag, line 114, in render
   Module Products.MIMETools.MIMETag, line 198, in render
   Module MimeWriter, line 177, in lastpart
 MemoryError: out of memory




 - --
 ZOPYX Limited           | zopyx group
 Charlottenstr. 37/1     | The full-service network for Zope  Plone
 D-72070 Tübingen        | Produce  Publish
 www.zopyx.com           | www.produce-and-publish.com
 - 
 E-Publishing, Python, Zope  Plone development, Consulting


 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.11 (Darwin)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

 iQGUBAEBAgAGBQJNQP9kAAoJEADcfz7u4AZjARQLv25A9rr7JyaaBg8SZDl1G1EN
 t19RNt1nXOg4tw+6r82IhH8I55FH+RbP+dHI73DuNTVJuSPYg2s9xuRtfOMdyhE1
 AqRTew6MK0paLaoRH9QtjWvPnhr4dnKSBn2FK4kRxzc0mKh9tTHefbwN+CUmGQmv
 lO+t0ZVdK+SqUwcfG9BekjVr/VYXUukhkm6WzxLTBkOo67sT+fTk2i8fZ7QH3dDw
 7q6f+dgOV0E1MWlQ1OeydEm+SAGo7EwqB1iaArCxwpJDN6YPLWQZk3DbA0kM9nNQ
 U6YAKsBI5urwuOoLiFJYHSGwy91Wgm9uLkNicx7sQ0zyJnGdReFfMNcf0BQWlz8X
 k0FGnaQ1oHo8qXGisgJPn1vZZxFlNtnnH7QLKk53lt4+9B6tBW3WI5RJXO9g+w2s
 Us/vpTLEHamyjb9bZNVvFI6qqQ0TiV1CmmsMSiOsEBTD56i7oS6SA594RyM65d0R
 BNUWKcU6pN/7W21MxhzGf3kLJirEgw4=
 =WPMi
 -END PGP SIGNATURE-

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





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby donecal.com
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Peewee and Zope

2010-12-30 Thread Peter Bengtsson
I'm interested in marrying my Zope app with Peewee[1]. It's a very
simple ORM based on Django's ORM patterns. All I need is a
non-persistent connection object in my app.
To avoid reinventing any wheels, I thought I could maybe look at the
SQLAlchemy or ZPsycopgDA packages for inspiration.
Even better way to avoid re-inventing the wheel would be if there
already was a package or some code I could try. Has anybody built
anything like this they're willing to share? (nothing found by
googling)

[1] https://github.com/coleifer/peewee

-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby donecal.com
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Question about Upgrading Zope and OS X Server

2010-12-08 Thread Peter Bengtsson
We're running several perfectly working 2.8 Zopes. They've been very stable.
Annoying that Ubuntu insists on making Python 2.4 hard to install but
for some of the servers we've changed back to Debian.

On 7 December 2010 16:58, Dan Gaibel d...@cornell.edu wrote:
 Good advice here, thanks! Is it a big mistake to stay at Zope 2.8.6? The 
 server has been very stable for years, apparently. What are the downfalls of 
 not upgrading all the way past 2.10?

 On Dec 7, 2010, at 2:40 PM, Andrew Milton wrote:

 +---[ Tres Seaver ]--
 | -BEGIN PGP SIGNED MESSAGE-
 | Hash: SHA1
 |
 | On 12/07/2010 01:18 PM, Dan Gaibel wrote:
 |
 |  I have recently inherited the responsibility of supporting a fairly
 |  complex web server running Zope 2.8.6 on Python 2.3.5. This
 |  configuration is currently on a Linux (Fedora Core) server and I
 |  would like very much to migrate to OS X Server Snow Leopard. It also
 |  seems to me that I should consider upgrading Zope to a more current
 |  release while I'm at it. We heavily use MySQL and associated
 |  products, LocalFS, and the Python Imagining Library. We have a
 |  variety of ZClass homegrown products as well.
 | 
 |  I know that I'm in for a headache no matter what, but I wonder if any
 |  of you folks could point me in the right direction or offer advice on
 |  the situation. Is it crazy to jump from 2.8.6 to 2.12? Does anyone
 |  use OS X Server for Zope? Is this migration a mistake? Any pitfalls I
 |  should be looking out for?
 |
 | I would do this in small steps, e.g. first migrate to the new machine / OS:
 |
 | - - Get Python 2.3.x installed on the OS/X server.
 |
 | - - Build the latest Zope 2.8.* on that server.
 |
 | - - Install and test products there in the same versions  you now use.
 |
 | - - Copy your old database over and test.
 |
 | then upgrade the software stack:
 |
 | - - Move carefully through the Zope releases (I would to 2.9, 2.10, and'
 |   2.12), upgrading Python as needed  to stay on a supported version.
 |
 | - - Check for upgrades to the products, and their compatibility with
 |   Zope versions.  Test them, and your site. after each upgrade.

 The move from 2.9 to 2.10 is likely to be the most painful part in
 terms of legacy Zope apps. A lot of products will break on 2.10

 --
 Andrew Milton
 a...@theinternet.com.au
 ___
 Zope maillist  -  z...@zope.org
 https://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )

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




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby donecal.com
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Persist password in CookieCrumbler

2010-10-22 Thread Peter Bengtsson
I wrote something a long time ago which did this. Download
http://www.issuetrackerproduct.com/Download#CookieCrumblerIssueTrackerProduct
And read some of the source I think what you have to do is override
its setAuthCookie method somehow and there you can set 'expires' to be
a date far in the future.

On 21 October 2010 23:28, Brian Sullivan briansulli...@gmail.com wrote:
 Can I persist the password using CookieCrumbler (in addition to the
 user name)? Has anybody made this modification and can supply the
 modified product or code. I made a stab at it but obviously my level
 of understanding is not up to snuff 'cause I can't get it to work.

 What are the implications/problems that might result from doing this?
 ___
 Zope maillist  -  z...@zope.org
 https://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists -
  https://mail.zope.org/mailman/listinfo/zope-announce
  https://mail.zope.org/mailman/listinfo/zope-dev )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] commit problems psycopg

2010-08-23 Thread Peter Bengtsson
Most likely you have raise conditions that you don't notice but that
the ZPsycopg2 adapter notices. Perhaps it's a ConflictError or a
Unauthorized.
Either start committing the data yourself (transaction.get().commit()
will commit in Postgres too)
You can also debug your problems by keeping a close eye on the SQL
logs. You'll need to enable it somewhere in the postgres conf. On
linux you can look for a line like log_statement = 'all'


On 23 August 2010 12:24, Richard Harley rich...@scholarpack.com wrote:
  We have had a problem with postgresql 8.3 on a Windows server 2008. I
  wonder whether there has been any other experiences like this. We have
  connected to Potsgres from Zope via a Psycopg adapter and noticed that
  sometimes when data is inserted via a form in Zope, the data is
  available in Zope but doesn't get committed to the database. This has
  come to a head over the weekend where at least one month's worth of data
  has disappeared and this includes changes to the actual database
  structure - luckily only on a testing machine, but concerning nevertheless.
  The data seemed to disappear after we upgraded to the most recent
  version of Zpsycopg2 database adapter, previously we were using version
  1 (I know it's old, we are only testing after all) and have never had
  these sorts of problem before. It's almost as if all the data and
  changes to the db were held in memory, and Postgres continued to work
  fine from there, but when the db adapter was changed and Zope restarted
  everything was cleared from memory.
  Has anyone had similar experiences or can anyone cast any light on where
  the problem may lie. To us it seems the db adapter is the most likely
  candidate but we can't understand how this could happen, explanations
  also welcome. Have posted this to psycopg list too.
 Thanks


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




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] [JOB][OT?] Position for a Python/Zope developer in Pula, Cagliari (CA), Italy

2010-07-13 Thread Peter Bengtsson
On 13 July 2010 11:20, Marco Bizzarri marco.bizza...@gmail.com wrote:


 On Tue, Jul 13, 2010 at 4:58 PM, Chris Withers ch...@simplistix.co.uk
 wrote:

 Marco Bizzarri wrote:

 I won't start a religious war on IDE editors :)

 You already did by putting such a ridiculous requirement in a job ad.

 Chris

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



 As I said before, I've no interest in starting such a war; you find this is
 a ridiculous requirement: fine, you're more than entitled to have your
 opinion.


I think what the senior developers react to here isn't the particular
choice. You could have written Vim is preferred and people would
still think: Do they want me to write with my left or right hand or
do they want me to get the job done.

Anyway, best of luck Marco!


 Regards
 Marco
 --
 Marco Bizzarri
 http://code.google.com/p/qt-asterisk/
 http://notenotturne.blogspot.com/
 http://iliveinpisa.blogspot.com/

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





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Zope Catalog sorting

2010-05-29 Thread Peter Bengtsson
I haven't tried it myself but the AdvancedQuery product from the
uber-zope-guru Dieter Maurer supports this:
http://www.dieter.handshake.de/pyprojects/zope/AdvancedQuery.html#bct_sec_4


On 28 May 2010 10:40, Giampiero Benvenuti
giampiero.benven...@chiaroscuro.com wrote:
 Hello,

 I have a simple/silly question:

 how can you sort the Catalog results with 2 parameters? Es:
 sort_on='last_name', sort_on='first_name'... in the old days was
 simple: sort='last_name, first_name'

 Thank You,

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




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Zope 2.12 and ZPT

2010-05-01 Thread Peter Bengtsson
I'm trying to get a product running in Zope 2.12 which I installed in
a virtualenv with easy_install. It starts fine and all but when I try
to render a piece of ZPT I get this weird error:


Traceback (innermost last):
  Module ZPublisher.Publish, line 127, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 47, in call_object
  Module Products.IssueTrackerProduct.IssueTracker, line 12629, in AddIssue
  Module Shared.DC.Scripts.Bindings, line 324, in __call__
  Module Shared.DC.Scripts.Bindings, line 361, in _bindAndExec
  Module Products.PageTemplates.PageTemplateFile, line 130, in _exec
  Module Products.PageTemplates.PageTemplate, line 80, in pt_render
  Module zope.pagetemplate.pagetemplate, line 115, in pt_render
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 888, in do_useMacro
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 533, in do_optTag_tal
  Module zope.tal.talinterpreter, line 518, in do_optTag
  Module zope.tal.talinterpreter, line 513, in no_tag
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal
  Module Products.PageTemplates.Expressions, line 220, in evaluateStructure
  Module zope.tales.tales, line 696, in evaluate
  Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
   - __traceback_info__: here.getRoot().title_or_id().replace(' ',' ')
  Module PythonExpr, line 1, in expression
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
0: ordinal not in range(128)


After a lot of trial-and-error I managed to figure out that the
culprit was this piece of ZPT code:
tal:content=structure python:here.getRoot().title_or_id().replace('
','nbsp;')
Stupid and easy to fix; maybe but what if there are other problems like this?

What's the cause of this? Do I have to set something special up in
zope.conf just for Page Templates to not convert 'nbsp;' into
'\xa0\xc2'?

-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Zope 2.12 and ZPT

2010-05-01 Thread Peter Bengtsson
On 1 May 2010 14:40, Andreas Jung li...@zopyx.com wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Peter Bengtsson wrote:
 I'm trying to get a product running in Zope 2.12 which I installed in
 a virtualenv with easy_install. It starts fine and all but when I try
 to render a piece of ZPT I get this weird error:


 Traceback (innermost last):
   Module ZPublisher.Publish, line 127, in publish
   Module ZPublisher.mapply, line 77, in mapply
   Module ZPublisher.Publish, line 47, in call_object
   Module Products.IssueTrackerProduct.IssueTracker, line 12629, in AddIssue
   Module Shared.DC.Scripts.Bindings, line 324, in __call__
   Module Shared.DC.Scripts.Bindings, line 361, in _bindAndExec
   Module Products.PageTemplates.PageTemplateFile, line 130, in _exec
   Module Products.PageTemplates.PageTemplate, line 80, in pt_render
   Module zope.pagetemplate.pagetemplate, line 115, in pt_render
   Module zope.tal.talinterpreter, line 271, in __call__
   Module zope.tal.talinterpreter, line 343, in interpret
   Module zope.tal.talinterpreter, line 888, in do_useMacro
   Module zope.tal.talinterpreter, line 343, in interpret
   Module zope.tal.talinterpreter, line 533, in do_optTag_tal
   Module zope.tal.talinterpreter, line 518, in do_optTag
   Module zope.tal.talinterpreter, line 513, in no_tag
   Module zope.tal.talinterpreter, line 343, in interpret
   Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal
   Module Products.PageTemplates.Expressions, line 220, in evaluateStructure
   Module zope.tales.tales, line 696, in evaluate
   Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
    - __traceback_info__: here.getRoot().title_or_id().replace(' ',' ')
   Module PythonExpr, line 1, in expression
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
 0: ordinal not in range(128)


 After a lot of trial-and-error I managed to figure out that the
 culprit was this piece of ZPT code:
 tal:content=structure python:here.getRoot().title_or_id().replace('
 ','nbsp;')
 Stupid and easy to fix; maybe but what if there are other problems like this?


 Likely related to the new ZPT engine since Zope 2.10.

 Either you deal with this using the unicode conflict resolver of ZPT
 or ensure that you don't mix up different encodings since ZPT now uses
 unicode internally.

the unicode conflict resolver?
My app does not have any non-ascii characters until user input is
added which it's programmed to work with.
The problem was that 'nbsp;' inside the TALES expression was converted to 0xa0


 - -aj
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.10 (Darwin)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

 iEYEARECAAYFAkvcL2IACgkQCJIWIbr9KYzjqACfWQ+7gQO0wO2q3vFzptxvrs5Q
 7CoAnRiCa6aTeOqX58GBN9DHubwKkYr1
 =myaM
 -END PGP SIGNATURE-

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





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Zope 2.12 and ZPT

2010-05-01 Thread Peter Bengtsson
On 1 May 2010 15:40, Andreas Jung li...@zopyx.com wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Peter Bengtsson wrote:


 the unicode conflict resolver?
 My app does not have any non-ascii characters until user input is
 added which it's programmed to work with.
 The problem was that 'nbsp;' inside the TALES expression was converted to 
 0xa0



 The traceback speaks of 0xc2.

I know. There is no such character in my source code. Somewhere TAL
converts 'nbsp;' to 0xc2

If it's not a matter of configuration I can make a bug report.

 - -aj
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.10 (Darwin)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

 iEYEARECAAYFAkvcPUcACgkQCJIWIbr9KYzw8ACgvySZqOCv2eN8WZPEu2Iifvwz
 XiAAnj5FGC8gD92HerPslMNFIrVN4zWR
 =EInK
 -END PGP SIGNATURE-

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





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Prevent a logger from writing to event.log

2009-10-16 Thread Peter Bengtsson
Sure, check out and find out how to create your own logger instance
where you decide what filename to write to.
http://blog.doughellmann.com/2007/05/pymotw-logging.html



2009/10/16 Bert Vanderbauwhede batlock...@gmail.com:
 Hi,

 Is it possible to have a logger in Zope that doesn't write to the
 event.log?  All the other loggers can write to the event.log, but just this
 one logger should not.


 --
 Bert Vanderbauwhede
 --
 I don't know if you noticed or not, but I'm an extremely arrogant man, who
 thinks all his plans will work.
 Rodney McKay, Stargate Atlantis

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





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Problem with Zodb connections pool

2009-10-14 Thread Peter Bengtsson
2009/10/14 Tres Seaver tsea...@palladion.com:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Claudio Battaglino wrote:
 Hi all,
 I've a system with Zope 2.8.8 that since some weeks is very slow.
 The python process keeps busy the CPU (98-99%) and the memory used by
 the process is growing up.
 Every day a script makes a pack of the ZODB and restarts Zope so the
 Data.fs size is stable (about 350MB).

 In the event.log I can see many of this warnings:
 2009-10-14T11:59:14 WARNING ZODB.DB DB.open() has 8 open connections
 with a pool_size of 7

 What does it mean?

 Likely something in your application is leaking connections (and
 therefore RAM).  Normally each worker thread gets a connection from
 the pool at the start of the request, uses it, and then returns it to
 the pool at the end of the request.

 If you are using the default configuration for number of threads (4),
 then something has leaked four connections (assuming your server is busy
 at the time you see that log message).  You should examine the Debug
 Information page in the ZMI control panel to get information for
 diagnosing the leak.


Tres is right. Use the Debug Information. Especially look for requests
(the last big table) that take longer than 1 second.
The table will provide some information about what request is taking so long.
Additionally/Alternatively you can check out DeadlockDebugger which
you have to install manually for your Zope and you get the same
information but instead of information about the requests you get
tracebacks from within the code that is executing the requests.


 I can see also some of these messages:
 2009-10-14T12:14:16 INFO ZODB.Conflict database conflict error...

 According to you, are the two messages related?

 No.  Conflict errors occur normally, whenever simultaneous requests
 cause writes to the same objects.  The request whose transaction commits
 later gets retried, up to three times;  if it still conflicts, then
 the request returns an error, and you see the message in your logfile.


 Tres.
 - --
 ===
 Tres Seaver          +1 540-429-0999          tsea...@palladion.com
 Palladion Software   Excellence by Design    http://palladion.com
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.9 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iEYEARECAAYFAkrVrT4ACgkQ+gerLs4ltQ5HagCeJ1X32zT+LOMasY90fzmBolzR
 Q6MAn3qHhkjENxxr7B24z54fsj4TCfQT
 =ETsW
 -END PGP SIGNATURE-

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




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] http return code of standard_error_message

2009-09-07 Thread Peter Bengtsson
Don't raise errors that cause 500 type HTTP error codes on input validation.
It's not an error. It's a user input error.

2009/9/7 Ulla Theiss u.the...@eurodata.de:
 Hallo list,

 because the application error messages like checks of input values
 produce such error messages.
 The browser firefox does display these messages, but the Internet
 Explorer with the newest updates does not.
 The Internet Explorer displays a own error message instead. Only if
 you manipulate the flag show friendly http error messages the
 body of standard_error_messages is *always* displayed. But  we think, it
 would be difficult to  make shure that every user does this.

 Ulla

 Chris Withers wrote:
 Ulla Theiss wrote:
 Hello list,

 is there a possibility to send the standard_error_message with http
 return code 200 (ok) instead of 500 (internal_server_error)?

 Why would you want to? That's in violation of several http specs...

 Chris


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




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] strange database read conflict error

2009-08-28 Thread Peter Bengtsson
The fact that the class is Products.Transience.Transience.Increaser
makes me suspect that you're using sessions and within the same
session you make too many read requests to the ZODB. When the load is
too high, after a certain amount of attempts Zope will say, piss off!
...for a while and come back later. So it comes back later and works
fine.
Are you using lots of AJAX requests? That can sometimes cause read
conflict errors.

2009/8/28 Dragos Chirila objectval...@gmail.com:
 Hello everyone,

 I have a question regarding a database read conflict error. I would
 appreciate any thoughts on this issue.

 I am using Zope 2.8.9.1-final, Python 2.3.7 with a ZEO server and 4
 clients for 6 months now. I have noticed that the event.log is filled
 with read conflict errors like the one below:

 2009-08-28T10:29:26 INFO ZODB.Conflict database read conflict error
 (oid 0x09, class Products.Transience.Transience.Increaser) at
 /VirtualHostBase/http/metropotam.ro:80/metropotam/VirtualHostRoot/Opera/loc4769172835-Ateneul-Roman/
 (21 conflicts, of which 0 were unresolved, since startup at Thu Aug 27
 15:25:02 2009)

 This URL of the object is
 http://metropotam.ro/Opera/loc4769172835-Ateneul-Roman . We have
 around 2000 objects of the same type and this is *the only one* that
 generates read conflict errors.

 I have tried a few things:

 1.      Edit object and recatalog it
 2.      Rename it
 3.      Delete object, pack database, create a new object and then rename
 it to keep the URL alive
 4.      checked the data.fs and got no errors (fstest.py)

 None of the above solved the problem; I still get a lot of conflicts.

 Is there a way to fix this? I found it very strange that I get
 conflicts only for this object and for no other of the same type, even
 in the same folder...

 Thank you,
 Dragos Chirila
 ___
 Zope maillist  -  z...@zope.org
 https://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists -
  https://mail.zope.org/mailman/listinfo/zope-announce
  https://mail.zope.org/mailman/listinfo/zope-dev )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] strange database read conflict error

2009-08-28 Thread Peter Bengtsson
2009/8/28 Dragos Chirila objectval...@gmail.com:
 Peter,

 Than you for your response. Please find below a few things:

 - I give up using sessions in the website's front and years ago :)
 There is only one page left that is using them, when u subscribe to
 our newsletter but I don't think that this affects because is used
 rarely

It might be used anyway. It'll be empty (except the
subscribe-to-newsletter page) all the time but it might still be in
use.
I think there is always a REQUEST.SESSION object.

 - I am using Yahoo Maps Ajax API to display maps; also some ajax calls
 for our build in chat (only for logged users)
That's unrelated. Yahoo! isn't using ZODB.


 So if the things above are causing read conflicts why only for this
 particular object? There is nothing special or different with this
 one...

It could be some other piece of code that tries to read from ZODB more
than once and whatever it's trying to read might be something slow
(slow for a computer).

Have you tried running ZopeProfiler on your site to figure out if
there are certain (ZO)DB related functions that are called either many
many times or few but slow times.

 Thanks again,
 Dragos

 On Fri, Aug 28, 2009 at 12:19 PM, Peter Bengtssonpete...@gmail.com wrote:
 The fact that the class is Products.Transience.Transience.Increaser
 makes me suspect that you're using sessions and within the same
 session you make too many read requests to the ZODB. When the load is
 too high, after a certain amount of attempts Zope will say, piss off!
 ...for a while and come back later. So it comes back later and works
 fine.
 Are you using lots of AJAX requests? That can sometimes cause read
 conflict errors.

 2009/8/28 Dragos Chirila objectval...@gmail.com:
 Hello everyone,

 I have a question regarding a database read conflict error. I would
 appreciate any thoughts on this issue.

 I am using Zope 2.8.9.1-final, Python 2.3.7 with a ZEO server and 4
 clients for 6 months now. I have noticed that the event.log is filled
 with read conflict errors like the one below:

 2009-08-28T10:29:26 INFO ZODB.Conflict database read conflict error
 (oid 0x09, class Products.Transience.Transience.Increaser) at
 /VirtualHostBase/http/metropotam.ro:80/metropotam/VirtualHostRoot/Opera/loc4769172835-Ateneul-Roman/
 (21 conflicts, of which 0 were unresolved, since startup at Thu Aug 27
 15:25:02 2009)

 This URL of the object is
 http://metropotam.ro/Opera/loc4769172835-Ateneul-Roman . We have
 around 2000 objects of the same type and this is *the only one* that
 generates read conflict errors.

 I have tried a few things:

 1.      Edit object and recatalog it
 2.      Rename it
 3.      Delete object, pack database, create a new object and then rename
 it to keep the URL alive
 4.      checked the data.fs and got no errors (fstest.py)

 None of the above solved the problem; I still get a lot of conflicts.

 Is there a way to fix this? I found it very strange that I get
 conflicts only for this object and for no other of the same type, even
 in the same folder...

 Thank you,
 Dragos Chirila
 ___
 Zope maillist  -  z...@zope.org
 https://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists -
  https://mail.zope.org/mailman/listinfo/zope-announce
  https://mail.zope.org/mailman/listinfo/zope-dev )




 --
 Peter Bengtsson,
 work www.fry-it.com
 home www.peterbe.com
 hobby www.issuetrackerproduct.com
 fun crosstips.org




 --
 Dragos Chirila
 objectval...@gmail.com
 (+4) 0722 395375
 ___
 Zope maillist  -  z...@zope.org
 https://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists -
  https://mail.zope.org/mailman/listinfo/zope-announce
  https://mail.zope.org/mailman/listinfo/zope-dev )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.org
___
Zope maillist  -  Zope@zope.org
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] strange database read conflict error

2009-08-28 Thread Peter Bengtsson
It's very very hard to reproduce. You have to have really good test
coverage but even in running tests it's hard because of the fact that
they're single threaded.
If I were you I'd look into something some stresstesting tool and
bombard your localhost till you find where it's causing most of the
conflict errors.
NB. Conflict errors aren't errors. That's a sucky thing about ZODB.
Deep down it's an error but since Zope, on a higher more human level,
will just retry it should be considered a warning or info or
something.

2009/8/28 Dragos Chirila objectval...@gmail.com:
 All objects as the same type of this one that generates conflicts are
 displayed using the same template that contains the same elements (js,
 images, etc.).

 I can access any object in the same folder
 (http://metropotam.ro/Opera/) and I will get no read conflicts (e.g.
 http://metropotam.ro/Opera/loc8982879061-Sala-Palatului/). I have
 conflicts when I access this particular object
 http://metropotam.ro/Opera/loc8982879061-Sala-Palatului/.

 If the problem is related with some piece of code I can't find any
 logical explanation for this behavior. ... or maybe I am looking in
 the wrong place.

 Also, told you before, I even erased the object from the Data.fs and
 then packed it. Conflicts stopped. After I have created a new object
 and rename it with the old id the conflicts showed up again...

 Thanks,
 Dragos



 On Fri, Aug 28, 2009 at 2:37 PM, Peter Bengtssonpete...@gmail.com wrote:
 2009/8/28 Dragos Chirila objectval...@gmail.com:
 Peter,

 Than you for your response. Please find below a few things:

 - I give up using sessions in the website's front and years ago :)
 There is only one page left that is using them, when u subscribe to
 our newsletter but I don't think that this affects because is used
 rarely

 It might be used anyway. It'll be empty (except the
 subscribe-to-newsletter page) all the time but it might still be in
 use.
 I think there is always a REQUEST.SESSION object.

 - I am using Yahoo Maps Ajax API to display maps; also some ajax calls
 for our build in chat (only for logged users)
 That's unrelated. Yahoo! isn't using ZODB.


 So if the things above are causing read conflicts why only for this
 particular object? There is nothing special or different with this
 one...

 It could be some other piece of code that tries to read from ZODB more
 than once and whatever it's trying to read might be something slow
 (slow for a computer).

 Have you tried running ZopeProfiler on your site to figure out if
 there are certain (ZO)DB related functions that are called either many
 many times or few but slow times.

 Thanks again,
 Dragos

 On Fri, Aug 28, 2009 at 12:19 PM, Peter Bengtssonpete...@gmail.com wrote:
 The fact that the class is Products.Transience.Transience.Increaser
 makes me suspect that you're using sessions and within the same
 session you make too many read requests to the ZODB. When the load is
 too high, after a certain amount of attempts Zope will say, piss off!
 ...for a while and come back later. So it comes back later and works
 fine.
 Are you using lots of AJAX requests? That can sometimes cause read
 conflict errors.

 2009/8/28 Dragos Chirila objectval...@gmail.com:
 Hello everyone,

 I have a question regarding a database read conflict error. I would
 appreciate any thoughts on this issue.

 I am using Zope 2.8.9.1-final, Python 2.3.7 with a ZEO server and 4
 clients for 6 months now. I have noticed that the event.log is filled
 with read conflict errors like the one below:

 2009-08-28T10:29:26 INFO ZODB.Conflict database read conflict error
 (oid 0x09, class Products.Transience.Transience.Increaser) at
 /VirtualHostBase/http/metropotam.ro:80/metropotam/VirtualHostRoot/Opera/loc4769172835-Ateneul-Roman/
 (21 conflicts, of which 0 were unresolved, since startup at Thu Aug 27
 15:25:02 2009)

 This URL of the object is
 http://metropotam.ro/Opera/loc4769172835-Ateneul-Roman . We have
 around 2000 objects of the same type and this is *the only one* that
 generates read conflict errors.

 I have tried a few things:

 1.      Edit object and recatalog it
 2.      Rename it
 3.      Delete object, pack database, create a new object and then rename
 it to keep the URL alive
 4.      checked the data.fs and got no errors (fstest.py)

 None of the above solved the problem; I still get a lot of conflicts.

 Is there a way to fix this? I found it very strange that I get
 conflicts only for this object and for no other of the same type, even
 in the same folder...

 Thank you,
 Dragos Chirila
 ___
 Zope maillist  -  z...@zope.org
 https://mail.zope.org/mailman/listinfo/zope
 **   No cross posts or HTML encoding!  **
 (Related lists -
  https://mail.zope.org/mailman/listinfo/zope-announce
  https://mail.zope.org/mailman/listinfo/zope-dev )




 --
 Peter Bengtsson,
 work www.fry-it.com
 home www.peterbe.com
 hobby www.issuetrackerproduct.com
 fun crosstips.org

[Zope] acl_users and encrypted passwords

2009-08-07 Thread Peter Bengtsson
When you encrypt your passwords in an acl_users User Folder, is there
a way to check that the old password is correct?
I'm building an app that allows the user to change her password with
the usual form of:
  Old: 
  New: 
  Confirm: 



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.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 )


Re: [Zope] acl_users and encrypted passwords

2009-08-07 Thread Peter Bengtsson
No, it's different every time.

Consider this::

def _doAddUser(self, name, password, roles, domains, **kw):
Create a new user
...
if password is not None and self.encrypt_passwords:
print \tself._encryptPassword('word')=,
repr(self._encryptPassword('word'))
print \tself._encryptPassword('word')=,
repr(self._encryptPassword('word'))
print \tself._encryptPassword('word')=,
repr(self._encryptPassword('word'))

When running this you get this output::

self._encryptPassword('word')= 
'{SSHA}dxZSdvO5CiaMbDuCC0mAreI0R6nqc5RyYFGo'
self._encryptPassword('word')= 
'{SSHA}pup1PWzONwMnGXk/itXd6rhySF8MOuI57SO6'
self._encryptPassword('word')= 
'{SSHA}HGRxMfi9J7uGK8tfHvuMWfIbNghvu+Z2hb7a'



2009/8/7 Andreas Jung li...@zopyx.com:
 On 07.08.09 16:26, Peter Bengtsson wrote:
 When you encrypt your passwords in an acl_users User Folder, is there
 a way to check that the old password is correct?
 I'm building an app that allows the user to change her password with
 the usual form of:
   Old: 
   New: 
   Confirm: 

 You has the 'old' password using the same algorithm and compare it
 against the stored password hash. Look the AccessControl API of Zope.

 -aj

 ___
 Zope maillist  -  z...@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 )





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.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 )


Re: [Zope] acl_users and encrypted passwords

2009-08-07 Thread Peter Bengtsson
2009/8/7 Andreas Jung li...@zopyx.com:
 On 07.08.09 17:22, Andreas Jung wrote:
 On 07.08.09 17:10, Peter Bengtsson wrote:

 No, it's different every time.


 Using private methods is unlikely the road to success.
 There is some official method with *validate* or something similar..
 In addition: if you call the low-level methods blindly, you must
 take the 'salt' into account.

 AuthEncoding.pw_validate() is likely what you are searching for.

That was the one! THanks for the tip

 -aj

 ___
 Zope maillist  -  z...@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 )





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.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 )


Re: [Zope] Problem with POST and text/xml

2009-07-11 Thread Peter Bengtsson
Roughly because of this I ended up writing the web service part of the
app in Grok instead of Zope.

2009/7/10 Jonathan (dev101) dev...@magma.ca:
 I need to support a third party web service (which is not within my control)
 that wants to send xml data to my zope server (Zope 2.9.2 running on Redhat
 linux).

 When Zope receives a POST request with a Content-Type of text/xml it assumes
 that it is an xmlrpc call (which it is not - it is just passing xml data
 within the POST request).

 Is there a way to get Zope to turn off this xmlrpc assumption so that my
 zope external method can process the xml data that is being passed?


 Thanks,

 Jonathan


 P.S.  details of a wget session that illustrate the error being generated
 follows:

 Setting --header (header) to Content-Type: text/xml
 Setting --post-data (postdata) to ?xml version=1.0 encoding=ISO-8859-1
 ?
 bulkMtNotification
  transactionId235006/transactionId
  triggerId1160/triggerId
  messagetest #27/message
  date2007-09-14 15:52:59/date
  phoneNumber+11234567890/phoneNumber
  carrierId26/carrierId
  carrierNameSprint/carrierName
  shortCode5/shortCode
  /bulkMtNotification
 DEBUG output created by Wget 1.10.2 (Red Hat modified) on linux-gnu.

 --16:12:28--  http://192.168.123.2:8080/Coz/Process3Ci
           = `Process3Ci.1'
 Connecting to 192.168.123.2:8080... connected.
 Created socket 3.
 Releasing 0x00638c60 (new refcount 0).
 Deleting unused 0x00638c60.

 ---request begin---
 POST /Coz/Process3Ci HTTP/1.0
 User-Agent: Wget/1.10.2 (Red Hat modified)
 Accept: */*
 Host: 192.168.123.2:8080
 Connection: Keep-Alive
 Content-Type: text/xml
 Content-Length: 390

 ---request end---
 [POST data: ?xml version=1.0 encoding=ISO-8859-1 ?
 bulkMtNotification
  transactionId235006/transactionId
  triggerId1160/triggerId
  messagetest #27/message
  date2007-09-14 15:52:59/date
  phoneNumber+11234567890/phoneNumber
  carrierId26/carrierId
  carrierNameSprint/carrierName
  shortCode5/shortCode
  /bulkMtNotification]
 HTTP request sent, awaiting response...
 ---response begin---
 HTTP/1.0 500 Internal Server Error
 Server: Zope/(Zope 2.9.2-, python 2.4.2, linux2) ZServer/1.1
 Date: Fri, 10 Jul 2009 20:12:28 GMT
 Bobo-Exception-Line: 742
 Content-Length: 849
 Bobo-Exception-Value: See the server error log for details
 Content-Type: text/html; charset=iso-8859-15
 Bobo-Exception-Type: ResponseError
 Connection: Keep-Alive
 Bobo-Exception-File: xmlrpclib.py

 ---response end---
 500 Internal Server Error
 Registered socket 3 for persistent reuse.


 ___
 Zope maillist  -  z...@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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
fun crosstips.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 )


Re: [Zope] Request time grows with memory size

2009-04-27 Thread Peter Bengtsson
What have you done to investigate memory leaks?
What external connectors are you using, like MySQL or LDAP?

2009/4/27 Gerhard Schmidt esta...@ze.tum.de:
 HI,

 I've encounters a performance Problem with Zope. Some requests take very
 long time to process while others are served very fast. All request go for
 the URL. The time for the delayed Requests grows with the memory size of
 the Zope Process. It's direct proportional.

 I have generated a chart showing the request times and memory size of the
 Zope Process. The chart can be found at http://etustar.ze.tum.de/frontend.jpg

 Our watchdog system restarts the Zope Process when it reaches 7.3 Gig
 Memory. The physical memory of the server is 16 Gig and its only used for
 the zope Server. There are at least 7 Gig Memory free.

 As you can see most of the requests are delivered within 2 seconds but some
 take up to 12 seconds. The Requests monitored are the request of our
 watchdog system. These requests are send approximately every 20 sec.

 When I set the restart memory limit higher the request time of the delayed
 request continues to grows proportionally.

 This server is part of a pool of 19 Servers. All are connected to one ZEO
 server. All show the same effect.

 We observe the same effect with regular requests. Some are served at normal
 speed but some requests are delayed.

 Any idea what causes this effect and how to fix it.

 Greetings
        Gerhard Schmidt
 --
 -
 Gerhard Schmidt       | E-Mail: schm...@ze.tum.de
 TU-München            |
 WWW  Online Services |
 Tel: 089/289-25270    |
 Fax: 089/289-25257    | PGP-Publickey auf Anfrage



 ___
 Zope maillist  -  z...@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 )





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Building a fast, scalable yet small Zope application

2009-04-27 Thread Peter Bengtsson
From experience I find that BTrees are very fast to write to and pick
out items from. Even in the millions. (Never gone into the tens of
millions or further)
Also, when it comes to browsing stuff I find SQL faster and easier to
work with. An added advantage of a RDBMS is that you get the indexing
seamlessly built in (no need to bridge zbrain.getObject()) and it
makes it easier to optimize and figure out which indexes help and
which indexes slow you down which is something that is far from
obvious with a ZCatalog approach.

2009/4/25 Morten W. Petersen mor...@nidelven-it.no:
 Hi,

 I'm considering building a large scale, but small in features site.  It
 will contain
 lots of small objects (millions, tens of millions, hundreds of millions)
 of objects,
 where each object has a couple of strings and maybe some other light
 attributes.

 So far, I've been contemplating disabling undo (if that's possible), and
 using
 BTree structures, maybe segmenting objects into different groups
 (folders) to
 further speed up lookups.  Scalability is also an issue, should I
 consider using
 RelStorage?  Should I consider using the ZCatalog for faster lookups?

 Has anyone else developed something similar?  Are there Zope product
 examples out there that fit the bill?

 -Morten

 --
 Morten W. Petersen
 Manager
 Nidelven IT Ltd

 Phone: +47 45 44 00 69
 Email: mor...@nidelven-it.no

 ___
 Zope maillist  -  z...@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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Building a fast, scalable yet small Zope application

2009-04-27 Thread Peter Bengtsson
For huge inserts like that, have you looked at the more modern
alternatives such as Tokyo Cabinet or MongoDB?
I heard about an experiment to transfer 20 million text blobs into a
Tokyo Cabinet. The first 10 million inserts were superfast but after
that it started to take up to a second to insert each item.
I'm not famililar with how good they are but I know they both have
indexing. And I'm confident they both have good Python APIs.
Or watch Bob Ippolitos PyCon 2009 talk on Drop ACID.

2009/4/27 Hedley Roos hedleyr...@gmail.com:
 I've followed this thread with interest since I have a Zope site with
 tens of millions of entries in BTrees. It scales well, but it requires
 many tricks to make it work.

 Roche Compaan wrote these great pieces on ZODB, Data.fs size and
 scalability at 
 http://www.upfrontsystems.co.za/Members/roche/where-im-calling-from/catalog-indexes
 and 
 http://www.upfrontsystems.co.za/Members/roche/where-im-calling-from/fat-doesnt-matter
 .

 My own in-house product is similar to GoogleAnalytics. I have to use a
 cascading BTree structure (a btree of btrees of btrees) to handle the
 volume. This is because BTrees do slow down the more items they
 contain. This is not a ZODB limitation or flaw - it is just how they
 work.

 My structure allows for fast inserts, but they also allow aggregation
 of data. So if my lowest level of BTrees store hits for a particular
 hour in time then the containing BTree always knows exactly how many
 hits were made in a day. I update all parent BTrees as soon as an item
 is inserted. The cost of this operation is O(1) for every parent.
 These are all details but every single one influenced my design.

 What is important is that you cannot just use the ZCatalog to index
 tens of millions of items since every index is a single BTree and will
 thus suffer the larger it gets. So you must roll your own to fit your
 problem domain.

 Data warehousing is probably a good idea as well.

 My problem domain allows me to defer inserts, so I have a queuerunner
 that commits larger transactions in batches. This is better than lots
 of small writes. This may of course not fit your model.

 Familiarize yourself with TreeSets and set operations in Python (union
 etc.) since those tools form the backbone of catalogueing.

 Hedley
 ___
 Zope maillist  -  z...@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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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-dev] Zope 4.0, maybe not such a bad idea...

2009-04-13 Thread Peter Bengtsson
 - Chris, I rarely agree with you but I actually like your fearless
and provocative bashing for the sake (hopefully) of stirring up some
action.

- Andreas, you've done a great job with Zope but let's raise the bar
and not pass judgement on peoples opinions (especially not my personal
hero Dieter :)

- Andrew, I agree with very much of what you say. Just because Zope2
has flaws doesn't mean we should trash and burn it.

- Dieter, glad to hear it wasn't just me who had problems keeping up
with the backwards incompatible improvements. You seem like a guy
who's more in it for the results than the method.


Long live DTML!



2009/4/13 Andreas Jung li...@zopyx.com:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 On 13.04.2009 6:29 Uhr, Dieter Maurer wrote:
 Andreas Jung wrote at 2009-4-12 09:52 +0200:
 
 @Dieter: participate or be silent.

 I do not obey your orders.

 You are Zope 2 release manager and part of the
 Foundation board -- but you do not have command power over things outside
 the Zope 2 release management and the foundation.

 Thus, I will participate in the way I have participated so far (i.e
 outside the circles controlled by the current Zope developers).
 And I will not be silent but continue to criticize tendencies that
 make Zope a less reliable platform for long living applications.


 As an open-source community we must not accept counter-productive and
 destructive participation.

 Andreas
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.9 (Darwin)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

 iEYEARECAAYFAkni620ACgkQCJIWIbr9KYylGQCgucaj2Sx1UsPjRRp2ugJJx2DP
 /aUAnixLmfZCl7ZDYY7uOUwrItcqmHVX
 =g85K
 -END PGP SIGNATURE-

 ___
 Zope maillist  -  z...@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 )





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] problem with a form in IE 7

2008-12-15 Thread Peter Bengtsson
Has nothing to do with Zope but...
Use Firefox to debug it and you'll get to see the error.
put method=post on form tag and the submission won't be visible in the URL.

2008/12/11 C baiew...@gmail.com:
 We are running Zope 2.9.8 on Macintosh OS X Server 10.5.5 behind Apache 2.x.

 I am having a problem when trying to submit one of my forms in IE 7.  This
 only happens on Windows XP and it only started happening recently (we think
 in the past week).

 The form contains several select boxes.  When the user selects a value from
 one of the select boxes, it submits the form and processes the selection.
 The error I receive is an IE error that says:Internet Explorer Cannot
 Display the Webpage.
 And for some reason, all of my selectbox values are showing in the URL as
 parameters.   This is not supposed to happen.   If I remove the parameters
 from the URL line and press enter, it works fine.

 I have another page that works similar to this one (with multiple select
 boxes that submit the form upon selection), that doesn't experience the same
 problem.

 I even changed my form action to go to a plain html page, and it still tries
 to pass all of my form variables in the URL string.

 I went to Microsoft's trouble shooting page for this error.  I've tried
 deleting my browser history, clearing out any cached items, and also
 re-starting IE without Add-Ons.  The server has been restarted as well.
 None of these options have resolved the issue.

 Neither the Apache log nor the Zope error log shows these errors.
 Has anyone encountered this problem?  If so, what have you done to resolve
 the issue?
 ___
 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 )





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] problem with a form in IE 7

2008-12-15 Thread Peter Bengtsson
2008/12/15  ga...@schoolteachers.co.uk:
 Quoting Peter Bengtsson pete...@gmail.com:

 Has nothing to do with Zope but...
 Use Firefox to debug it and you'll get to see the error.
 put method=post on form tag and the submission won't be visible in the URL.
 I've had this happen with method=get in the past. Changing to post fixed it
 but...
 May be worth checking zope.conf:

 Directive: http-header-max-length
 #
 # Description:
 # Maximum number of bytes allowed within a HTTP request header. The
 request
 # is discarded and considered as a DoS attack if the header size exceeds
 # this limit.
 #
 # Default: 8192
 #
 # Example:
 #
 # http-header-max-length 16384


No. Don't fiddle with that. Get the form right. That's the basics.
It might be worth reading up and understanding the basic difference
between POST and GET and which to use when.

 Regards
 Garry

 2008/12/11 C baiew...@gmail.com:
 We are running Zope 2.9.8 on Macintosh OS X Server 10.5.5 behind Apache 2.x.

 I am having a problem when trying to submit one of my forms in IE 7.  This
 only happens on Windows XP and it only started happening recently (we think
 in the past week).

 The form contains several select boxes.  When the user selects a value from
 one of the select boxes, it submits the form and processes the selection.
 The error I receive is an IE error that says:Internet Explorer Cannot
 Display the Webpage.
 And for some reason, all of my selectbox values are showing in the URL as
 parameters.   This is not supposed to happen.   If I remove the parameters
 from the URL line and press enter, it works fine.

 I have another page that works similar to this one (with multiple select
 boxes that submit the form upon selection), that doesn't experience the same
 problem.

 I even changed my form action to go to a plain html page, and it still tries
 to pass all of my form variables in the URL string.

 I went to Microsoft's trouble shooting page for this error.  I've tried
 deleting my browser history, clearing out any cached items, and also
 re-starting IE without Add-Ons.  The server has been restarted as well.
 None of these options have resolved the issue.

 Neither the Apache log nor the Zope error log shows these errors.
 Has anyone encountered this problem?  If so, what have you done to resolve
 the issue?
 ___
 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 )





 --
 Peter Bengtsson,
 work www.fry-it.com
 home www.peterbe.com
 hobby www.issuetrackerproduct.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 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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] single zsql on multiple tables or multiple zsql s

2008-12-13 Thread Peter Bengtsson
Assuming you're developing your product on the filesystem and not inside the ZMI
you can use this:
http://www.fry-it.com/oss/ZSQL which has some profiling options.

2008/12/12 indrajit926 indra indrajit...@gmail.com:
 Hi All,

 In my project iam using zsqls.

 Now i want to improve performance of project.So i thought to reduce number
 of zsqls,expecting it may improve performance.

 using one zsql to fetch values from  different tables ,can increase
 performance ?(instead of using multiple zsqls on multiple tables).

 Is there anyother ways to improve performance in using zsql.please suggest
 me if any.

 Thanks in advance,
  Raj.


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





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] The proxy server received an invalid response from an upstream server.

2008-12-12 Thread Peter Bengtsson
Doesn't that just mean that Apache is proxy passing to a Zope that
doesn't respond?

2008/12/12 rugbert kjenni...@housecallit.com:

 My client's zope has two back ends, /manage and /tools. tools is the one with
 the more user friendly interface and manage is the utilitarian one.

 When users goto /tools tho, and click the assets folder the site times
 outs with this:
 [code]
 Proxy Error

 The proxy server received an invalid response from an upstream server.
 The proxy server could not handle the request GET /tools/assets/.

 Reason: Error reading from remote server
 [/code]

 However, I can get there just fine through manage. Any thoughts?
 --
 View this message in context: 
 http://www.nabble.com/The-proxy-server-received-an-invalid-response-from-an-upstream-server.-tp20980101p20980101.html
 Sent from the Zope - General mailing list archive at Nabble.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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] sorting ids in python

2008-12-11 Thread Peter Bengtsson
2008/12/11 robert rottermann [EMAIL PROTECTED]:
 Garry Saddington schrieb:
 On Tuesday 09 December 2008 03:15, Andreas Jung wrote:
 On 08.12.2008 21:11 Uhr, robert rottermann wrote:
 Garry Saddington schrieb:
 Can anyone help me sort the following by id in a python script?

 for object in context.objectValues(['Folder', 'DTML
 Document','ZipFolder','File','Image']):
 objs=context.objectValues(['Folder',
 'DTMLDocument','ZipFolder','File','Image']) objs.sort()
 for o in objs:
   ..
 huh? Afaik there is no sort order defined on a per-object basis.

 This is my final working solution:

 ids = context.objectIds(['Folder', 
 'DTMLDocument','ZipFolder','File','Image'])
 ids.sort()
 for object in ids:
 object=context.restrictedTraverse(object)
 path=object.absolute_url()
 ...
 I think you can have it a little bit easier:
 use context.objectItems instead of objectIds
 context.objectItems returns (id, object) tuples.

 so your solution wold be:
 objs = context.objectItems(['Folder', 
 'DTMLDocument','ZipFolder','File','Image'])
 objs.sort()
 for id, object in objs:
 path=object.absolute_url()
 robert

Personally I prefer to always use objectValues(). Sorting isn't
objectXXX()'s problem. It's something you do in your view.
objs = list(self.objectValues())
objs.sort(lambda x,y: cmp(x.id, y.id))

It's only a matter of time until you need something more advanced
and then you shouldn't
have to change how you use the objectXXX() iterator. E.g.:
objs.sort(lambda x,y: cmp(x.title_or_id().lower(), y.title_or_id().lower()))


-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Learning to use a BTreeFolder2

2008-11-25 Thread Peter Bengtsson
OOBTrees are created as attributes on zopeish objects (e.g. BTreeFolder2).
E.g.

class Stuff(BTreeFolder2):
 meta_type ='Stuff'
 def __init__(self, oid):
super(Stuff, self).__init__(oid)
self.people = OOBTree()

2008/11/25 Mr SZ [EMAIL PROTECTED]:
 Hi All,

 I am writing a product to manage the back end operations of users.I need to 
 store lots of user info.My first plan was to use ZSQL but then I read about 
 ZODB and more specifically OOBTrees and BTreeFolder2. My objective is to 
 store user related stuff on ZODB but not litter the ZODB but to instead 
 organize into folders. I read the test code and the BTreeFolder.py to figure 
 out the API.

 I have a few doubts to clarify:

 In this method I tried to add two BTFs and an OOBTree:
 def test3():
f = BTreeFolder2('sufest')
f2 = BTreeFolder2('somefolder')
f3 = BTreeFolder2('somefolder2')
f._setObject(f2.id, f2)
f._setObject(f3.id, f3)
uniq_id = f.generateId()
obT = OOBTree()
obT['Auth'] = {'a':1,'b':2}
f._setOb(uniq_id, obT)
lst = f.objectMap()

return f._getOb(uniq_id)

 Now the functions returns an error:
 Traceback (innermost last):
  Module ZPublisher.Publish, line 115, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 41, in call_object
  Module Products.ExternalMethod.ExternalMethod, line 225, in __call__
   - __traceback_info__: ((), {}, None)
  Module /var/lib/zope2.9/instance/sandbox/Products/Test/Extensions/Tst.py, 
 line 40, in test3
  Module Products.BTreeFolder2.BTreeFolder2, line 211, in _getOb
 AttributeError: 'BTrees._OOBTree.OOBTree' object has no attribute '__of__'

 I beleive this is because OOBTrees don't have a meta_type which the _getOb 
 function tries to access. Enlighten me :)

 Other methods like objectMap and getBatchObjectListing work fine though.

 My question is how do we properly a store any item other than zope objects 
 like strings,dicts or OOBTrees in a BTreeFolder2 and how to retrieve them 
 back.

 Zope seems interesting to work with but at times really confuses me 
 especially acquisition concepts.

 Regards,
 SZ


  life isn't heavy enough,it flies away and floats far above action



  Start your day with Yahoo!7 and win a Sony Bravia TV. Enter now 
 http://au.docs.yahoo.com/homepageset/?p1=otherp2=aup3=tagline
 ___
 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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] How to find unused Images

2008-11-17 Thread Peter Bengtsson
Write a script in Zope that makes a list of all the Image's paths,
then write another script that parses the Z2.log and cross reference
these lists and remove the Image paths that appear in the access log.
Do it long enough and you'll find which ones aren't being used.


2008/11/17 Rupesh P Raj [EMAIL PROTECTED]:
 Hi All,

 I am working on an application built on top of Zope. Being a heavily used
 system, there are quite a lot of old 'Images' in the ZODB which are not
 referenced anymore. Can I find the images which are not accessed for a long
 time programatically? Is there a last accessed time or so associated with
 every object?

 Regards
 Roopesh

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





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] FunctionalTestCase commits transactions

2008-11-17 Thread Peter Bengtsson
2008/11/17 Dieter Maurer [EMAIL PROTECTED]:
 Peter Bengtsson wrote at 2008-11-5 15:14 +:
 ...
 When I wrote a functional test browser (years before zope3),
 I emulated the Zope publisher rather than calling it directly
 in order to have control how transactions are handled.

 Especially, I used subtransactions instead of top level transactions
 to avoid the bug reported by Peter.


Uh? subtransactions?
So how would you recommend that I go abouts doing this?

 savepoints have replaced subtransactions.

 This means:

  When a request starts, a new savepoint is created.
  When the request would cause a transaction abort (in normal operation),
  the test request will roll back to the saved savepoint. Otherwise,
  the modifications are kept.

  When the complete test ends, the transaction is aborted, wiping out
  all modifications done be the test. Of course, this works only when
  all resouce managers in the transaction support savepoints (which
  probably means that all resource managers need to be ZODB connections).

That's fine. When I used SQL connections in ZopeTestCase they are
aborted and after running all tests my tables are empty as expected.
With FunctionalTestCase this is not the case. It seems to have to
commit transactions (save savepoints).

I solved my situation by writing a custom tearDown() method that
manually resets the tables. Kind of like this:

class TestFunctionalBase(ZopeTestCase.FunctionalTestCase):
def tearDown(self):
  sql = 'TRUNCATE TABLE table1, table2, table3;'
  self.pypgsqlda.manage_test(sql)
  import transaction
  transaction.commit()
  super(TestFunctionalBase, self).tearDown()



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




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Call PageTemplateFile class instances

2008-11-13 Thread Peter Bengtsson
This used to work in zope 2.8 but not now in zope 2.10 (actually zope
2.10.7 to be exact)

from Products.PageTemplates.PageTemplateFile import PageTemplateFile
class MyProduct(Folder):
meta_type = bla
page = PageTemplateFile('zpt/foo.pt', globals())

def render_page(self):
 html = self.page(self.REQUEST) # ERROR!!

The error is ridiculously large so I've truncated it:


Error in test test_foo
(Products.MoneyVillage2.tests.test_creditconfusion.TestCreditCheck)
Traceback (most recent call last):
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Testing/ZopeTestCase/profiler.py,
line 98, in __call__
testMethod()
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/Products/MoneyVillage2/tests/test_creditconfusion.py,
line 20, in test_foo
print cc.advice2(self.app.REQUEST)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Shared/DC/Scripts/Bindings.py,
line 313, in __call__
return self._bindAndExec(args, kw, None)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Shared/DC/Scripts/Bindings.py,
line 350, in _bindAndExec
return self._exec(bound_data, args, kw)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Products/PageTemplates/PageTemplateFile.py,
line 129, in _exec
return self.pt_render(extra_context=bound_names)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Products/PageTemplates/PageTemplate.py,
line 98, in pt_render
showtal=showtal)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/pagetemplate/pagetemplate.py,
line 117, in pt_render
strictinsert=0, sourceAnnotations=sourceAnnotations)()
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tal/talinterpreter.py,
line 271, in __call__
self.interpret(self.program)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tal/talinterpreter.py,
line 346, in interpret
handlers[opcode](self, args)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tal/talinterpreter.py,
line 870, in do_useMacro
macro = self.engine.evaluateMacro(macroExpr)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tales/tales.py,
line 696, in evaluate
return expression(self)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tales/expressions.py,
line 217, in __call__
return self._eval(econtext)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Products/PageTemplates/Expressions.py,
line 153, in _eval
ob = self._subexprs[-1](econtext)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tales/expressions.py,
line 124, in _eval
ob = self._traverser(ob, element, econtext)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Products/PageTemplates/Expressions.py,
line 83, in boboAwareZopeTraverse
request=request)
  File 
/home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/traversing/adapters.py,
line 161, in traversePathElement
raise TraversalError('No traversable adapter found', obj)
TraversalError: ('No traversable adapter found', {'master':
[('version', '1.6'), ('mode', 'html'), ('setPosition', (1, 0)),
('setSourceFile', 'main_template'), ('beginScope', {'define-macro':
'master'}), ('optTag', ('metal:block', None, 'metal', 0, [('startTag',
('metal:block', [('define-macro', 'master', 'metal')]))], [('rawtextCo
...MANY MANY MORE
LINES..



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Call PageTemplateFile class instances

2008-11-13 Thread Peter Bengtsson
I've kind of work it out. The trick is to write some boiler plate in
the class definition like this::

from zope import traversing, component, interface
from zope.interface import implements
from zope.traversing.interfaces import ITraversable

from Products.PageTemplates.PageTemplateFile import PageTemplateFile
class MyProduct(Folder):

   implements(ITraversable)
   component.provideAdapter(
traversing.adapters.DefaultTraversable,
(interface.Interface,),ITraversable)

   meta_type = bla
   page = PageTemplateFile('zpt/foo.pt', globals())

   def render_page(self):
html = self.page(self.REQUEST) # ERROR!!


I don't understand how it works and I wish there was a way to apply
these settings from a function instead of having to copy and paste it
into every instance creating class.


2008/11/13 Peter Bengtsson [EMAIL PROTECTED]:
 This used to work in zope 2.8 but not now in zope 2.10 (actually zope
 2.10.7 to be exact)

 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 class MyProduct(Folder):
meta_type = bla
page = PageTemplateFile('zpt/foo.pt', globals())

def render_page(self):
 html = self.page(self.REQUEST) # ERROR!!

 The error is ridiculously large so I've truncated it:


 Error in test test_foo
 (Products.MoneyVillage2.tests.test_creditconfusion.TestCreditCheck)
 Traceback (most recent call last):
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Testing/ZopeTestCase/profiler.py,
 line 98, in __call__
testMethod()
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/Products/MoneyVillage2/tests/test_creditconfusion.py,
 line 20, in test_foo
print cc.advice2(self.app.REQUEST)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Shared/DC/Scripts/Bindings.py,
 line 313, in __call__
return self._bindAndExec(args, kw, None)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Shared/DC/Scripts/Bindings.py,
 line 350, in _bindAndExec
return self._exec(bound_data, args, kw)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Products/PageTemplates/PageTemplateFile.py,
 line 129, in _exec
return self.pt_render(extra_context=bound_names)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Products/PageTemplates/PageTemplate.py,
 line 98, in pt_render
showtal=showtal)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/pagetemplate/pagetemplate.py,
 line 117, in pt_render
strictinsert=0, sourceAnnotations=sourceAnnotations)()
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tal/talinterpreter.py,
 line 271, in __call__
self.interpret(self.program)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tal/talinterpreter.py,
 line 346, in interpret
handlers[opcode](self, args)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tal/talinterpreter.py,
 line 870, in do_useMacro
macro = self.engine.evaluateMacro(macroExpr)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tales/tales.py,
 line 696, in evaluate
return expression(self)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tales/expressions.py,
 line 217, in __call__
return self._eval(econtext)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Products/PageTemplates/Expressions.py,
 line 153, in _eval
ob = self._subexprs[-1](econtext)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/tales/expressions.py,
 line 124, in _eval
ob = self._traverser(ob, element, econtext)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/Products/PageTemplates/Expressions.py,
 line 83, in boboAwareZopeTraverse
request=request)
  File 
 /home/peterbe/virtualenvzope/MoneyVillage2/zope2107/lib/python/zope/traversing/adapters.py,
 line 161, in traversePathElement
raise TraversalError('No traversable adapter found', obj)
 TraversalError: ('No traversable adapter found', {'master':
 [('version', '1.6'), ('mode', 'html'), ('setPosition', (1, 0)),
 ('setSourceFile', 'main_template'), ('beginScope', {'define-macro':
 'master'}), ('optTag', ('metal:block', None, 'metal', 0, [('startTag',
 ('metal:block', [('define-macro', 'master', 'metal')]))], [('rawtextCo
 ...MANY MANY MORE
 LINES..



 --
 Peter Bengtsson,
 work www.fry-it.com
 home www.peterbe.com
 hobby www.issuetrackerproduct.com




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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

Re: [Zope] Call PageTemplateFile class instances

2008-11-13 Thread Peter Bengtsson
2008/11/13 Andrew Milton [EMAIL PROTECTED]:
 +---[ Peter Bengtsson ]--
 | I've kind of work it out. The trick is to write some boiler plate in
 | the class definition like this::
 |
 | from zope import traversing, component, interface
 | from zope.interface import implements
 | from zope.traversing.interfaces import ITraversable
 |
 | from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 | class MyProduct(Folder):
 |
 |implements(ITraversable)
 |component.provideAdapter(
 | traversing.adapters.DefaultTraversable,
 | (interface.Interface,),ITraversable)
 |
 |meta_type = bla
 |page = PageTemplateFile('zpt/foo.pt', globals())
 |
 |def render_page(self):
 | html = self.page(self.REQUEST) # ERROR!!


 why do you do this double shuffle anyway, when you can directly call
 page and protect it if necessary...

 I certainly don't have the issue you're describing and I don't need to
 do all that implements garbage either.

 Are you sure you don't have some Product installed that's messing with
 it?

No I'm not sure.
Truth is that my product is more complicated than that but so I took a
risk thinking it'll be the same as the pseudo product code I wrote.



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




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Call PageTemplateFile class instances

2008-11-13 Thread Peter Bengtsson
2008/11/13 Andreas Jung [EMAIL PROTECTED]:
 On 13.11.2008 17:53 Uhr, Peter Bengtsson wrote:

 This used to work in zope 2.8 but not now in zope 2.10 (actually zope
 2.10.7 to be exact)

 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 class MyProduct(Folder):
 meta_type = bla
 page = PageTemplateFile('zpt/foo.pt', globals())

 def render_page(self):
  html = self.page(self.REQUEST) # ERROR!!

 Are you sure that you don't have to pass the REQUEST as a keyword parameter?

No difference if I pass REQUEST or not.  :(

 -aj

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





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] FunctionalTestCase commits transactions

2008-11-05 Thread Peter Bengtsson
2008/11/4 Dieter Maurer [EMAIL PROTECTED]:
 Ross Patterson wrote at 2008-11-3 16:04 -0800:
 ...
If memory serves, a *functional* test fixture calls the Zope publisher
when a testbrowser request is made.  The publisher opens a new
transaction, as it should.

 Really?

 When I wrote a functional test browser (years before zope3),
 I emulated the Zope publisher rather than calling it directly
 in order to have control how transactions are handled.

 Especially, I used subtransactions instead of top level transactions
 to avoid the bug reported by Peter.


Uh? subtransactions?
So how would you recommend that I go abouts doing this?
In fact I've already written a custom tearDown() for my class that
cleans the test database (postgresql) which is quite neat because I
can write tests in a completely different way as each test can build
on each other (assuming order of methods is respected) similar to how
doctests are done where you have blocks of shell code split between
text.

If this is the way it has to be to test with zope.testbrowser in zope
2 then I'll let it be so.

-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] FunctionalTestCase commits transactions

2008-11-03 Thread Peter Bengtsson
I'm trying to get zope.testbrowser to work in Zope 2.10. After a lot
of guesswork (easy_install zope.testbrowser broke my environment, Zope
2.11 isn't setting up session container, used various blogs tips to
get adapters right) I got it running and I can now do stuff like
browser.open(self.folder.myapp.absolute_url()) in python unit test.
However, I have a problem. The app uses ZSQL Methods and when the test
finishes the transaction is not rolled back and I'm not interested in
manually resetting the test database.
Is this so deliberately?
Do I really have to manually reset the database?

I noticed that FunctionTestCase
(lib/python/Testing/ZopeTestCase/ZopeTestCase.py:116) inherits from
functional.Functional which inherits from sandbox.SandBoxed which,
although I don't understand it, seems to do things differently to the
non-functional approach which inherits from base.TestCase.

Although I'm not using it, function.Functional adds the nifty function
publish() which I'm not using but it's not a transaction.commit() in
it. Why??
And what does that decorator actually do?


Peter


class Functional(sandbox.Sandboxed):
...
__implements__ = (interfaces.IFunctional,)

@savestate
def publish(self, path, basic=None, env=None, extra=None,
request_method='GET', stdin=None, handle_errors=True):
'''Publishes the object at 'path' returning a response object.'''
   ...

# Commit the sandbox for good measure
transaction.commit()
...


-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] find zodb object sizes

2008-10-20 Thread Peter Bengtsson
What's a floating point division error?
I know what a ZeroDivisionError is but that's unlikely to be the case
for you now.

2008/10/20 Yuri [EMAIL PROTECTED]:
 Hi!

  I would like to run a script to see what objects size is, printing the
 zodb path.

  analize.py gives me a floating point division error, so I would like to
 ask if there's a simpler way to see what there's inside the ZODB.

  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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] delete a variable from REQUEST

2008-09-30 Thread Peter Bengtsson
Just set it to None.


if REQUEST['usr_msg']:
do_something()
REQUEST.set('usr_msg', None)

Then, the next time the condition will be false.

2008/9/30 indrajit926 indra [EMAIL PROTECTED]:
 Hi,

 thanks for ur reply.

 My problem is, my code is like

 #code code code

 if REQUEST['usr_msg']:
   do some operations.

 #some code related to project

 my program control loops with above  if condition.

 REQUEST is in same context.

 so once REQUEST stores 'usr_msg ' every time when it goes to if condition 
 , it performs that do some operations

 Due to above reason i want to delete that usr_msg variable from REQUEST

 also i cannot put restriction on usr_msg ,because it comes from user
 input, and user can give any text to that variable.

 thanks,
 Indrajit.

 On Mon, Sep 29, 2008 at 1:36 PM, Tino Wildenhain [EMAIL PROTECTED] wrote:

 Hi,

 indrajit926 indra wrote:

 Hi All,

 Iam relatively new to zope.

 I want to delete a variable and it value from REQUEST.I used python pop()
 and __delattr__() ,but getting attribute error.

 Actually you can't. (Not without writing a product in filesystem
 and getting deep into zope). Why would you?

 What you could do is to update one of the requests namespace to
 give the variable a new value.

 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 )





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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 hangs

2008-09-30 Thread Peter Bengtsson
Yes, and you can use the Control_Panel/DebugInfo as well and scroll
down to the Connections table. Out of the 8 threads most of them
should be vacant (ie. None) and if there are some requests logged
there they should in the range of  1 sec.
If any of them are longer than 1 sec they are either stuck or doing
something is supposed to take a long time (e.g. render a complex
report, do a big upload, etc.)

I once had a similar problem and I hacked the LDAPUserFolder to do a
timing of the connections and found that connecting to the LDAP server
was super slow and thus each connection cost too much time and it
subsequently blocked the threads.

Peter



2008/9/30 Nico Grubert [EMAIL PROTECTED]:
 Hi there

 in the last days my Zope server seems to hang and the CPU is almost
 every time at 100 %.

 I installed DeadlockDebugger and see a lot of these entries:
 -
   File /usr/local/Zope-2.10.5/lib/python/OFS/Traversable.py, line
 288, in unrestrictedTraverse
 return obj
   File /usr/local/Zope-2.10.5/lib/python/ZODB/Connection.py, line
 767, in setstate
 raise
   File /usr/local/Zope-2.10.5/lib/python/ZODB/Connection.py, line
 820, in _setstate
 obj._p_serial = serial
   File /usr/local/Zope-2.10.5/lib/python/ZODB/serialize.py, line 605,
 in setGhostState
 obj.__setstate__(state)
   File /usr/local/Zope-2.10.5/lib/python/ZODB/serialize.py, line 597,
 in getState
 return unpickler.load()
   File /usr/local/Zope-2.10.5/lib/python/ZODB/serialize.py, line 471,
 in _persistent_load
 return self.load_oid(reference)
   File /usr/local/Zope-2.10.5/lib/python/ZODB/serialize.py, line 537,
 in load_oid
 return self._conn.get(oid)
   File /usr/local/Zope-2.10.5/lib/python/ZODB/Connection.py, line
 225, in get
 return obj
   File
 /usr/local/Zope-2.10.5/lib/python/ZODB/FileStorage/FileStorage.py,
 line 562, in load
 self._lock_release()
   File /usr/local/lib/python2.4/threading.py, line 109, in acquire
 return rc
 -

 I am wondering what the last line
   File /usr/local/lib/python2.4/threading.py, line 109, in acquire
 return rc
 does exactly mean. Are the threads blocked?


 My configuration:
 -Zope 2.10.5 running with 8 threads on a 2-CPU machine with 8 GB of RAM
 -Python 2.4.4
 -LDAPUserfolder
 -Silva CMS 2.0.8
 -ZODB size: ~6 Gbyte
 -Only 6-10 people work in the CMS and no public access  (spy bots,
  crawlers) access the Zope server


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




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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 hangs

2008-09-30 Thread Peter Bengtsson
2008/9/30 Nico Grubert [EMAIL PROTECTED]:
 Yes, and you can use the Control_Panel/DebugInfo as well and scroll
 down to the Connections table. Out of the 8 threads most of them
 should be vacant (ie. None) and if there are some requests logged
 there they should in the range of  1 sec.
 If any of them are longer than 1 sec they are either stuck or doing
 something is supposed to take a long time (e.g. render a complex
 report, do a big upload, etc.)

 I once had a similar problem and I hacked the LDAPUserFolder to do a
 timing of the connections and found that connecting to the LDAP server
 was super slow and thus each connection cost too much time and it
 subsequently blocked the threads.

 Hi Peter

 thanks for your reply.

 At Control_Panel/DebugInfo I see
 ---
 None (44921)
 Tue Sep 30 13:24:18 2008 (0.37s)(... 'ACTUAL_URL':
 'http://fog:8086/Control_Panel/DebugInfo/manage_main'}) (641)
 None(57523)
 None(69795)
 None(47637)
 Tue Sep 30 13:24:17 2008 (1.18s)(... path/to/any/doc')}) (48335)
 ---

 I sometimes see a LDAP call in the DeadlockProfiler output so it could
 be the reason.

 Do you still have the LDAP patch around? I'd like to do a
 timing of the connections, too.


It was work on at a client's site. But I think you should look for
somehing like this:
conn.simple_bind_s(user_dn, user_pwd) in LDAPDelegate.py
so it looks something like this:

import time
T0 = time.time()
conn.simple_bind_s(user_dn, user_pwd)
T1 = time.time()
open('/tmp/timings.log','a').write('%s\n' % (T1-T0))


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




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] How to access the content of a file in a test suite in a portable way

2008-09-17 Thread Peter Bengtsson
From within the product class you can do this:

from Globals import package_home
class MyProduct(...):
meta_type = '...'
def do_something(self):
 print package_home(globals())


2008/9/17 Marco Bizzarri [EMAIL PROTECTED]:
 Hi all.

 I'm writing a number of acceptance tests where I need to compare
 whether the content of a text file is equals to another file.

 The comparision files are in a subdirectory of the acceptance test
 directory itself, therefore, once I know where my product is on the
 filesystem, I can access the test files from there.

 What is the accepted way to do know the directory of a product?

 Regards
 Marco

 --
 Marco Bizzarri
 http://notenotturne.blogspot.com/
 http://iliveinpisa.blogspot.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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] iterating over result sets in python

2008-08-24 Thread Peter Bengtsson
That's easy.

prev_date = None
for record in recordset:
if prev_date is None:
prev_date = record.mydate
print first date: %s % record.mydate
elif (prev_date + 30)  record.mydate:
print %s days since previous date % (record.mydate - prev_date)


2008/8/24 Garry Saddington [EMAIL PROTECTED]:
 I am trying to iterate over a result set from a zsql method in a python script
 in Zope 2. In the results is a date field. What I want to do is test whether
 a date is younger than the date in the previous row by at least 30 days but I
 am having problems working out how, not coming from a pythonic background.
 Could anyone point me in the correct direction?
 Regards
 garry
 ___
 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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] uncataloging

2008-08-14 Thread Peter Bengtsson
I don't know how to uncatalog a brain but I do know how to uncatalog a
normal zope object::

 # to uncatalog 'self'
 path = '/'.join(self.getPhysicalPath())
 self.MyCatalog.uncatalog_object(path)

 # to uncatalog some other know object
 path = '/'.join(self.some_object.getPhysicalPath())
 self.MyCatalog.uncatalog_object(path)



2008/8/14 Darryl Caldwell [EMAIL PROTECTED]:
 Hey folks,

 I have looked at the source of Catalog.py but am still confused about
 what parameters I need to uncatalog an object.

 Is the uid the same as the object id? That which is returned from
 obj.getId(), or is it the same as the object Identifier listed on the
 Catalog tab within the catalog? Thanks in advance. Code samples
 welcome.

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




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Asking recipe for caching objects

2008-08-01 Thread Peter Bengtsson
My ZSQL product has a very simple feature for hooking up up to
memcache but with one caveat: that you can't invalidate the cache.
It only works for selects of course but it's really easy to work with. E.g.

SQLSelectAverageUserAge(min=10, max=20, memcache__=True)
 (defaults to 5*60 seconds)
...or...
SQLSelectAverageUserAge(min=10, max=20, memcache__=10)
 (10 seconds)

I've only used it in one project but it made a huge difference.
However, it only makes sense to use this when you're going to call the
same SELECT many times which is something you should avoid of course
if you can.

2008/8/1 Marco Bizzarri [EMAIL PROTECTED]:
 Hi all.

 I have a zope application which uses a db (postgreSQL) to store and
 retrieve data. I would like to cache it.

 It is ok for me to cache them on thread-base. Up to now I've used a
 simple _v_ attribute, with a dictionary.

 The approach works, but:

 - the _v_ attribute is not transactional (and transactions could be
 rerun due to conflicts),
 - the dictionary can grows indefinitively.

 Therefore, I'm looking to see if there is a ready solution for this problem.

 Thanks you all in advance for your advice

 Regards
 Marco





 --
 Marco Bizzarri
 http://iliveinpisa.blogspot.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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] MySQL reconnects on zope application level

2008-07-16 Thread Peter Bengtsson
I don't have an easy answer but if you do dig into Andy's code and try
to implement this, I would suggest you look at the ZPsycopgDA code
perhaps and look for inspiration since I think that one works much
better.


2008/7/16 Jonas [EMAIL PROTECTED]:
 Hello,

 On several zope 2.10.6 instances we discovered issues with database
 connections to MySQL. Apparently MySQL seems to not automaticly
 reconnect connections with a timeout since version 5.0.3 due to issues
 with transactions.

 Until now, mysql-python was patched to restore that behaviour to
 automatically reconnect timeouted connections, but that is not the case
 anymore either.

 So from now on the database reconnects need to be done from zope
 applications on their own. Unfortunately the ZMySQLda adapter by Andy
 Dustman doesn't implement such a functionality.

 I cannot imagine that we are the only ones who discover this problem. Is
 there an easy way to implement automatic reconnects for Z MySQL Database
 Connections on zope application level?

 greetings, and thanks in advance,
  jonas
 ___
 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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Annoying when objectValues() doesn't work

2008-07-03 Thread Peter Bengtsson
from cStringIO import StringIO

def workflowscripts2methods(self):
out = StringIO()

print out, Star converting workflow scripts into External Methods

pw = self.portal_workflow
for workflow in pw.objectValues('Workflow'):
for container in workflow.objectValues('Workflow Scripts'):
meta_type = 'Script (Python)'
for script in container.objectValues(meta_type):
assert script.meta_type == meta_type
print out, script (%r, %s) % (script.meta_type,
script.absolute_url_path())


value = out.getvalue()
print value
return value


I'm getting an AssertionError on this!!!
After having used objectValues() for so many many years without much
trouble my confidence in it just dropped.
Anybody else seen something like this?

-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Annoying when objectValues() doesn't work

2008-07-03 Thread Peter Bengtsson
2008/7/3 Andreas Jung [EMAIL PROTECTED]:


 --On 3. Juli 2008 15:41:52 +0100 Peter Bengtsson [EMAIL PROTECTED] wrote:

 I'm getting an AssertionError on this!!!
 After having used objectValues() for so many many years without much
 trouble my confidence in it just dropped.

 After years of Zope, you know that we need a full traceback :-)


The traceback will just say that the AssertionError happened. It
doesn't mention anything interesting.

Traceback (innermost last):
  Module ZPublisher.Publish, line 101, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 39, in call_object
  Module Products.ExternalMethod.ExternalMethod, line 225, in __call__
   - __traceback_info__: ((CMFSite instance at 9b924a0,), {}, None)
  Module 
/home/peterbe/virtualenvzope/Gosh/zope278/Products/SeamusCore/Extensions/wf_script_despatcher.py,
line 41, in workflowscripts2methods
AssertionError





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Annoying when objectValues() doesn't work

2008-07-03 Thread Peter Bengtsson
2008/7/3 Andrew Milton [EMAIL PROTECTED]:
 +---[ Peter Bengtsson ]--
 | 2008/7/3 Andreas Jung [EMAIL PROTECTED]:
 | 
 | 
 |  --On 3. Juli 2008 15:41:52 +0100 Peter Bengtsson [EMAIL PROTECTED] 
 wrote:
 | 
 |  I'm getting an AssertionError on this!!!
 |  After having used objectValues() for so many many years without much
 |  trouble my confidence in it just dropped.
 | 
 |  After years of Zope, you know that we need a full traceback :-)
 | 
 |
 | The traceback will just say that the AssertionError happened. It
 | doesn't mention anything interesting.
 |
 | Traceback (innermost last):
 |   Module ZPublisher.Publish, line 101, in publish
 |   Module ZPublisher.mapply, line 88, in mapply
 |   Module ZPublisher.Publish, line 39, in call_object
 |   Module Products.ExternalMethod.ExternalMethod, line 225, in __call__
 |- __traceback_info__: ((CMFSite instance at 9b924a0,), {}, None)
 |   Module 
 /home/peterbe/virtualenvzope/Gosh/zope278/Products/SeamusCore/Extensions/wf_script_despatcher.py,
 | line 41, in workflowscripts2methods
 | AssertionError

 It does tell you the script and the line of the External Method that is
 causing the problem when being instanced via _getOb() (from
 objectValues)

I know. That was the script I showed and the code only has one obvious
assert statement. That was my code the assert statement. The point is,
it shouldn't happen, ever.



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Annoying when objectValues() doesn't work

2008-07-03 Thread Peter Bengtsson
2008/7/3 Andrew Milton [EMAIL PROTECTED]:
 +---[ Peter Bengtsson ]--
 | 2008/7/3 Andrew Milton [EMAIL PROTECTED]:
 |  +---[ Peter Bengtsson ]--
 |  | 2008/7/3 Andreas Jung [EMAIL PROTECTED]:
 |  | 
 |  | 
 |  |  --On 3. Juli 2008 15:41:52 +0100 Peter Bengtsson [EMAIL PROTECTED] 
 wrote:
 |  | 
 |  |  I'm getting an AssertionError on this!!!
 |  |  After having used objectValues() for so many many years without much
 |  |  trouble my confidence in it just dropped.
 |  | 
 |  |  After years of Zope, you know that we need a full traceback :-)
 |  | 
 |  |
 |  | The traceback will just say that the AssertionError happened. It
 |  | doesn't mention anything interesting.
 |  |
 |  | Traceback (innermost last):
 |  |   Module ZPublisher.Publish, line 101, in publish
 |  |   Module ZPublisher.mapply, line 88, in mapply
 |  |   Module ZPublisher.Publish, line 39, in call_object
 |  |   Module Products.ExternalMethod.ExternalMethod, line 225, in __call__
 |  |- __traceback_info__: ((CMFSite instance at 9b924a0,), {}, None)
 |  |   Module 
 /home/peterbe/virtualenvzope/Gosh/zope278/Products/SeamusCore/Extensions/wf_script_despatcher.py,
 |  | line 41, in workflowscripts2methods
 |  | AssertionError
 | 
 |  It does tell you the script and the line of the External Method that is
 |  causing the problem when being instanced via _getOb() (from
 |  objectValues)
 | 
 | I know. That was the script I showed and the code only has one obvious
 | assert statement. That was my code the assert statement. The point is,
 | it shouldn't happen, ever.

 Except CMFSite is calling it according to your traceback..


CMFSite is the type of the container that holds the External Method
that runs that stuff.

-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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 stops responding

2008-07-03 Thread Peter Bengtsson
Yes, couldn't agree more with kevin. DeadlockDebugger is crucial. It
won't change anything other than that you'll have information about
what really needs to change.
As an intermediate solution you can start to increase the number of
Zope threads from 4 to 6 or 8 and see if that kills the CPU of your
beefy server. Too many threads can hurt performance especially when
working with badly coded external connectors that selfishly hook
itself to the python GIL too much.
A lightweight alternative to DeadlockDebugger is the table at the
bottom of the Debug Information page in Control_Panel. If any of the
dates in the first column in that table shows times longer than a
second you have a problem with those requests.

Peter

2008/7/3 Garry Saddington [EMAIL PROTECTED]:
 Following a hard disk crash 2 weeks ago we have installed Zope onto a new
 server and all was fine until yesterday morning when Zope stopped responding
 and required a restart to get it working. It did the same at 3-30pm today.
 We are using Zope 2.9.0 on Centos 5.1 on a quad Zeon server with 4gb. Ram. At
 the moment the server is in quite heavy use with teachers trying to write
 reports for a deadline tomorrow. These are sent to a Postgres DB via psycopg.
 There is nothing in Z2.log or event.log to point me to the problem. I am
 therefore asking for advice on the sorts of things that can cause Zope to
 stop responding and whether there is anything we can do to mitigate against
 such an event.
 Thanks and regards
 Garry
 ___
 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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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: CMF security error in DCWorkflow that doesn't make sense

2008-07-02 Thread Peter Bengtsson
Some progress.

I managed to get it work by de-selecting the Manager role on the
Proxy roles. Makes absolutely no sense.

Later today I had another similar problem/error and nothing I changed
on the Proxy roles mattered. I ended up replacing the Python Scipt
with an External Method and that worked.
This absolutely sucks. The DCWorkflow code is incredibly complicated
and obscure and I hope it burns in hell. Having said that, I don't
think I would do any better if I was to replicate what it can do :)



2008/7/1 Peter Bengtsson [EMAIL PROTECTED]:
 First of all, I'm not sure if this is the right mailing list but
 hopefully the DCWorkflow people read this list too.

 I've got a strange problem.
 On my laptop it works (zope 2.7.8) on the live server it works (zope
 2.7.3) but on the test server (2.7.8) it doesn't!!! And it's the same
 Data.fs and Products as the live server. It throws an Unauthorized
 error upon executing a python script as part of a workflow transition.
 The Error:

 The owner of the executing script is defined outside the context of
 the object being accessed. The script has proxy roles, but they do not
 apply in this context.. Access to 'workflow' of
 (Products.DCWorkflow.Expression.StateChangeInfo instance at 0xddffb48)
 denied. Access requires Manage_portal_Permission, granted to the
 following roles: ['Manager']. The executing script is (PythonScript at
 /intranet/portal_workflow/intranet_workflow/scripts/wf_script_despatcher),
 owned by oliver.

 The Python script has Proxy role Manager so how can it be limited?

 I didn't write this CMF based application and I want to get on top of
 it so it doesn't happen again.

 Regards, Peter


 --
 Peter Bengtsson,
 work www.fry-it.com
 home www.peterbe.com
 hobby www.issuetrackerproduct.com




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] unicode support

2008-06-26 Thread Peter Bengtsson
Make the form input tags look like this:
input name=mystring:utf-8:ustring /
then you'll be certain to get it into Zope as unicode under utf-8.

2008/6/26 Garry Saddington [EMAIL PROTECTED]:
 I am using Zope 2.9 connected to a Posgres DB via psycopg. My database
 encoding is UTF8.

 I am getting the following error when users try to insert text in the
 database containing £ signs:

 ERROR: invalid byte sequence for encoding UTF8: 0xa3

 This is due to the encoding of a £ sign in the text being sent to the DB.

 My question then is how do I make sure that all encodings submiitted from
 forms are in the correct UTF8 format?

 Regards

 Garry

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





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] unicode support

2008-06-26 Thread Peter Bengtsson
I would advice against relying on default-zpublisher-encoding. I never
used that.
By specifying the encoding like this  variablename:utf8:ustring you
override whatever default-zpublisher-encoding was set to.
If you rely on default-zpublisher-encoding your product isn't
installable somewhere in another zope without explicit instructions
and it might clash with other things installed.
Remember, it's just a default.

2008/6/26 Garry Saddington [EMAIL PROTECTED]:
 On Thursday 26 June 2008 15:12, Andreas Jung wrote:

 --On 26. Juni 2008 14:09:50 + Garry Saddington



 [EMAIL PROTECTED] wrote:

  I am using Zope 2.9 connected to a Posgres DB via psycopg. My database

  encoding is UTF8. I am getting the following error when users try to

  insert text in the database containing £ signs: ERROR: invalid byte

  sequence for encoding UTF8: 0xa3

 

  This is due to the encoding of a £ sign in the text being sent to the
  DB.

  My question then is how do I make sure that all encodings submiitted
  from

  forms are in the correct UTF8 format? Regards



 Use ensure that the HTML page uses UTF-8 as encoding

 (either using meta-equiv... within the HTML page or by sending



 content-type: text/html; charset=utf-8



 as HTTP header.



 I have taken this a little further after trying all suggestions in the
 thread with no success and looked into zope.conf, specifically:

 # Directive: default_zpublisher_encoding

 #

 # Description:

 # This controls what character set is used to encode unicode

 # data that reaches ZPublisher without any other specified encoding.

 #

 # Default: iso-8859-15

 #

 # Example:

 #

 # default_zpublisher_encoding utf-8

 As my pages all report as iso-8859-15 I thought a change here would help,
 but this happens:

 from OFS.content_types import guess_content_type

 Error: 'default_zpublisher_encoding' is not a known key name

 It works on this: Zope Version (Zope 2.9.0, python 2.4.2, win32)

 And fails on this: Zope Version (Zope 2.9.0-, python 2.4.5, linux2)

 Any further help would be appreciated.

 regards

 Garry

 ps. just noticed the typo (not mine) in zope.conf -
 default_zpublisher_encoding should be default-zpublisher-encoding

 all sorted

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





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] zopectlsock missing

2008-06-11 Thread Peter Bengtsson
This happens from time to time and I've never really understood how it
ends up like this.
There's no zopeinstance/var/zopectlsock socket which means that
zopectl stop|restart|start just spits out daemon manager not running
When in fact, Zope is running. It's there when you run `netstat -nptl`
and you can go to the.
If I do go in to http://localhost:8080/Control_Panel/manage_main and
Shutdown the next time I'll be able to use zopectl happily.

Does anybody know what's going on with and why it goes missing?
I have a vague suspicion that it might have something to do with my
init.d restart script and rebooting of the server but I could be
wrong.

Cheers,
Peter

-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] zopectlsock missing

2008-06-11 Thread Peter Bengtsson
2008/6/11 Martijn Pieters [EMAIL PROTECTED]:
 On Wed, Jun 11, 2008 at 3:28 PM, Peter Bengtsson [EMAIL PROTECTED] wrote:
 This happens from time to time and I've never really understood how it
 ends up like this.
 There's no zopeinstance/var/zopectlsock socket which means that
 zopectl stop|restart|start just spits out daemon manager not running
 When in fact, Zope is running. It's there when you run `netstat -nptl`
 and you can go to the.
 If I do go in to http://localhost:8080/Control_Panel/manage_main and
 Shutdown the next time I'll be able to use zopectl happily.

 Does anybody know what's going on with and why it goes missing?
 I have a vague suspicion that it might have something to do with my
 init.d restart script and rebooting of the server but I could be
 wrong.

 If this in a buildout, then you you ran bin/buildout which nuked your
 parts/instance directory with the socket. This is a bug in
 zope2instance where it sets the CLIENT_HOME to parts/instance instead
 of a part-specific subdirectory of var/


This is not buildout. Just regular zope like it's been since 1999


-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] REMOTE_ADDR passed through when proxying

2008-06-11 Thread Peter Bengtsson
Since apache sits in front of Zope, the REMOTE_ADDR header always
becomes '127.0.0.1' not the IP address of the actual client
connecting.
What do I need to do to get this passed on to Zope.

Tried ProxyPreserveHost and ProxyVia but that's not it. I've even
tried, dangerously, switching ProxyRequests On.

Peter

-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] REMOTE_ADDR passed through when proxying

2008-06-11 Thread Peter Bengtsson
2008/6/11 Andreas Jung [EMAIL PROTECTED]:


 --On 11. Juni 2008 17:34:27 +0100 Peter Bengtsson [EMAIL PROTECTED] wrote:

 Since apache sits in front of Zope, the REMOTE_ADDR header always
 becomes '127.0.0.1' not the IP address of the actual client
 connecting.
 What do I need to do to get this passed on to Zope.


 trusted-proxies within zope.conf?
Yeah. Got that.
It's set to the IP and the domain name used like the example shows.

In fact, I'm deploying a site in Ubuntu that was originally deployed
with FreeBSD and I've copied everything! (Putting it in quotes
because I can't be 101% certain plus certain things should be copied).
On the FreeBSD the apache was compiled from source (long before I
arrived).

Besides, the IP addres IS passed but under HTTP_X_FORWARDED_FOR but I
think the Domain part of acl_users relies on REMOTE_ADDR


 -aj



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] display uploaded file

2008-06-06 Thread Peter Bengtsson
Change the uploaded file's content_type to text/plain and the browser
will try to display it.
This is something you can do to images too but you'll get a very
looong page of junk.

2008/6/6 sujitha mary [EMAIL PROTECTED]:
 hi all,
 I need to display the contents of an uploaded file when i click a link.But
 when i click the link instead of displaying the contents i'm getting a
 message to save this BIN file.wht changes should i make to display it in my
 plone interface?Plz help.

 
 Bollywood, fun, friendship, sports and more. You name it, we have it.
 ___
 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 )





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] zope-memory-readings

2008-05-30 Thread Peter Bengtsson
Check it out
http://code.google.com/p/zope-memory-readings/

Perhaps useful

-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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 PIL Images

2008-05-28 Thread Peter Bengtsson
2008/5/28 Gaurav Girotra [EMAIL PROTECTED]:
 Hello

 I am using Plone3 and zope 2.10,
 I need to save images generated through MatplotLib Graphs using External
 Methods to my zope site or to my linux file system.

 When i try to save using im.save(/zope/zeocluster/Extemsions)

Been a while but doesn't im.save() expect a filename?

 folder i get Permission denied error.

 Can anyone Help me in saving images to the file system.

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





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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: But I have python2.4-dev installed

2008-05-01 Thread Peter Bengtsson
Turns out that I was missing libc6-dev (I had libc6)

2008/4/28 Tres Seaver [EMAIL PROTECTED]:


  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1


  Peter Bengtsson wrote:
   Searching the mailing list it seems that the uniform advice is to
   install python2.4-dev but I already have that installed. I also
   installed the metapackage
   python-all-dev just to be safe. I'll paste the whole error of what
   happens when I try to make a configured Zope 2.10 or Zope 2.9.8.
   In the error it says this:
   /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h:122:61: error:
   limits.h: No such file or directory
   But that file exists and around line 122 it contains the following:
   121 #ifdef _GCC_NEXT_LIMITS_H
   122 #include_next limits.h/* recurse down to the real 
 one */
   123 #endif
  
   This is the first Zope I've tried to install on this brand spanking
   new (K)ubuntu 8.04 which is a fresh install (not an upgrade).
   The error:

  Googling that error reveals the following gcc thread which seems to be
  relevant:

   http://gcc.gnu.org/ml/gcc-patches/2004-11/msg00819.html


  Tres.
  - --
  ===
  Tres Seaver  +1 540-429-0999  [EMAIL PROTECTED]
  Palladion Software   Excellence by Designhttp://palladion.com
  -BEGIN PGP SIGNATURE-
  Version: GnuPG v1.4.6 (GNU/Linux)
  Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

  iD8DBQFIFlSn+gerLs4ltQ4RArWtAJ0ceikWr8z9Ty7wnKP8rR1Sr9oGowCgy3sq
  2/qcsS+1cQuvQ/XUNqPUQok=
  =PYkF
  -END PGP SIGNATURE-





-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] But I have python2.4-dev installed

2008-04-28 Thread Peter Bengtsson
Searching the mailing list it seems that the uniform advice is to
install python2.4-dev but I already have that installed. I also
installed the metapackage
python-all-dev just to be safe. I'll paste the whole error of what
happens when I try to make a configured Zope 2.10 or Zope 2.9.8.
In the error it says this:
/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h:122:61: error:
limits.h: No such file or directory
But that file exists and around line 122 it contains the following:
121 #ifdef _GCC_NEXT_LIMITS_H
122 #include_next limits.h/* recurse down to the real one */
123 #endif

This is the first Zope I've tried to install on this brand spanking
new (K)ubuntu 8.04 which is a fresh install (not an upgrade).
The error:


/usr/bin/python2.4 /tmp/test_environment/Zope-2.9.8-final/setup.py \
build
--build-base=/tmp/test_environment/Zope-2.9.8-final/build-base/python-2.4
--build-lib=/tmp/test_environment/Zope-2.9.8-final/build-base/python-2.4/build-lib
--build-scripts=/tmp/test_environment/Zope-2.9.8-final/build-base/python-2.4/build-scripts
--build-temp=/tmp/test_environment/Zope-2.9.8-final/build-base/python-2.4/build-temp
running build
running build_py
running build_ext
creating zope.proxy
copying zope/proxy/proxy.h - zope.proxy
building 'AccessControl.cAccessControl' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
-Wstrict-prototypes -fPIC -IExtensionClass -I. -IAcquisition
-I/usr/include/python2.4 -c AccessControl/cAccessControl.c -o
/tmp/test_environment/Zope-2.9.8-final/build-base/python-2.4/build-temp/AccessControl/cAccessControl.o
In file included from /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h:7,
 from /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h:11,
 from /usr/include/python2.4/Python.h:18,
 from ./ExtensionClass/ExtensionClass.h:83,
 from AccessControl/cAccessControl.c:51:
/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h:122:61: error:
limits.h: No such file or directory
In file included from ./ExtensionClass/ExtensionClass.h:83,
 from AccessControl/cAccessControl.c:51:
/usr/include/python2.4/Python.h:32:19: error: stdio.h: No such file or directory
/usr/include/python2.4/Python.h:34:5: error: #error Python.h requires
that stdio.h define NULL.
/usr/include/python2.4/Python.h:37:20: error: string.h: No such file
or directory
/usr/include/python2.4/Python.h:38:19: error: errno.h: No such file or directory
/usr/include/python2.4/Python.h:39:20: error: stdlib.h: No such file
or directory
/usr/include/python2.4/Python.h:41:20: error: unistd.h: No such file
or directory
/usr/include/python2.4/Python.h:53:20: error: assert.h: No such file
or directory
In file included from /usr/include/python2.4/Python.h:55,
 from ./ExtensionClass/ExtensionClass.h:83,
 from AccessControl/cAccessControl.c:51:
/usr/include/python2.4/pyport.h:7:20: error: stdint.h: No such file or directory
In file included from /usr/include/python2.4/Python.h:55,
 from ./ExtensionClass/ExtensionClass.h:83,
 from AccessControl/cAccessControl.c:51:
/usr/include/python2.4/pyport.h:73: error: expected '=', ',', ';',
'asm' or '__attribute__' before 'Py_uintptr_t'
/usr/include/python2.4/pyport.h:74: error: expected '=', ',', ';',
'asm' or '__attribute__' before 'Py_intptr_t'
/usr/include/python2.4/pyport.h:94:76: error: math.h: No such file or directory
/usr/include/python2.4/pyport.h:101:22: error: sys/time.h: No such
file or directory
/usr/include/python2.4/pyport.h:102:18: error: time.h: No such file or directory
/usr/include/python2.4/pyport.h:120:24: error: sys/select.h: No such
file or directory
/usr/include/python2.4/pyport.h:159:22: error: sys/stat.h: No such
file or directory
In file included from /usr/include/python2.4/Python.h:74,
 from ./ExtensionClass/ExtensionClass.h:83,
 from AccessControl/cAccessControl.c:51:
/usr/include/python2.4/pymem.h:50: warning: parameter names (without
types) in function declaration
/usr/include/python2.4/pymem.h:51: error: expected declaration
specifiers or '...' before 'size_t'
In file included from /usr/include/python2.4/Python.h:76,
 from ./ExtensionClass/ExtensionClass.h:83,
 from AccessControl/cAccessControl.c:51:
/usr/include/python2.4/object.h:227: error: expected declaration
specifiers or '...' before 'FILE'
/usr/include/python2.4/object.h:371: error: expected declaration
specifiers or '...' before 'FILE'
In file included from /usr/include/python2.4/Python.h:77,
 from ./ExtensionClass/ExtensionClass.h:83,
 from AccessControl/cAccessControl.c:51:
/usr/include/python2.4/objimpl.h:97: warning: parameter names (without
types) in function declaration
/usr/include/python2.4/objimpl.h:98: error: expected declaration
specifiers or '...' before 'size_t'
/usr/include/python2.4/objimpl.h:292: 

Re: [Zope] Zope X Plone

2008-04-24 Thread Peter Bengtsson
On 24/04/2008, Tatiane Almeida [EMAIL PROTECTED] wrote:

  Hi!



 I'm a new Zope programmer, and I want to know:

 1) What is the relation between zope and plone?
Zope is the application platform where you build applications. Plone
is one of those applications.


 2) What is plone and when I use it?

When you want to set up a CMS with the CMSy features that Plone offers.
When you want something more specific, for example an bug tracker,
you build your own application in Zope.



 Thanks.



 Tatiane

 
 Notícias direto do New York Times, gols do Lance, videocassetadas e muitos
 outros vídeos no MSN Videos! Confira já!
 ___
  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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Guarded __getitem__ with non-ascii unicode key

2008-04-20 Thread Peter Bengtsson
Today I had to write this supporting method in my product to prevent a
rather strange Unauthorized error in my Page Template. My docstring
should explain what I understand::


def unsafe_unicode_dict_getitem(self, dictionary, item):
 Return the value of this item in a dictionary object.

Simply call the __getitem__ of this dictionary to pluck out an
item.

Why call this unsafe_...() ?
If you try to do this in a guarded context (e.g. Script (Python)
(or Page Template)) you'll get an Unauthorized error:

  d = {u'\xa3':1}
  d[u'\xa3'] # will raise an Unauthorized error

  # this works however
  d = {u'\xa3':1, u'asciiable':1}
  d[u'asciiable']

Why? I don't know. The place where it happens is the parental guardian
function guarded_getitem() from ZopeGuards.py

By instead calling the __getitem__ from here in unrestricted python
we can bypass this.

return dictionary[item]


Is my app unsafe now?
Why is it not possible to get to __getitem__ if the key is non-ascii?


-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] anyone heard of Zamasing?

2008-04-16 Thread Peter Bengtsson
Not until now. But I'm amased! Really looking forward to taking it for a spin.

On 16/04/2008, Chris Withers [EMAIL PROTECTED] wrote:
 ...I certainly never had until someone threw a press release my way...

  http://zamasing.com

  Any ideas/comments/etc?

  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 )



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Problem with DTML and JOINS(ZSQL)

2008-04-15 Thread Peter Bengtsson
Zope is agnostic of whatever SQL you enter. In other words, they
compile differently and their errors are completely different.
I suggest you do this:

1. Fake the ZSQL to make sure your DTML is correct by changing the SQL
to something like this:
  SELECT 'drug_name_test', 'route_of_admin_test', etc.

2. Then write the ZSQL properly with the correct SQL syntax that you
want to use and as you're developing this, test it using the ZSQL
Method's Test tab rather than testing it via your custom DTML
application.

3. Run together.


PS. Tip: I always name my ZSQL methods something like
select_all_drug_zsql or UpdateOneDrug.sql just to avoid confusion when
I'm later working on the application. 'drug' isn't a suitable name of
a function/method.

On 15/04/2008, member madhangc [EMAIL PROTECTED] wrote:
 Dear all, I am developing a web application for a biological research
 institute down here in india. I have some
 problem in using JOINS. The below is the queries i used,

 SQL query

 File name : drug
  select drug_name,dtype from bio_info_schema.drug order by dtype

 File name:drug_gene_details
 Note : i used both the sql queries seperately, but neither one worked.

 SELECT
 drug.drug_name,drug.route_of_admin,drug.dose_adult,drug.dose_child,drug.adverse_effects,drug_gene.gene_name
  FROM drug,drug_gene
 WHERE drug.drug_name = drug_gene.drug_name and drug.drug_name=dtml-sqlvar
 drug_name type=string

 SELECT
 drug.drug_name,drug.route_of_admin,drug.dose_adult,drug.dose_child,drug.adverse_effects,drug.dtype,drug_gene.gene_name
  FROM drug INNER JOIN drug_gene
 ON drug.drug_name = drug_gene.drug_name AND drug.drug_name=dtml-sqlvar
 drug_name type=string

 Below is the DTML code i have used,

 File name : view_drug_detail
 table width = 30% border = 1 
  tr
  !-- Table header --
  thDrug Name/th
  /tr
  !-- Iterate through drug details using dtml-in tag --
  dtml-in drug
  !-- for each drug , print out the drug name and type of drug --
  tr
  td align = center
  a
 href=http://localhost:8080/ddrd/ddrtb/drugs/display_drugs/drug_gene_details/drug_name/dtml-var
 drug_name/view_drug_infodtml-var drug_name/a/td
  /tr
  /dtml-in
  /table

 File name : view_drug_info
  h3font color= #008000centerDrug Information
 Summary/center/font/h3
  table width = 100% border = 1 align=center
 tr
  thDrug name/thtddtml-var drug_name/td
  /tr
 tr
  thRoute of Administration/thtddtml-var
 route_of_admin/td
  /tr
 tr
  thDosage (Adult)/thtddtml-var dose_adult/td
  /tr
 tr
  thDosage (Child)/thtddtml-var dose_child/td
  /tr
 tr
  thAdverse Effects/thtddtml-var adverse_effects/td
  /tr
 tr
  thDrug Type/thtddtml-var dtype/td
  /tr
 tr
  thDrug Targets/thtddtml-var gene_name/td
  /tr
 /table

 This is the error which i got.

 Site Error

  An error was encountered while publishing this resource.
 exceptions.KeyError
  Sorry, a site error occurred.
 Traceback (innermost last):
  * Module ZPublisher.Publish, line 150, in publish_module
 * Module ZPublisher.Publish, line 114, in publish
  * Module Zope, line 134, in zpublisher_exception_hook
 * Module Shared.DC.ZRDB.DA, line 547, in __getattr__
  KeyError: _r
 Troubleshooting Suggestions
  * The URL may be incorrect.
 * The parameters passed to this resource may be incorrect.
  * A resource that this resource relies on may be encountering an error.
  For more detailed information about the error, please refer to the HTML
 source for this page.
  If the error persists please contact the site maintainer. Thank you for
 your patience.

 Any kind of suggestion and help will be very useful. Thanks in advance.

 --
 Best Regards
 \madhan

 Things must be learned only to be unlearned again or, more likely, to be
 corrected.
  -- Richard Feynman
 ___
  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 )




-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Help writing test where bobobase_modification_time changes

2008-04-11 Thread Peter Bengtsson
Thanks for the tips Chris and Dieter, I actually solved it in a very simple way:


from OFS.Image import File
from time import time
class MockFile(File):
 This file works the same as a normal File expect that
in manage_edit() the internal modification time is set immediately.
Normally Zope objects get their internal modification set when
the transaction manager commits.


def manage_edit(self, title, content_type, precondition='',
filedata=None, REQUEST=None):
# here's the mock hack, we set the _p_mtime NOW instead of letting
# the transaction manager do it at the end.
self._p_mtime = time()
return File.manage_edit(self, title, content_type,
precondition=precondition,
filedata=filedata, REQUEST=REQUEST)

This worked beautifully in the integration test. I'm happy.

On 10/04/2008, Chris Withers [EMAIL PROTECTED] wrote:
 Peter Bengtsson wrote:

  How can I solve this? Make one big transaction two without having to
  use transaction.get().commit() which I don't think I can use in unit
  tests as per Dieter's advice.
 

  I'd suggest monkeypatching bobobase_modification_time on the objects you're
 testing with. You're testing your cache code, not the implementation of
 those objects, so replacing them with (partially) dummy objects is great for
 avoiding this kind of problem and is a pattern I've used frequently...

  cheers,

  Chris

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



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Help writing test where bobobase_modification_time changes

2008-04-08 Thread Peter Bengtsson
I'll try to explain as briefly as possible.
I've got a working cache pattern that keeps a cached version of a Zope
file's content and only when it changes (by 
bobobase_modification_time) the cache is invalidated and recreated.
Here's the gist of my test

class Test(ZopeTestCase.FunctionalTestCase):

def test_recreateCache(self):
  bla 
 self.folder.manage_addFile('foo.js','FOO data')
 url = self.folder.mytool.cacheFile('foo.js') # pseudo code this time
 path = urlparse(url)[2]
 response = self.publish(path)
 self.assert... tests on response...

 _file = getattr(self.folder, 'foo.js')
 _file.manage_edit(_file.title, _file.content_type,
  filedata='new data')

 newurl = self.folder.mytool.cacheFile('foo.js')
 assert newurl != url, url hasn't changed :(

The reason it fails on the last line is that the time difference
between the first time and the second time is nil. Adding a
time.sleep(1) won't change anything because the
bobobase_modification_time() doesn't change.

How can I solve this? Make one big transaction two without having to
use transaction.get().commit() which I don't think I can use in unit
tests as per Dieter's advice.

Grateful for help.
Peter


-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] ZopeTestCase and Selenium RC? Anybody?

2008-03-20 Thread Peter Bengtsson
Has anybody managed to marry ZopeTestCase (and the ZopeLite running
database) with Selenium RC?
I like Selenium but it's a pain to have to manually create a fixture
and tear it down again.
Would it be possible to kick start Selenium RC from within the
testrunner on zope2?

-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] ZopeTestCase and Selenium RC? Anybody?

2008-03-20 Thread Peter Bengtsson



Andreas Jung wrote:



--On 20. März 2008 12:50:48 + Peter Bengtsson [EMAIL PROTECTED] wrote:


Has anybody managed to marry ZopeTestCase (and the ZopeLite running
database) with Selenium RC?
I like Selenium but it's a pain to have to manually create a fixture
and tear it down again.
Would it be possible to kick start Selenium RC from within the
testrunner on zope2?



I have no idea how Selenium and ZTC would be related - neither in 
general nor in this particular case.




I don't know how/if the zope testrunner starts a server that can be 
reached with a browser or not. If it does start a server that can be 
used in Firefox I'd be able to run som Selenium scripts (Remote 
Controlled or manually) and when I'm happy with the browser stuff I'd 
stop the testrunner which would reset the database/zodb again.


Basically, having to manually create a fixture for running Selenium 
scripts is a bore. There's got to be an easier way.


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] ZopeTestCase and Selenium RC? Anybody?

2008-03-20 Thread Peter Bengtsson



Andreas Jung wrote:



--On 20. März 2008 14:24:57 + Peter Bengtsson [EMAIL PROTECTED] wrote:




Andreas Jung wrote:



--On 20. März 2008 12:50:48 + Peter Bengtsson [EMAIL PROTECTED]
wrote:


Has anybody managed to marry ZopeTestCase (and the ZopeLite running
database) with Selenium RC?
I like Selenium but it's a pain to have to manually create a fixture
and tear it down again.
Would it be possible to kick start Selenium RC from within the
testrunner on zope2?



I have no idea how Selenium and ZTC would be related - neither in
general nor in this particular case.



I don't know how/if the zope testrunner starts a server that can be
reached with a browser or not.



ZTC won't start any servers.



What are my options then other than manually creating the fixtures?


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Choosing printer in client computer

2008-03-19 Thread Peter Bengtsson
You've seen Andreas response already so I'm not going to repeat that.
I don't think the browser will ever have access to these settings.
Imagine if it did, it could open up a world of security risks for just
using a normal web page.

On 18/03/2008, rieh25 [EMAIL PROTECTED] wrote:

  I need an application to choose a specific printer in a client computer (not
  the server) for printing reports. Internet explorer uses register entries to
  configure the default printer, but the problem is that an external script
  would do this changes in the server, not the local computer. Or should I
  just give up trying to use Zope and use an external utility (MS Access
  perhaps) to manage the printing part of the application?
  --
  View this message in context: 
 http://www.nabble.com/Choosing-printer-in-client-computer-tp16130952p16130952.html
  Sent from the Zope - General mailing list archive at Nabble.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 )



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Upgrading a Product from Zope 2.7 to Zope 2.10

2008-03-19 Thread Peter Bengtsson
I'm not an expert at these kind of things but 3 tips:

* Don't bother with trying to run off the old Data.fs until you get
your product working in the new Zope.

* Inspect your code and what kind of objects (and most likely more
importantly) and attributes you're attaching to classes that are
persistent. I've forgotten my case now but I remember that I had a
problem when I was trying to set an attribute that turned out to be a
uncalled class method of another class.

* Get familiar with this: 'import pdb; pdb.set_trace()'

On 19/03/2008, Mark Hellewell [EMAIL PROTECTED] wrote:
 Hello,

  I'm in the middle of trying to upgrade a Product written for Zope 2.7
  so that it runs on Zope 2.10!

  The product appears in the newer ZMI's list of available products but
  whenever I try to add an object of the products type through the ZMI I
  get the following error in the event.log and nothing is added to the
  site:

  Traceback (innermost last):
Module ZPublisher.Publish, line 125, in publish
Module Zope2.App.startup, line 238, in commit
Module transaction._manager, line 96, in commit
Module transaction._transaction, line 395, in commit
Module transaction._transaction, line 495, in _commitResources
Module ZODB.Connection, line 502, in commit
Module ZODB.Connection, line 1046, in savepoint
Module ZODB.Connection, line 555, in _commit
Module ZODB.Connection, line 582, in _store_objects
Module ZODB.serialize, line 407, in serialize
  TypeError: Can't pickle objects in acquisition wrappers.

  additionally, if I take a Data.fs from my Zope 2.7 instance and try
  running with it in place on a 2.10 instance the various objects of the
  product already created simply don't show up (no broken icon, nothing)

  Running Zope 2.10.5 and Python 2.4.4 and the Product in question was
  written using CMF 1.4.2 (but now upgraded to CMF 1.6.4, I've made
  several changes already to accomodate this upgrade)

  I'd be grateful for any insight anyone might have or any hints at what
  to do next!

  Thanks,
  Mark
  ___
  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 )



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] For the record

2008-03-19 Thread Peter Bengtsson
On 19/03/2008, Dieter Maurer [EMAIL PROTECTED] wrote:
 Peter Bengtsson wrote at 2008-3-18 17:38 +:

 I wanted to see how much faster brain.getObject() would be if the
  returned object was located in a BTreeFolder versus a normal folder so
  I wrote a benchmark that created about 10,000 light simple objects in
  two distinctly different containers and each with a ZCatalog that has
  a PathIndex.
  
  I would expect the BTreeFolder parenting calls of brain.getObject() to
  be much faster but I found that there was NO DIFFERENCE. wtf?!


 If you access many (most) objects, these accesses may be even
  more expensive with a BTreeFolder than with a standard folder.
  This is not that difficult to explain:

   When you access a normal folder, with the folder all child
   references are loaded. When you later access the folder
   again (and it has not yet been flushed from the ZODB cache),
   no loading is necessary.

   When you access a BTreeFolder, no child references are loaded.
   Thus, elementary access to a BTreeFolder is much more
   efficient.
   When you access a child in a BTreeFolder, then all child
   references are loaded that are in the same bucket as the
   access child. In addition, all nodes on the path
   from the BTreeFolder to this bucket are loaded.
   When you access many children, you have a good chance,
   that you have accessed at least on child in each bucket.
   In this case, you have loaded all child references (as
   in the standard folder case). In addition, you have
   loaded the complete access structure.

  To summarize: an isolated access to a child of a large BTreeFolder
  is usually much more efficient than an isolated access to a standard
  folder with the same children. However, the advantage of the
  BTreeFolder decreases when lots of children are accessed.

...because they're cached in the normal folder.

So, to rewrite my benchmark I'd have to flush the cache between each fetch?
I don't mind because the app itself has little traffic but individual
pages are slow.



  --

 Dieter



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] For the record

2008-03-18 Thread Peter Bengtsson
I wanted to see how much faster brain.getObject() would be if the
returned object was located in a BTreeFolder versus a normal folder so
I wrote a benchmark that created about 10,000 light simple objects in
two distinctly different containers and each with a ZCatalog that has
a PathIndex.

I would expect the BTreeFolder parenting calls of brain.getObject() to
be much faster but I found that there was NO DIFFERENCE. wtf?!

The benchmark is too messy to share right now but how come this could
have happened? getObject() basically does a
parent.restrictedTraverse(path_splitted[-1]) which should be some sort
of getattr() on the container right?

Is there something obvious I've missed?

-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] python script returning a 'rendered' zpt

2008-03-06 Thread Peter Bengtsson
rendered_html = context.some_page_template(context, somevariable='foobar')
But then you need to write the page template as:
div tal:contents=options/somevariable blah /div

On 07/03/2008, David Bear [EMAIL PROTECTED] wrote:
 I need to right a script that will return a zpt. However, I need the script to
  feed the zpt some values and then have zope returned the rendered zpt.

  I hope this is possible.

  For example, lets say I have something like this in a zpt

  div tal:contents=somevariable blah /div

  My python script with have something like this:

  somevariable = this is a test

  How can I get the script to returned the 'rendered' zpt?

  --

  David Bear
  College of Public Programs/ASU
  411 N Central, Phoenix, AZ 85004
  ___
  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 )



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Acquisition / proxying object

2008-02-26 Thread Peter Bengtsson
This is maybe a naive suggestion but if Zope's TTW execution (e.g. 
Python Scripts) can't find a __roles__ on the object at hand doesn't 
that just mean that the class wasn't initialized with any security.



class LDAPProxy(Folder):
...

from Globals import InitializeClass
InitializeClass(LDAPProxy)

That should set the *__roles__ on all it's methods.


Joerg Baach wrote:

Hi *,

I am trying to have a folderish object that acquires from a user object
(ldapuserfolder). It should have its own properties and contents, but
fall back to the ones of the ldap user.

I have created an object, extending Folder, and it behaves nicely in
zopectl debug. When I try to access it through e.g. a python script  I
get an:

Error Type: Unauthorized
Error Value: Unable to find __roles__ in the container and the container
is not wrapped. Access to 'dn' of test, acquired through (LDAPProxy at
/testfolder/ldapproxy), denied.

I am sure its my lack of understanding of acquisition. I am trying to
bascially put ldap user object 'on top' of the aquisition line (with the
ldapproxy at the bottom), but obviously failing in doing so. Any ideas?

Cheers,

  Joerg



8 excerpt from code ---

class LDAPProxy(Folder):

meta_type='LDAPProxy'

def __init__(self, id, remoteid,title='',REQUEST=None):
self.id = id
self.title = title
self.remoteid = remoteid

def __of__(self, parent):
if not hasattr(parent,'aq_base'):
return self
folder,id = self.remoteid.split(':')
acl = parent.restrictedTraverse(folder)
remote = acl.getUser(id)
return Folder.__of__(self,parent.__of__(remote))

--- teststructure--

/testfolder/
   ldapproxy (LDAPProxy)
   acl_users/
   testscript (.py)


8 testscript -
return context.ldapproxy.dn

traceback--
Traceback (most recent call last):
  File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/Publish.py,
line 113, in publish
request, bind=1)
  File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/mapply.py,
line 88, in mapply
if debug is not None: return debug(object,args,context)
  File /home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/Publish.py,
line 40, in call_object
result=apply(object,args) # Type scr to step into published object.
  File
/home/joerg/zope/Zope-2.8.5/lib/python/Shared/DC/Scripts/Bindings.py,
line 311, in __call__
return self._bindAndExec(args, kw, None)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/Shared/DC/Scripts/Bindings.py,
line 348, in _bindAndExec
return self._exec(bound_data, args, kw)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/Products/PythonScripts/PythonScript.py,
line 323, in _exec
result = f(*args, **kw)
  File Script (Python), line 1, in testscript
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 727, in guarded_getattr
aq_acquire(inst, name, aq_validate, validate)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 669, in aq_validate
return validate(inst, object, name, v)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 563, in validate
self._context)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 293, in validate
accessed, container, name, value, context)
  File
/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py,
line 808, in raiseVerbose
raise Unauthorized(text)
Unauthorized: Unable to find __roles__ in the container and the
container is not wrapped.  Access to 'dn' of test, acquired through
(LDAPProxy at /testfolder/ldapproxy), denied.





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


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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 and postgresql

2008-02-22 Thread Peter Bengtsson
I remember that there was a bug in the ZpsycopgDA that comes with
version 2 of psycopg that no one has bothered to fix. It was something
like when you add a connection object in Zope it doesn't allow you to
set the encoding for Unicode or something crazy like that.

It was discussed on the IRC and some poor guy who was trying to
install it had to manually change the code of that product.

Here we use the pyscopg version 1 and it works brilliantly.

On 22/02/2008, madhangc [EMAIL PROTECTED] wrote:

  Dear all,

  I'm new to zope. I have planned to use zope with postgresql in a windows
  environment. I have installed zope 2.x, python 2.4, mxtools, psycopg2.0. I
  have no idea to proceed from here. I have ZpsycopgDA downloaded, but i don't
  no how to install it and use it in zope. It is very urgent that i have to
  finish a project. Can some one give some idea on how to connect zope and
  postgresql. I prefer a good tutorial which teaches how to use zope with
  pgsql.

  Thanks in advance.

  \madhan
  --
  View this message in context: 
 http://www.nabble.com/zope-and-postgresql-tp15631023p15631023.html
  Sent from the Zope - General mailing list archive at Nabble.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 )



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Execute a PageTemplate in another context

2008-02-04 Thread Peter Bengtsson



Andrew Milton wrote:

+---[ Peter Bengtsson ]--
| Is it possible to execute a PageTemplate as if it was located somewhere 
| else?

| The PageTemplate has this code::
| htmlbr tal:replace=here/absolute_url_path//html
| 
| And it's located in a folder called /foo/bar/ which are normal Zope 
| Folder objects.
| I'm executing this template object from Python code (not from URL 
| travsersal) and the rendered result is:

| html/foo/bar/html
| 
| But what if I want to execute it as if it existed in another context, 
| e.g. /barfoo

| Is that possible?
| 
| I can imagine a some convoluted solutions but was hoping for something 
| easy and obvious that I've missed.


context.foo.bar.barfoo.template_id(...) ?

It's not done like that. I receive it the PageTemplate object as is 
already. I tried this::


 return apply(template_obj, (self.some.other.context, self.REQUEST), kw)

But that didn't work.


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Installing TextIndexNG3 in ZopeTestCase (long story short)

2008-02-04 Thread Peter Bengtsson
I've had a morning of annoyed frustration on trying to get TextIndexNG3 
to install properly in ZopeTestCase.

The problem I described in
http://www.nabble.com/ZopeTestCase.installProduct%28%27TextIndexNG3%27%29-trouble-to12403238.html#a12403356
mysteriously went away some time ago without any reasonable explaination.
Now I've created a new product which relies on the old troublemaker and 
it starts like this:


ZopeTestCase.installProduct('ZPsycopgDA')
ZopeTestCase.installProduct('PlacelessTranslationService')
ZopeTestCase.installProduct('ZCatalog')
ZopeTestCase.installProduct('ZCTextIndex')
ZopeTestCase.installProduct('Five')
ZopeTestCase.installProduct('TextIndexNG3')
ZopeTestCase.installProduct('Mest2')
ZopeTestCase.installProduct('Design2Mest')
ZopeTestCase.installProduct('MailHost')
ZopeTestCase.installProduct('Photo')

This works when running the tests of Mest2/tests!
Mest2 depends on Photo but the ZopeTestCase is clever enough to solve 
that dependency challange and TextIndexNG3 depends on Five but it works 
that out too.



Now in Design2Mest/test I copied the above lines and wrote a few basic 
tests and now it no longer works!!! TextIndexNG3 complains (again) about 
some parsers not being available. What happened was kind of that none of 
the zcml files of TextIndexNG3 were read or parsed at all.

The solution to the problem was to rearrange the order of...:
ZopeTestCase.installProduct('Five')
ZopeTestCase.installProduct('TextIndexNG3')
...to this...:
ZopeTestCase.installProduct('TextIndexNG3')
ZopeTestCase.installProduct('Five')
...and then it worked.


Lessons learnt:

 * Five and TextIndexNG3's importing order is very sensitive  in
   ZopeTestCase

 * Sometimes the order matters sometimes it doesn't

 * TextIndexNG3 is a brilliant product with excellent features but a
   large heap of external connections that are hard to debug

 * Five  ZCML is very hard to debug since there's bucket loads full of
   magic or whatever you want to call it that makes it damn hard
   to put in conventional print and raise statements to look through
   tracebacks.

 * Don't give up


PS. I've never touched or written an ZCML files in this environment.


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Execute a PageTemplate in another context

2008-02-04 Thread Peter Bengtsson
Is it possible to execute a PageTemplate as if it was located somewhere 
else?

The PageTemplate has this code::
htmlbr tal:replace=here/absolute_url_path//html

And it's located in a folder called /foo/bar/ which are normal Zope 
Folder objects.
I'm executing this template object from Python code (not from URL 
travsersal) and the rendered result is:

html/foo/bar/html

But what if I want to execute it as if it existed in another context, 
e.g. /barfoo

Is that possible?

I can imagine a some convoluted solutions but was hoping for something 
easy and obvious that I've missed.


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] [OT] -C

2008-01-31 Thread Peter Bengtsson



Chris McDonough wrote:
 Ricardo Newbery wrote:

 On Jan 30, 2008, at 12:59 PM, Tres Seaver wrote:

[snip]


 - C


A HA!! That's where that notorious `-C` comes from that we all see in 
the str(REQUEST) on the REQUEST.form part! It's Chris secretly 
influencing our apache rewrite rules somehow.


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


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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 2.9.6 stops servicing requests

2008-01-28 Thread Peter Bengtsson
Look for the DeadlockDebugger and install that and follow the 
instructions. Hopefully it can help you debug what Zope is doing when 
it's not responding but still ticking.
Perhaps you've got some dead connections to the database that refuse to 
timeout.


Chris Hoy wrote:

Hi

Several weeks ago I moved one of my machine to a new server and upgraded
zope from 2.7 to 2.9 as well as the database from mysql 4.1 to 5.0.38.
All seems to be going well expect that on a couple of occasions the zope
server has stop repsonding to request. The server is takeing 0% cpu and the
only way to get it going again is to re-start zope.
I can't see anything in the event.log file or on the machine (the debug info
is below)

Can anybody point me in the right direction to try and find out what is
happening 


# Zope version: (Zope 2.9.6-final, python 2.4.4, linux2)
# Python version: 2.4.4 (#2, Apr 12 2007, 21:22:23) [GCC 4.1.2 (Ubuntu
4.1.2-0ubuntu4)]
# System Platform: linux2
# SOFTWARE_HOME: /usr/lib/zope2.9/lib/python
# INSTANCE_HOME: /home/zope/instance
# CLIENT_HOME: /home/zope/instance/var
# Process ID: 31605 (1140881728)
# Running for: 13 min 15 sec
# sys.path:
  /home/zope/instance/Products/Hnd
  /home/zope/instance/lib/python
  /home/zope/instance/lib/python
  /usr/lib/zope2.9/lib/python/Zope2/Startup
  /usr/lib/python2.4/site-packages/setuptools-0.6c6-py2.4.egg
  /usr/lib/python2.4/site-packages/simplejson-1.7.1-py2.4.egg
  /usr/lib/zope2.9/lib/python
  /home/zope/instance
  /usr/lib/python24.zip
  /usr/lib/python2.4
  /usr/lib/python2.4/plat-linux2
  /usr/lib/python2.4/lib-tk
  /usr/lib/python2.4/lib-dynload
  /usr/local/lib/python2.4/site-packages
  /usr/lib/python2.4/site-packages
  /usr/lib/python2.4/site-packages/PIL 



Chris



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



--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Counting threads

2008-01-23 Thread Peter Bengtsson




GDB can help you determine where the hanging condition originates. 
Here's some links:


http://plone.org/documentation/how-to/use-gdb-to-get-backtraces-of-hung-spinning-sites 



http://zopelabs.com/cookbook/1073504990

This is great! I haven't used it yet but it definitely appears to me the 
right tool for me.



--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Counting threads

2008-01-22 Thread Peter Bengtsson
Perhaps I'm wrong but I suspect that a Zope I'm running is dying because 
of running out of threads. They probably die when being designated to 
open an external relational database connection or something dodgy.


What are my options for monitoring and debugging what zope's threads are 
doing?
Is there a simple tool to just get a simple readout of how many threads 
are busy?


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Counting threads

2008-01-22 Thread Peter Bengtsson
On 22/01/2008, Dieter Maurer [EMAIL PROTECTED] wrote:
 Peter Bengtsson wrote at 2008-1-22 15:23 +:
 Perhaps I'm wrong but I suspect that a Zope I'm running is dying because
 of running out of threads.

 This is very unlikely. It may no longer respond when all its threads
 are working -- but it will not die for this reason.

By dying I don't mean crashing and stopping but instead staying up and
running but not responding to anything. Like a coma.

 Zope uses a worker thread pool (of size 4, by default),
 allocated quite early.
 It does not create further threads. It is therefore very unlikely
 that it hits a thread limit.

I'm just not certain if it's this. It seems highly related to MS SQL
connections but I could be wrong. The strange thing is, restarting the
MS SQL server might be (we're not certain) a solution to get Zope
responding again.

My theory was that the threads get too attached to a network service
that doesn't time out or raise an error.

Sadly I can't reproduce it but the next time it happens I'll look at
both DeadlockDebugger and the Control_Panel Debug info if there are
any clues there.


-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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 ZMI Templates

2008-01-15 Thread Peter Bengtsson
I would strongly advice against building on top of the ZMI. It's dated 
and as you say, in DTML. It's also too geeky to be acceptable by any 
client of mine.
Personally I'd build something standalone that you have ultimate control 
over. You can still use things like manage_renameObjects() in your own 
mnagement interface; which you'd be able to replace once you move to zope 3.


Jurian Botha wrote:

I'm currently developing some customized ZMI pages and I was hoping someone
could give me some insight into what the best way would be to do this.

I see that Zope 2 uses dtml methods to build the standard ZMI pages but as
far as I know (Zope 3 wise) I should rather be using Zope Page Templates to
build the pages.

I would also like the product to gracefully move on to Zope 3 in future, so
that should be taken into consideration as well.

Are there perhaps some existsing templates for ZMI that can also be used
with Zope 3?


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] can't pickle instancemethod objects in testcase

2008-01-13 Thread Peter Bengtsson
Thanks Andreas and Dieter,

The explanation was quite simple, I set an attribute on an object that
was a method like this::

class TestBase(ZopeTestCase.ZopeTestCase):

def dummy_redirect(self, *a, **kw):
self.has_redirected = a[0]
if kw:
print *** Redirecting to %r + (%s) % (a[0], kw)
else:
print *** Redirecting to %r % a[0]

def afterSetUp(self):
self._setupDBConnection()
dispatcher = self.folder.manage_addProduct['MExpenses']
dispatcher.manage_addHomepage('mexpenses')
self.mexpenses = self.folder['mexpenses']
self.mexpenses.http_redirect = self.dummy_redirect # NOTICE!!

request = self.app.REQUEST
sdm = self.app.session_data_manager
request.set('SESSION', sdm.getSessionData())

self.has_redirected = False


The reason for the dummy redirector is boring. The reason for the
transaction.get().commit() is to not cancel everything when a
ConflicrError happens during a very long-lasting file upload.

Again, thanks.

PS. Andreas, I did use your set_trace() tip on the ZODB code. Isn't
Python great!

On 08/01/2008, Dieter Maurer [EMAIL PROTECTED] wrote:
 Peter Bengtsson wrote at 2008-1-7 18:29 +:
 My code works fine in normal running zope but not when run as a testcase
 (I'm not using bin/zopectl test if that matters) I get the following error.
 I feel guilty since I've got this line in my code:
 transaction.get().commit()  (Expense.py#4458)
 
 I remember having come across this error before but can't remember what
 the solution was.
  ...
File /home/peterbe/zope/zope285/lib/python/ZODB/serialize.py, line
 339, in _dump
  self._p.dump(state)
File copy_reg.py, line 69, in _reduce_ex
  raise TypeError, can't pickle %s objects % base.__name__
 TypeError: can't pickle instancemethod objects
 
 --

 Apparently, you have an instancemethod in your test setup
 where you do not have one in the normal Zope.

 An alternative explanation could be that in your normal
 Zope additional pickle registrations are performed.
 If you would use, e.g., my CompiledExecutable product,
 then the import of this product would register code and instancemethod
 instances as picklable. A test setup may not import CompiledExecutables
 and its pickle registrations would be missing.


 A side note: Usually, it is a very bad idea to perform a full
 commit in a test. Such commits are incompatible with
 techniques that share (for efficiency reasons) part of the
 test setup among several tests. ZopeTestCase, e.g., makes
 use of such techniques.



 --
 Dieter



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] can't pickle instancemethod objects in testcase

2008-01-07 Thread Peter Bengtsson
My code works fine in normal running zope but not when run as a testcase 
(I'm not using bin/zopectl test if that matters) I get the following error.

I feel guilty since I've got this line in my code:
transaction.get().commit()  (Expense.py#4458)

I remember having come across this error before but can't remember what 
the solution was.


--
Traceback (most recent call last):
  File 
/home/peterbe/zope/zope285/lib/python/Testing/ZopeTestCase/profiler.py, 
line 98, in __call__

testMethod()
  File testExpenses2.py, line 81, in test_uploadPhotos
eids = context.uploadExpenseFiles(files)
  File /home/peterbe/zope/zope285/Products/MExpenses/Expense.py, line 
4458, in uploadExpenseFiles

transaction.get().commit()
  File lib/python/transaction/_transaction.py, line 381, in commit
  File lib/python/transaction/_transaction.py, line 379, in commit
  File lib/python/transaction/_transaction.py, line 424, in 
_commitResources
  File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 
462, in commit

self._commit(transaction)
  File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 
503, in _commit

self._store_objects(ObjectWriter(obj), transaction)
  File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line 
525, in _store_objects

p = writer.serialize(obj)  # This calls __getstate__ of obj
  File /home/peterbe/zope/zope285/lib/python/ZODB/serialize.py, line 
330, in serialize

return self._dump(meta, obj.__getstate__())
  File /home/peterbe/zope/zope285/lib/python/ZODB/serialize.py, line 
339, in _dump

self._p.dump(state)
  File copy_reg.py, line 69, in _reduce_ex
raise TypeError, can't pickle %s objects % base.__name__
TypeError: can't pickle instancemethod objects

--



--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] can't pickle instancemethod objects in testcase

2008-01-07 Thread Peter Bengtsson



Andreas Jung wrote:



--On 7. Januar 2008 18:29:50 + Peter Bengtsson [EMAIL PROTECTED] 
wrote:



My code works fine in normal running zope but not when run as a testcase
(I'm not using bin/zopectl test if that matters) I get the following
error.
I feel guilty since I've got this line in my code:
transaction.get().commit()  (Expense.py#4458)

I remember having come across this error before but can't remember what
the solution was.

--
Traceback (most recent call last):
   File
/home/peterbe/zope/zope285/lib/python/Testing/ZopeTestCase/profiler.py,
line 98, in __call__
 testMethod()
   File testExpenses2.py, line 81, in test_uploadPhotos
 eids = context.uploadExpenseFiles(files)
   File /home/peterbe/zope/zope285/Products/MExpenses/Expense.py, line
4458, in uploadExpenseFiles
 transaction.get().commit()
   File lib/python/transaction/_transaction.py, line 381, in commit
   File lib/python/transaction/_transaction.py, line 379, in commit
   File lib/python/transaction/_transaction.py, line 424, in
_commitResources
   File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line
462, in commit
 self._commit(transaction)
   File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line
503, in _commit
 self._store_objects(ObjectWriter(obj), transaction)
   File /home/peterbe/zope/zope285/lib/python/ZODB/Connection.py, line
525, in _store_objects
 p = writer.serialize(obj)  # This calls __getstate__ of obj
   File /home/peterbe/zope/zope285/lib/python/ZODB/serialize.py, line
330, in serialize
 return self._dump(meta, obj.__getstate__())
   File /home/peterbe/zope/zope285/lib/python/ZODB/serialize.py, line
339, in _dump
 self._p.dump(state)
   File copy_reg.py, line 69, in _reduce_ex
 raise TypeError, can't pickle %s objects % base.__name__
TypeError: can't pickle instancemethod objects


Well, this error is self-speaking :-)

The standard solution for figuring out the related property/attr keeping 
the instancemethod is: pdb. Look at the object or its __dict__ and check 
what is
inside or think about your code where you might be assigning a method 
somewhere.


Damn it! Not the answer I was hoping for. I was hoping for something 
simpler and more obvious :)


What object do you suggest I inspect in the debugger then? I don't know 
how the ZODB figures out what it needs to save.


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Using zoperoot.misc_.MyProduct

2007-12-14 Thread Peter Bengtsson
As far as I can see, an advantage with attaching static stuff to
OFS.misc_.MyInstalledProduct is that it becomes available globally
which makes sense to avoid loading a different icon URL for each www
icon in the ZMI of a product. Makes sense also for example if you have
one Zope with 10 different instances because then there's just one on
/misc_/MyProduct/screen.css to cache and download for the browser if
you've placed a static file there called that.

A drawback seems to be that errors happening in
/misc_/MyProduct/static-content isn't reported in the error_log. This
makes it hard to spot bugs in objects in there and, more commonly,
NotFound errors.

Is there anything I can do about that or should I not expect so much
and instead use the instance?

-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] why zope is rendering apostrophe as a small square box

2007-10-16 Thread Peter Bengtsson
The apostrophe was entered with a different encoding from what you're 
using to show it.
My guess is that you copy and paste a LATIN1 string, entered it into a 
form that doesn't transform and then you're trying to show it with 
Content-Type UTF8.


Getting encodings right has never been easy.
...unless you keep it simple and consistent.
...everywhere.

kamal hamzat wrote:

Hi,
 
Please what can I do to stop zope showing apostrophe in my content as a 
small square box.
 
I am running Zope 2.10.4, python 2.4.4 on a windows server.
 
Thanks.

Kamal.




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


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] How can I get graph statistics

2007-10-11 Thread Peter Bengtsson

An example of this in action is:
http://real.issuetrackerproduct.com/MoreStatistics


Kees de Brabander wrote:
I am very pleased with chartdirector (www.advsofteng.com 
http://www.advsofteng.com). Not free, but relatively cheap and good 
support.

cb


*Van:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] *Namens 
*Jonathan Salazar Santos

*Verzonden:* donderdag 11 oktober 2007 6:33
*Aan:* zope@zope.org
*Onderwerp:* [Zope] How can I get graph statistics

I am wondering if..., ¿Could some body tell me (help me) how to do graph 
statistics on the fly with DTML or python?


I need to create reports with statistics on the fly.

Some howto... I will apreciate, thanks in advance.

--
Jonathan Salazar

 





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


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Weird hangs on zope/plone.

2007-10-09 Thread Peter Bengtsson

Are you using any SQL connections or anything like that inside the Zope?

Samuel Abreu de Paula wrote:

Hi, i recently installed a plone site, but its acting weird!

All start 2 weeks ago when i set this new site in production, on
wednesday, and in thursday at beggining of the morning the instance
just stop response.

I restart the service, reboot the system and nothing bring back the
instance, but suddenly back to normal. This happen on friday too, i
find something about the livesearch_reply (some stuff from plone) that
maybe its the cause of the problem, i fix it and the problem dont
ocurr on weekend, but the same thing happened on monday, tuesday and
wednesday again!

I set the number of threads:
zserver-threads 25
I set:
pool-size 27
on zodb_db main


and the problem was gone from last wednesday untill today, this
morning the problem back, i search my entire logs for something that
could help but i cant find nothing...

The weirdest thing is yesterday i setup a second machine, with
identical OS and zope/python version, and run the same site, for
change machine purpose, but this morning both of machine was lock, i
cant access zope in any of them. I look for any kind of cron job or
something like that on operating system (RHEL 5) and didn't find
nothing.

Anyone have any idea where is the problem? Theres something like cron
jobs inside zope/plone itself?

How can i run some kind of debug on zope (debug-mode on dont log
anything more) to check this next time happen?

Thanks for the attention.


Some info:

OS: RHEL 5
Plone 2.5.1

# Zope version: (Zope 2.9.8-final, python 2.4.3, linux2)
# Python version: 2.4.3 (#1, Dec 11 2006, 11:38:52) [GCC 4.1.1
20061130 (Red Hat 4.1.1-43)]
# System Platform: linux2
# SOFTWARE_HOME: /opt/zope/zope-2.9.8/lib/python
# INSTANCE_HOME: /opt/zope/portal
# CLIENT_HOME: /opt/zope/portal/var
# Process ID: 3570 (-1223578736)
# Running for: 44 min 36 sec
# sys.path:
  /opt/zope/portal/lib/python
  /opt/zope/portal/lib/python
  /opt/zope/zope-2.9.8/lib/python/Zope2/Startup
  /opt/zope/portal/Products/ATContentTypes/thirdparty
  /opt/zope/zope-2.9.8/lib/python
  /opt/zope/portal/bin
  /usr/lib/python24.zip
  /usr/lib/python2.4
  /usr/lib/python2.4/plat-linux2
  /usr/lib/python2.4/lib-tk
  /usr/lib/python2.4/lib-dynload
  /usr/lib/python2.4/site-packages
  /usr/lib/python2.4/site-packages/Numeric
  /usr/lib/python2.4/site-packages/PIL
  /usr/lib/python2.4/site-packages/gtk-2.0
  /opt/zope/portal/Products/TextIndexNG2
___
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 )



--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Re: How to know what are zope doing now?

2007-09-23 Thread Peter Bengtsson
I've seen that too in some Zope's. ZopeProfiler installed by nothing
in the Control_Panel.
What I had to do was to manually guess the URL by typing in
http://localhost:8080/Control_Panel/ZopeProfiler/manage_main and it was there.

On 9/23/07, Dieter Maurer [EMAIL PROTECTED] wrote:
 Garito wrote at 2007-9-21 19:57 +0200:
 I supposed that but any ZopeProfiler objects appears on my Control_Panel
 
 Any suggestion?

 As always: Look into the logfile to see whether there are any
 problems reported during startup.

 If no problems are reported, check that ZopeProfiler
 is properly installed on the file systems. It should live
 in the Products directory of your Zope instance.



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



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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] Limit Zope only from Pound

2007-09-10 Thread Peter Bengtsson

Andreas advice about using a firewall is probably the right advice.
Basically, since it's an internal IP it's not accessible from the 
outside. What you do is that you only expose the Pound server to the 
internet and then no one will ever be able to reach the zope directly 
unless they're inside the network which is only going to be your 
colleagues anyway.


Juan Javier Carrera Obrero wrote:
Hello, I have installed pound and zope in different machines. Pound is a 
IP: 192.168.1.1 and Zope is in IP: 192.168.1.5:8080. Pound  balances to 
Zope, correctly.


Although, I want than Zope does not visible from external, that is to 
say, Zope is only accessible from Pound (and not with 
http://192.168.1.5:8080 manually) . I have tried con ip-address, but 
it does not run.


Anybody do knows how do it ?

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 )



--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.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 )


  1   2   3   4   5   >