[Zope-dev] testing, DemoStorage and Zope2.app()
Hi All, I've been having fun with unit tests: http://mail.zope.org/pipermail/zope3-dev/2006-October/020757.html http://mail.zope.org/pipermail/zope3-dev/2006-October/020775.html But Jim finally pointed me in the right direction: http://mail.zope.org/pipermail/zope3-dev/2006-October/020789.html So, stacking DemoStorages sounds like exactly what I want to do, with one DemoStorage for each test layer. A couple of questions: 1. Should I do a transaction.commit() after each layer's setup, or will a DemoStorage stacked onto another DemoStorage as follows: storage = DemoStorage(base=base_storage) ...still see all changes made to the base even if they're not committed? 2. How do I go about weaving the storage into the Zope2.app() stuff? In particular: - in a layer's setUp() method, how do I replace the DB used by the current Zope2.app() with the same storage but wrapped in a new DemoStorage? - in a layer's tearDown() method, how do I toss the DemoStorage created in the layer's setUp and replace it with the original one? 3. Is storage = DemoStorage(base=base_storage) and the dance needed for question 2 going to be quicker that transaction.commit() at the end of the layer setup and transaction.abort() at the end of every unit test? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Zope 2.10.0 installer for Windows
This Monday, I've built an installer for Windows, based on the Zope-2.10.0-final release which has been published on zope.org two weeks ago. Today, I've got some time to run tests: Tests with failures: c:\build\2\Zope-2.10.0-final\inst\build\lib\python\zope\formlib\form.txt Total: 8304 tests, 1 failures, 4 errors (more info on request). Alas, that release seems to be unusable for my purposes, for various reasons. So I'll have to stay with 2.9.4 or older, for the forseeable future. Somehow, I wonder whether current Zope2 releases get any real world testing before becoming stable. Did perhaps all testing happen on the Windows side, in the past? ;-) Anyway, anybody interested in getting hold of an almost unused Zope-2.10.0-final-win32.exe? -- // EXEC PGM=IEFBR14 // DD DSN=Zope-2.10.0-final-win32.exe,DISP=(OLD,DELETE) ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope] Tab completion in zopectl debug
Am Mittwoch, 18. Oktober 2006 01:43 schrieb Maurits van Rees: Hi, I have recently learned how to add tab completion to an interactive python session and to pdb, thanks to Tom Lazar and to Jacob at ParTecs. More info with links on my first blog entry in three months: http://maurits.vanrees.org/weblog/2006/10/tab-completion.html just a thought: you might also use ipython, which has tab-completion by default: http://ipython.scipy.org/moin/About Cheers, Sascha -- Lalisio GmbH www.lalisio.com Puschkinstraße 1 fon +49-(0)361/541 43 80 99084 Erfurt fax +49-(0)361/541 43 79 [EMAIL PROTECTED] + AKTUELLER HINWEIS (Oktober 2006) Wussten Sie schon, dass Lalisio ab sofort den Dokumentenlieferdienst CISTI in seine Literatursuchmaschine einbindet? Sobald Sie über unsere Literatursuchmaschine in den Datenbanken Ingenta oder Projekt MUSE relevante Artikel finden, können Sie die bibliographischen Daten per Mausklick an CISTI übermitteln und Kopien der Artikel bestellen. Testen Sie unser Angebot unter www.lalisio.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] Tab completion in zopectl debug
Maurits van Rees wrote: Hi, I have recently learned how to add tab completion to an interactive python session and to pdb, thanks to Tom Lazar and to Jacob at ParTecs. More info with links on my first blog entry in three months: http://maurits.vanrees.org/weblog/2006/10/tab-completion.html At the end of that entry I ask a question: Can we add tab completion to the zopectl debugger? Or actually more general: can we load the ~/.pythonrc.py file when the zopectl debugger is started? In that file, the user can arrange tab completion or anything else he wants to have available for interactive python sessions. It is very easy to do: just add 'import user;' to the command line in the do_debug function of $SOFTWARE_HOME/Zope2/Startup/zopectl.py. For details, see that blog entry. Looks good, is there any way this can be done by putting more code in do_debug and not usering .pythonrc.py? In any case, this would be cool, please add a feature request + patch in the collector: http://www.zope.org/Collectors/Zope cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Upgrading Zope
Hi All, I've been asked to migrate an ancient Zope server from 2.1.x to the latest 2.x or 3.x version. This server only have a couple of applications, both using Z SQL Methods, DHTML methods and documents, some products and some external methods. They don't use ZPT or Script (python) at all. I'd like to know if you think that such migration is feasible or if I'll encounter some problems. Do you think it is better to migrate to the latest version of the 2.x or 3.x branch? If you have any link on this subject is really appreciated. Bye, Andrew. ___ 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 Zope
--On 18. Oktober 2006 14:55:33 +0200 Nightflyer [EMAIL PROTECTED] wrote: Hi All, I've been asked to migrate an ancient Zope server from 2.1.x to the latest 2.x or 3.x version. This server only have a couple of applications, both using Z SQL Methods, DHTML methods and documents, some products and some external methods. They don't use ZPT or Script (python) at all. Nobody will promise you that a migration to the latest 2.X version will work. You install a new Zope instance and figure it out own our own. If there are problems, come back. Nobody knows what your application is doing so is bascially a trial-and-error game. Using only DTML and ZSQL methods...does not sound so impossible for a migration...just try it. I'd like to know if you think that such migration is feasible or if I'll encounter some problems. Do you think it is better to migrate to the latest version of the 2.x or 3.x branch? Zope 2 and Zope 3 are totally incompatible. Stick with the latest 2.X version unless you really want to migrate your code *manually* to the complete new architecture of Zope 3 (Z3 has no ZSQL methods - it has something similar but nothing that is compatible). -aj pgpTOPKhl9xo6.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Upgrading Zope
On Wed, Oct 18, 2006 at 02:55:33PM +0200, Nightflyer wrote: Hi All, I've been asked to migrate an ancient Zope server from 2.1.x to the latest 2.x or 3.x version. http://zopewiki.org/Upgrading -- Paul Winkler http://www.slinkp.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Upgrading Zope
Hi, Nightflyer wrote: I'd like to know if you think that such migration is feasible or if I'll encounter some problems. Do you think it is better to migrate to the latest version of the 2.x or 3.x branch? From 2.1.x to the latest 2.x should be feasible. Zope 3.x is a rewrite with no upgrade path, so that's not an option. The best route is probably to try it on a development server and report back with any issues. Which RDBMS are you using your ZSQL Methods against? -- Regards, PhilK Say what you mean. Bear witness. Iterate. —John M. Ford ___ 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 )
R: [Zope] Upgrading Zope
Which RDBMS are you using your ZSQL Methods against? MySQL 4.1. Bye, Andrew. ___ 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] Zeo Client hanging
On Wed, Oct 18, 2006 at 07:32:38AM +0200, Maciej Wisniowski wrote: zope 2.8.5 + zeo python 2.3.4 (red hat distribution) Red Hat RHEL 4 Plone 2.1.2 Our zeo clients hang intermittently. We have no way of reproducing the problem, but it occurs daily. The client hangs and a restart seems to fix the problem. Install DeadlockDebugger and you'll be able to see what is the state of your threads when Zope becomes unresponsive. In the event log with tracing on we get Trace zeo.zrpc.Connection(C) wait(16697) {server:8100} pending, async=0 There are hundreds to thousands of these until the server is restarted. In the zeo log we get Error caught in asyncore asyncore.py error:(110,'Connection timed out') I'm not sure what these errors are. Maybe firewall between zeo server and zeo client closes the connections or something like that? That was my guess too. See this thread: http://aspn.activestate.com/ASPN/Mail/Message/zope-list/2916870 -- Paul Winkler http://www.slinkp.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: R: [Zope] Upgrading Zope
Hi Andrew, Nightflyer wrote: Which RDBMS are you using your ZSQL Methods against? MySQL 4.1. From what you tell us, the database adapter is the only 3rd-party dependency, and (although I don't use it myself) I understand mySQL is well-supported, so you really need to try the upgrade on a development machine to find out. The Very Old Zope section in the link to ZopeWiki that Paul sent should get you going... -- Regards, PhilK Say what you mean. Bear witness. Iterate. —John M. Ford ___ 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 Zope
If you are using any zClass objects and have them cataloged, then you need to run a script against them to do the reindexing, as I found out that changed at 2.8. Also if you are using DTML and using any sorting within dtml-in segments, you will need to patch a file. Pages that use sorting on dtml-in throw a weird error. The patch works fine but since it sounds like no one who maintains core Zope uses DTML, that bug probably won't get really fixed. There is an outstanding ticket open on it. Those are the things I have found so far. We are on 2.7.5 and now that those issues are worked out we are working on our upgrade strategy. Allen Nightflyer wrote: Hi All, I've been asked to migrate an ancient Zope server from 2.1.x to the latest 2.x or 3.x version. This server only have a couple of applications, both using Z SQL Methods, DHTML methods and documents, some products and some external methods. They don't use ZPT or Script (python) at all. I'd like to know if you think that such migration is feasible or if I'll encounter some problems. Do you think it is better to migrate to the latest version of the 2.x or 3.x branch? If you have any link on this subject is really appreciated. Bye, Andrew. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Zeo Client hanging
I see references to asyncore.py near the end of the thread listing when using DeadLockDebugger and seeing a stuck thread process. The tread eventually clears out but sometimes an impatient user reloads, reloads, reloads...and then all 4 threads are stuck on exact same thing. Then you can see the same URL jump to the other Zope/ZEO client and same thing happens there. Another few reloads and one user has effectively crashed the siteuntil the threads clear themselves out. Usually is a catalog search for a news article or something spanning our 6 years of online news articles searching on the word 'bob' or something like that. +1 for DeadlockDebugger... love it. Allen Paul Winkler wrote: On Wed, Oct 18, 2006 at 07:32:38AM +0200, Maciej Wisniowski wrote: zope 2.8.5 + zeo python 2.3.4 (red hat distribution) Red Hat RHEL 4 Plone 2.1.2 Our zeo clients hang intermittently. We have no way of reproducing the problem, but it occurs daily. The client hangs and a restart seems to fix the problem. Install DeadlockDebugger and you'll be able to see what is the state of your threads when Zope becomes unresponsive. In the event log with tracing on we get Trace zeo.zrpc.Connection(C) wait(16697) {server:8100} pending, async=0 There are hundreds to thousands of these until the server is restarted. In the zeo log we get Error caught in asyncore asyncore.py error:(110,'Connection timed out') I'm not sure what these errors are. Maybe firewall between zeo server and zeo client closes the connections or something like that? That was my guess too. See this thread: http://aspn.activestate.com/ASPN/Mail/Message/zope-list/2916870 ___ 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] How to do...
Hi all! How can I control the way an attribute of a product is readed? __getattr__? __getattribute__? I try the __getattribute__ way but it modifies the property pages Example: I create an object instance of the product and like: Property1 = 'Some text' Property2 = 2006-10-18 I would like to call Property2 like object.Property2 and retrieve the data with the current locale For spanish locale I would like to retrieve 18-10-2006 But if I read the property pages of this object I would like to conserve the given data Is this possible? Thanks! -- Mis Cosas http://blogs.sistes.net/Garito ___ 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 do...
--On 18. Oktober 2006 16:15:37 +0200 Garito [EMAIL PROTECTED] wrote: Hi all! How can I control the way an attribute of a product is readed? __getattr__? __getattribute__? I try the __getattribute__ way but it modifies the property pages Example: I create an object instance of the product and like: Property1 = 'Some text' Property2 = 2006-10-18 I would like to call Property2 like object.Property2 and retrieve the data with the current locale Don't do that. Make a clear separation between the storage layer and any kind of presentation issues. If you need your internal data represented in a fancy way, write a dedicated accessor method and use this one inside your templates (or whatever) instead of accessing the data directly. -aj pgpT0b4D9f9Xi.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to do...
- Original Message - From: Garito [EMAIL PROTECTED] To: Lista Zope Internacional zope@zope.org Sent: Wednesday, October 18, 2006 10:15 AM Subject: [Zope] How to do... Hi all! How can I control the way an attribute of a product is readed? __getattr__? __getattribute__? I try the __getattribute__ way but it modifies the property pages Example: I create an object instance of the product and like: Property1 = 'Some text' Property2 = 2006-10-18 I would like to call Property2 like object.Property2 and retrieve the data with the current locale For spanish locale I would like to retrieve 18-10-2006 But if I read the property pages of this object I would like to conserve the given data Is this possible? Reading/displaying stored data should not change the stored data! You should determine what internal data storage format you want and keep it consistent. When you retrieve data for presentation/display you can reformat the data prior to display (eg. for localization), but you should not overwrite the stored data with the new format (this will cause you serious difficulties as your data 'reading' routines will never know what format the data is stored in - unless you also store some formatting information, but in most cases this is a bad idea!) Jonathan ___ 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 do...
Andreas Jung escribió: --On 18. Oktober 2006 16:15:37 +0200 Garito [EMAIL PROTECTED] wrote: Hi all! How can I control the way an attribute of a product is readed? __getattr__? __getattribute__? I try the __getattribute__ way but it modifies the property pages Example: I create an object instance of the product and like: Property1 = 'Some text' Property2 = 2006-10-18 I would like to call Property2 like object.Property2 and retrieve the data with the current locale Don't do that. Make a clear separation between the storage layer and any kind of presentation issues. If you need your internal data represented in a fancy way, write a dedicated accessor method and use this one inside your templates (or whatever) instead of accessing the data directly. -aj Then I can't create a property that stores a tal expression for example? I would like to write things like: object.property = 'here/anotherproperty' object.anotherproperty = 'Barcelona' and ask it like: print object.property - 'Barcelona' or tal:city tal:replace='here/property' / - 'Barcelona' Is this possible? Thanks!!! -- Mis Cosas http://blogs.sistes.net/Garito ___ 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 do...
--On 18. Oktober 2006 18:53:05 +0200 Garito [EMAIL PROTECTED] wrote: Andreas Jung escribió: --On 18. Oktober 2006 16:15:37 +0200 Garito [EMAIL PROTECTED] wrote: Hi all! How can I control the way an attribute of a product is readed? __getattr__? __getattribute__? I try the __getattribute__ way but it modifies the property pages Example: I create an object instance of the product and like: Property1 = 'Some text' Property2 = 2006-10-18 I would like to call Property2 like object.Property2 and retrieve the data with the current locale Don't do that. Make a clear separation between the storage layer and any kind of presentation issues. If you need your internal data represented in a fancy way, write a dedicated accessor method and use this one inside your templates (or whatever) instead of accessing the data directly. -aj Then I can't create a property that stores a tal expression for example? I would like to write things like: object.property = 'here/anotherproperty' object.anotherproperty = 'Barcelona' and ask it like: print object.property - 'Barcelona' or tal:city tal:replace='here/property' / - 'Barcelona' This posting is totally weird. Sorry, but I have really no idea what you're trying to do. It makes absolutely no sense. -aj pgpuAUwWVj1Fl.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] external method strangeness
Can anyone explain what is happening here. I am using Saxon to transform an xml file(source) using a stylesheet(style) the result is then written to Postgres. The contents of source are uploaded in Zope and passed to the external method as a string. When I run this external method: import psycopg, string, re, subprocess def scholarpack_xml_transform(source): f=open('/opt/scholarpack/ancillary/source.xml','w') f.write(source) f.close source= '/opt/scholarpack/ancillary/source.xml' style='/opt/scholarpack/ancillary/style.xml' source1=source.replace('apos;','`') source2=source1.replace('NLPGaddress','BS7666address') p=re.compile(\') source3=p.sub( '`' , source2) r = subprocess.Popen(['/opt/scholarpack/ancillary/jre/bin/java','-jar','./saxon.jar',source3,style], stdout = subprocess.PIPE,cwd = '/opt/scholarpack/ancillary/') r.wait() transformed = r.stdout.read() transformed1=transformed.replace(',)',')') conn = psycopg.connect(dbname=scholarpack user=scholarpack) curs = conn.cursor() do=curs.execute(transformed1) do conn.commit() conn.close I get a programming error thrown from the conn.commit() line and the method fails. However when I run the following script externally to Zope after the Zope failure (so that source.xml exists) the DB write is successful. #!/opt/scholarpack/python/bin/python import psycopg, string, re, subprocess source='source.xml' style='style.xml' source1=source.replace('apos;','`') source2=source1.replace('NLPGaddress','BS7666address') p=re.compile(\') source3=p.sub( '`' , source2) r = subprocess.Popen(['/opt/scholarpack/ancillary/jre/bin/java','-jar','./saxon.jar',source3,style], stdout = subprocess.PIPE,cwd = '/opt/scholarpack/ancillary/') r.wait() transformed = r.stdout.read() transformed1=transformed.replace(',)',')') conn = psycopg.connect(dbname=scholarpack user=scholarpack) curs = conn.cursor() do=curs.execute(transformed1) do conn.commit() conn.close Can 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 )
Re: [Zope] How to do...
Andreas Jung escribió: --On 18. Oktober 2006 18:53:05 +0200 Garito [EMAIL PROTECTED] wrote: Andreas Jung escribió: --On 18. Oktober 2006 16:15:37 +0200 Garito [EMAIL PROTECTED] wrote: Hi all! How can I control the way an attribute of a product is readed? __getattr__? __getattribute__? I try the __getattribute__ way but it modifies the property pages Example: I create an object instance of the product and like: Property1 = 'Some text' Property2 = 2006-10-18 I would like to call Property2 like object.Property2 and retrieve the data with the current locale Don't do that. Make a clear separation between the storage layer and any kind of presentation issues. If you need your internal data represented in a fancy way, write a dedicated accessor method and use this one inside your templates (or whatever) instead of accessing the data directly. -aj Then I can't create a property that stores a tal expression for example? I would like to write things like: object.property = 'here/anotherproperty' object.anotherproperty = 'Barcelona' and ask it like: print object.property - 'Barcelona' or tal:city tal:replace='here/property' / - 'Barcelona' This posting is totally weird. Sorry, but I have really no idea what you're trying to do. It makes absolutely no sense. -aj I only try to create a model but I'm searching the best way to create it I try to create properties like this is (in the last example): object.property is like object.anotherproperty Is this possible? -- Mis Cosas http://blogs.sistes.net/Garito ___ 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] external method strangeness
+---[ garry saddington ]-- | Can anyone explain what is happening here. I am using Saxon to transform | an xml file(source) using a stylesheet(style) the result is then written | to Postgres. The contents of source are uploaded in Zope and passed to | the external method as a string. When I run this external method: [snip] | Can anyone point me in the correct direction? Text encoding? Would probably be a lot easier if you told us the error message in full that you get. -- Andrew Milton [EMAIL PROTECTED] ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to do...
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 18 Oct 2006, at 12:53, Garito wrote: Then I can't create a property that stores a tal expression for example? I would like to write things like: object.property = 'here/anotherproperty' object.anotherproperty = 'Barcelona' and ask it like: print object.property - 'Barcelona' or tal:city tal:replace='here/property' / - 'Barcelona' Google for ComputedAttribute. jens -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (Darwin) iD8DBQFFNmNuRAx5nvEhZLIRAkRcAJ4lfb9YMZGCgMnyhwokS9b9JocsEQCdEMh1 FSIjkr9Ijvr6LpR1vIPXrHI= =ugZY -END PGP SIGNATURE- ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to do...
--On 18. Oktober 2006 19:17:42 +0200 Garito [EMAIL PROTECTED] wrote: I only try to create a model but I'm searching the best way to create it I try to create properties like this is (in the last example): object.property is like object.anotherproperty You got already multiple advices. Write a method anotherproperty() and do whatever you like with in this method. You can call it from TALES as here/anotherproperty. TALES bascially deals with attributes and methods in the same way. -aj pgpQEhmY3CKov.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to do...
Andreas Jung escribió: --On 18. Oktober 2006 19:17:42 +0200 Garito [EMAIL PROTECTED] wrote: I only try to create a model but I'm searching the best way to create it I try to create properties like this is (in the last example): object.property is like object.anotherproperty You got already multiple advices. Write a method anotherproperty() and do whatever you like with in this method. You can call it from TALES as here/anotherproperty. TALES bascially deals with attributes and methods in the same way. -aj Sure! But I need to write a method for every like property but I would like (if is possible) a way to evaluate if a property is a TALES property automatically Perhaps the property could begin like tal:expression If a property begins with tal: I would like to pre-process automatically Is this possible? -- Mis Cosas http://blogs.sistes.net/Garito ___ 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 do...
--On 18. Oktober 2006 19:41:07 +0200 Garito [EMAIL PROTECTED] wrote: You got already multiple advices. Write a method anotherproperty() and do whatever you like with in this method. You can call it from TALES as here/anotherproperty. TALES bascially deals with attributes and methods in the same way. -aj Sure! But I need to write a method for every like property but I would like (if is possible) a way to evaluate if a property is a TALES property automatically Do you *really*, *really*, *really* need this feature? You can of course implement your own __getattr__() methodbut every Python programmer would likely slap you left and right...these are the last comments on this issue.. it's still to weird in my opinion. -aj pgp2e2ObIyVAF.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Tab completion in zopectl debug
Maurits van Rees wrote at 2006-10-17 23:43 +: ... More info with links on my first blog entry in three months: http://maurits.vanrees.org/weblog/2006/10/tab-completion.html At the end of that entry I ask a question: Can we add tab completion to the zopectl debugger? Or actually more general: can we load the ~/.pythonrc.py file when the zopectl debugger is started? Nothing prevents you to call execfile at the start of your debug session. -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to do...
Andreas Jung escribió: --On 18. Oktober 2006 19:41:07 +0200 Garito [EMAIL PROTECTED] wrote: You got already multiple advices. Write a method anotherproperty() and do whatever you like with in this method. You can call it from TALES as here/anotherproperty. TALES bascially deals with attributes and methods in the same way. -aj Sure! But I need to write a method for every like property but I would like (if is possible) a way to evaluate if a property is a TALES property automatically Do you *really*, *really*, *really* need this feature? You can of course implement your own __getattr__() methodbut every Python programmer would likely slap you left and right...these are the last comments on this issue.. it's still to weird in my opinion. -aj Yes I think about __getattr__() method but I don't have any idea about how to retrive the original property And another question about this is if implementing __getattr__ method the property manager works ok or not (for me works ok if property manager displays the tal expression instead of the process of the expression will __getattr_ be the method I'm looking for? Thanks Aj and sorry for my weird questions -- Mis Cosas http://blogs.sistes.net/Garito ___ 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] external method strangeness
+---[ garry saddington ]-- | On Thu, 2006-10-19 at 03:18 +1000, Andrew Milton wrote: | +---[ garry saddington ]-- | | Can anyone explain what is happening here. I am using Saxon to transform | | an xml file(source) using a stylesheet(style) the result is then written | | to Postgres. The contents of source are uploaded in Zope and passed to | | the external method as a string. When I run this external method: | | [snip] | | | Can anyone point me in the correct direction? | | Text encoding? | The same files are used both times. The error log is not very helpful | here but I enclose it for completeness. | regards | garry I'd add some debugging into the pyana.py file, at the point where it's raising the exception. -- Andrew Milton [EMAIL PROTECTED] ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to do...
Garito wrote at 2006-10-18 16:15 +0200: ... How can I control the way an attribute of a product is readed? __getattr__? __getattribute__? A product is an extension mechanism for Zope. Usually, a product does not have attributes (you are interested in). But inside your product you may have defined classes instances of which you place into the Zope hierarchy (http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html speaks about site building objects). The standard Python way to access their attributes (__getattr__ and __getattribute__) will work but has caveats: It is *very* easy to create infinite loops with it and their self with not be acquisition wrapped. The Zope specific safer way is to implement __bobo_traverse__. Both the publisher as well as [un]restrictedTraverse (which is internally used by TALES path expressions) use __bobo_traverse__ when defined. However, Python's getattr will not use it. -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to do...
Dieter Maurer escribió: Garito wrote at 2006-10-18 16:15 +0200: ... How can I control the way an attribute of a product is readed? __getattr__? __getattribute__? A product is an extension mechanism for Zope. Usually, a product does not have attributes (you are interested in). But inside your product you may have defined classes instances of which you place into the Zope hierarchy (http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html speaks about site building objects). The standard Python way to access their attributes (__getattr__ and __getattribute__) will work but has caveats: It is *very* easy to create infinite loops with it and their self with not be acquisition wrapped. The Zope specific safer way is to implement __bobo_traverse__. Both the publisher as well as [un]restrictedTraverse (which is internally used by TALES path expressions) use __bobo_traverse__ when defined. However, Python's getattr will not use it. Hi, Dieter! How can I create an accessor to read (not to write) and preprocess all properties? Thanks! -- Mis Cosas http://blogs.sistes.net/Garito ___ 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: Tab completion in zopectl debug
Dieter Maurer, on 2006-10-18: Nothing prevents you to call execfile at the start of your debug session. Lazyness prevents me to call execfile at the start of my debug session. :) -- Maurits van Rees | http://maurits.vanrees.org/ [NL] Work | http://zestsoftware.nl/ Do not worry about your difficulties in computers, I can assure you mine are still greater. ___ 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: Tab completion in zopectl debug
Sascha Ottolski, on 2006-10-18: http://maurits.vanrees.org/weblog/2006/10/tab-completion.html just a thought: you might also use ipython, which has tab-completion by default: http://ipython.scipy.org/moin/About I saw that mentioned in one of the links on my page as well; looks promising; I'll try it out, thanks. The following also mention ipython in the light of zope: http://tomster.org/blog/archive/2006/10/09/ipython-as-zope-shell http://michaelthornhill.blogspot.com/2005/09/how-to-debug-zopeplone-with-ide.html -- Maurits van Rees | http://maurits.vanrees.org/ [NL] Work | http://zestsoftware.nl/ Do not worry about your difficulties in computers, I can assure you mine are still greater. ___ 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] external method strangeness
On Wed, Oct 18, 2006 at 06:13:38PM +0100, garry saddington wrote: Can anyone explain what is happening here. I am using Saxon to transform an xml file(source) using a stylesheet(style) the result is then written to Postgres. The contents of source are uploaded in Zope and passed to the external method as a string. When I run this external method: import psycopg, string, re, subprocess def scholarpack_xml_transform(source): f=open('/opt/scholarpack/ancillary/source.xml','w') f.write(source) I have no idea what's causing your problem, but this raises red flags for me: if two people upload sources at the same time, you'll have problems here. If you really really must read/write files on the filesystem, either use locks or use python's tempfile module. f.close source= '/opt/scholarpack/ancillary/source.xml' style='/opt/scholarpack/ancillary/style.xml' source1=source.replace('apos;','`') source2=source1.replace('NLPGaddress','BS7666address') p=re.compile(\') source3=p.sub( '`' , source2) r = subprocess.Popen(['/opt/scholarpack/ancillary/jre/bin/java','-jar','./saxon.jar',source3,style], stdout = subprocess.PIPE,cwd = '/opt/scholarpack/ancillary/') Are you just using saxon for xslt processing? If so, IMO using an external process for that is severe overkill. Get lxml and try something like this: from lxml import etree style = etree.XSLT(etree.parse(some_file_object)) transformed = style.apply(source_data) but again, this doesn't address your immediate problem :) -- Paul Winkler http://www.slinkp.com ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Re: Tab completion in zopectl debug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Maurits van Rees wrote: Hi, I have recently learned how to add tab completion to an interactive python session and to pdb, thanks to Tom Lazar and to Jacob at ParTecs. More info with links on my first blog entry in three months: http://maurits.vanrees.org/weblog/2006/10/tab-completion.html At the end of that entry I ask a question: Can we add tab completion to the zopectl debugger? Or actually more general: can we load the ~/.pythonrc.py file when the zopectl debugger is started? In that file, the user can arrange tab completion or anything else he wants to have available for interactive python sessions. It is very easy to do: just add 'import user;' to the command line in the do_debug function of $SOFTWARE_HOME/Zope2/Startup/zopectl.py. For details, see that blog entry. I don't think there are security risks (but don't take my word for it). If someone can put malicious python code in that rc file, than that someone could just as easily start a python session and enter the malicious code there. This would just be for convenience. Would this be enough of a convenience to put into the Zope source code? +1. The original version of zopectl actually supported this, along with persistent command-line history: the person who rewrote it didn't actually use it, and so left a number of those features out ('test', 'run', and 'debug' have all been added back in). Tres. - -- === Tres Seaver +1 202-558-7113 [EMAIL PROTECTED] Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFNoQS+gerLs4ltQ4RAsrFAJ0b8rJ/gNpEkobWkT99XZhErAUZmgCgzKq2 yLElkaygeEay8mf8NDi2Wxw= =U2N1 -END PGP SIGNATURE- ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] Zope and Log File Analysis
Hello, So I've been struggling for years now to try and provide thorough log analysis for my Zope based web site. The big problem I have is determining file types without having file extensions, since many objects are name with a simple id that doesn't contain a typical file extension. This makes it supremely difficult to determine viewing statistics based on content type for example ... Or determining what should be concidered a page view, and so on. The best solution I can think of is to actually come up with standard file extensions for the various content types I use ... It's slightly annoying because of the dot in the ID, but otherwise, it should work ok. Has anybody confronted this issue before? Any other alternatives I haven't concidered? Any insight would be much appreciated! Thanks, Jean-François Doyon Internet Service Development and Systems Support / Spécialiste de dèveloppements internet et soutien technique Canada Centre for Remote Sensing/Centre Canadien de télédétection Natural Resources Canada/Ressources Naturelles Canada http://atlas.gc.ca Tel./Tél.: (613) 992-4902 Fax: (613) 947-2410 ___ 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 fork in external method - mysql connection dropped
I spoke too soon. It was working, but consistent with the Curse of Fork, the mysql error eventually started showing up inconsistently. At first I thought it might be dependent on zope's debug mode, but it started showing up either way. So I did what I didn't want to do: split out the 'grandchild' code into a command-line script... with the resulting basic structure: external_method.py: #do some zope stuff here rv = os.system(shell_script.sh) if rv: #handle error here, such as command not found return RESPONSE.redirect(wait_page) shell_script.sh #do some shell stuff here python_script.py exit 0 python_script.py #all the grandchild code here My understanding of this is that (1) os.system creates a shell in a new process [without copying the parent's stack and files?], (2) the ampersand line in the shell script creates a grandchild process, and (3) the shell script exits, orphaning the python_script and allowing the grandparent to proceed. Maybe it's a little roundabout, but this seems to be cleaner and more reliable so far. Comments? -Daniel On Tue, 17 Oct 2006, Daniel Lopez wrote: You're good, my friend. I was hoping something like this existed, and so far, it seems to be working exactly as desired. One note for others: it's actually os._exit() not sys._exit() Re: the other suggestions: (1) I was already using runzope (2) subprocess module: I'm using an older version of zope and python, and can't currently risk upgrading core components. For true cleanliness, in order to avoid the use of fork(), I could try to pull out the grandchild's code into a self-standing script that could get spawned by the grandparent, but that would require a great deal of work, as the grandchild makes a few calls back into zope, along with using some information in the request, which I'd need to pass to the standalone script. I'm happy the lazier approach worked. Thanks to all... -D On Tue, 17 Oct 2006, Dieter Maurer wrote: Daniel Lopez wrote at 2006-10-16 13:31 -0700: I made one tweak to the double-fork procedure, adding a waitpid call in the grandparent process (the original zope thread) before it returns out of the external method... the code then looked something like: [...prefork code up to here...] pid1 = os.fork() if pid1 0: #grandparent waits for its child before returning os.waitpid(pid1, 0) return RESPONSE.redirect(wait_page) pid2 = os.fork() os.setsid() if pid2 0: #child quits, orphaning grandchild sys.exit(0) [...grandchild-only code after here...] The waitpid call seems to be preventing the zombies... this is good! (though if you find something bad about this approach, please do speak up) But in the process, a new bug was created, having to do with the MySQL connection. I now receive a Lost connection to MySQL server during query error in what appears to be a final db flush from the grandparent's publish function (ZPublisher.Publish, line 104). The good news is that the grandchild continues to do it's work, but the bad news is that the user receives an error page instead of the redirect to the wait_page. Maybe, the MySQL client library installed an atexit hook that closes the database connection. You may try sys._exit(0) (instead of sys.exit(0)) to finish the child. _exit is for purposes when you do not want standard exit handling (such as flushing buffers and calling atexit hooks). -- 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 )