[Zope-dev] Re: Deciphering Zope Comments
On 2008-06-04 20:28:07 +0200, Dieter Maurer [EMAIL PROTECTED] said: Shane Hathaway wrote at 2008-6-4 00:01 -0600: That led me to the zope.thread module, which is apparently deprecated already, yet zope.app.component still depends on it. Is that an hysterical accident? As I have read, thread local variables have been invented and implemented in Zope 3 land and donated to Python. Now, that it is in Python, the original Zope implementation can go away. Maybe, that is the purpose of the zope.thread module? Actually zope.thread does nothing but importhing the python implementation. The module is there for backward compatibility. -- Christian Zagrodnick · [EMAIL PROTECTED] gocept gmbh co. kg · forsterstraße 29 · 06112 halle (saale) · germany http://gocept.com · tel +49 345 1229889 4 · fax +49 345 1229889 1 Zope and Plone consulting and development ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Re: SQLAlchemy (zope.sqlalchemy) integration
Am Mittwoch, 4. Juni 2008 22:09 schrieb Laurence Rowe: Hermann Himmelbauer wrote: In my application, I then use getSASession() to retrieve my session. However, what I think is not that beautiful is the s.bind = engine part. Are there any suggestions how to improve this? You have two options If you ever need to mix objects from different `sites` into the same session, you should use an adapter on your root object like: If you don't need to mix objects from different `sites` then you can register a local utility for ISessionConfig. def scope(): return getUtility(ISessionConfig).uid, thread.get_ident() def factory(): engine = Engine(getUtility(ISessionConfig).url) return create_session( transactional=True, autoflush=True, bind=engine extension=ZopeTransactionExtension(), )) Session = scoped_session(factory, scopefunc=scope) Then you can just import Session and use: session = Session() Ok, great, thanks for help. The only thing I don't understand is what uid from the SessionConfig utility is. Below is my full database integration code which works for me, perhaps this is helpful to someone else. Btw., I'd suggest to put such code / session use cases in some Zope package, maybe into zope.sqlalchemy, or e.g. zope.sqlalchemy_utility as it's really difficult for non-insiders to set this up. - import thread from persistent import Persistent from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, create_session from zope.interface import Interface, implements, alsoProvides from zope.schema import TextLine, Bool from zope.component import getUtility, adapter from zope.sqlalchemy import ZopeTransactionExtension from zmyapp.interfaces import INewMySiteEvent from zope.i18nmessageid import MessageFactory _ = MessageFactory('xyz') class ISAEngineUtility(Interface): SQLAlchemy Engine Utility db_type = TextLine(title = _(uDatabase Type)) db_username = TextLine(title = _(uDatabase Username)) db_password = TextLine(title = _(uDatabase Password)) db_host = TextLine(title = _(uDatabase Host)) db_name = TextLine(title = _(uDatabase Name)) db_echo = Bool(title = _(uEcho Database Operations)) db_enconding = TextLine(title = _(uDatabase Encoding)) db_convert_unicode = Bool(title = _(uDatabase Unicode Conversion)) class SAEngineUtility(Persistent): implements(ISAEngineUtility) # FIXME FIXME!!! uid = 12345 def reset_engine_on_attrset(dsn_part): doc = Reset engine when setting variable (stored in %s) % dsn_part def fget(self): return getattr(self, dsn_part, None) def fset(self, value): oldvalue = getattr(self, dsn_part, None) if oldvalue != value: setattr(self, dsn_part, value) if getattr(self, 'init_done', False): self._resetEngine() return {'fget': fget, 'fset': fset, 'doc': doc} db_type = property(**reset_engine_on_attrset('_db_type')) db_username = property(**reset_engine_on_attrset('_db_username')) db_password = property(**reset_engine_on_attrset('_db_password')) db_host = property(**reset_engine_on_attrset('_db_host')) db_name = property(**reset_engine_on_attrset('_db_name')) db_echo = property(**reset_engine_on_attrset('_db_echo')) db_encoding = property(**reset_engine_on_attrset('_db_encoding')) db_convert_unicode =property( **reset_engine_on_attrset('_db_convert_unicode')) def __init__(self, db_type, db_username, db_password, db_host, db_name, db_echo = False, db_encoding = 'utf-8', db_convert_unicode = False): self.db_type = db_type self.db_username = db_username self.db_password = db_password self.db_host = db_host self.db_name = db_name self.db_echo = db_echo self.db_encoding = db_encoding self.db_convert_unicode = db_convert_unicode self.init_done = True def mkDSN(self): Create database DSN out of DSN elements userpass = '' if self.db_username: userpass += self.db_username if self.db_password: userpass += ':' + self.db_password if self.db_host == 'localhost': db_host = '' else: db_host = self.db_host if db_host and userpass: db_host = userpass + '@' + self.db_host elif not db_host and userpass: db_host = userpass + '@localhost' return '%s://%s/%s' % (self.db_type, db_host, self.db_name) def getEngine(self): engine = getattr(self, '_v_engine', None) if engine: return engine # No engine available, create a new one self._v_engine = create_engine(self.mkDSN(), echo = self.db_echo,
[Zope-dev] Zope Tests: 5 OK
Summary of messages to the zope-tests list. Period Wed Jun 4 11:00:00 2008 UTC to Thu Jun 5 11:00:00 2008 UTC. There were 5 messages: 5 from Zope Tests. Tests passed OK --- Subject: OK : Zope-2.8 Python-2.3.6 : Linux From: Zope Tests Date: Wed Jun 4 21:00:48 EDT 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-June/009655.html Subject: OK : Zope-2.9 Python-2.4.4 : Linux From: Zope Tests Date: Wed Jun 4 21:02:18 EDT 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-June/009656.html Subject: OK : Zope-2.10 Python-2.4.4 : Linux From: Zope Tests Date: Wed Jun 4 21:03:48 EDT 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-June/009657.html Subject: OK : Zope-2.11 Python-2.4.4 : Linux From: Zope Tests Date: Wed Jun 4 21:05:18 EDT 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-June/009658.html Subject: OK : Zope-trunk Python-2.4.4 : Linux From: Zope Tests Date: Wed Jun 4 21:06:48 EDT 2008 URL: http://mail.zope.org/pipermail/zope-tests/2008-June/009659.html ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Conflict Errors
Previously David Otero Figueroa wrote: Hello everyone, I have a couple questions related to conflict errors. During our home page stress testing (20 concurrent users), we detected several conflict errors (see trace below), We thought these could ONLY appear when writing objects in the ZODB. That is correct. You need to audit your check to check for undesired writes. Wichert. -- Wichert Akkerman [EMAIL PROTECTED]It is simple to make things. http://www.wiggy.net/ It is hard to make things simple. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Conflict Errors
Hello everyone, I have a couple questions related to conflict errors. During our home page stress testing (20 concurrent users), we detected several conflict errors (see trace below), We thought these could ONLY appear when writing objects in the ZODB. 2008-05-27T18:57:53 INFO ZODB conflict error at /portal/ (26 conflicts since startup at 2008-05-27T13:37:19) I have this problems too in a not estress testing. In a simple access (2 concurrents users) I have this response: 2008-05-27T13:23:48 INFO ZODB conflict error at /portal/ (22 conflicts since startup at 2008-05-27T10:37:28) 2008-05-27T13:23:48 INFO ZODB conflict error at /portal/ (23 conflicts since startup at 2008-05-27T10:37:28) 2008-05-27T13:29:21 INFO ZODB conflict error at /portal/login_form_usuario_pwd/ (29 conflicts since startup at 2008-05-27T10:37:28) 2008-05-27T13:29:22 INFO ZODB conflict error at /portal/login_form_usuario_pwd/ (30 conflicts since startup at 2008-05-27T10:37:28) 2008-05-27T19:48:40 INFO ZODB conflict error at /portal/portal_css/Plone Default/ploneStyles5658.css (68 conflicts since startup at 2008-05-27T13:37:19) I would like to know: - Can conflict errors appear when reading objects from the ZODB? - Could conflict errors be the cause of a spinning ZOPE scenario? - Is there any situation where ZOPE could try to write objects when rendering an only read page? - How can they be solved? - Can I realize partial commits? How to? Our configuration is as follows: Apache + Pound + ZEO architecture (5 ZEO clients, 1 ZEO storage server - 650.000 ZODB objects) Thanks in advance. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Conflict Errors
On Jun 5, 2008, at 10:16 AM, Jim Fulton wrote: On Jun 5, 2008, at 9:52 AM, David Otero Figueroa wrote: I would like to know: - Can conflict errors appear when reading objects from the ZODB? Yes Gaaa. I meant no. Jim -- Jim Fulton Zope Corporation ___ 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] Restricted Python not handling slices correctly
Hi everyone, I am starting to use Restricted Python a lot and I found the following problem with slicing: from zope.security import checker l = [1, 2] l[-3:] [1, 2] lp = checker.ProxyFactory(l) lp[-3:] [2] The problem is that -3 gets converted to 1 somewhere, but it should be a negative number signalizing the slice to start at the beginning of the sequence. The problem exists both in Python 2.4 and 2.5 and affects both Zope 2 and 3, since both Zopes use the RestrictedPython package. I suspect that the problem lies with the new slicing syntax introduced in Python 2.4. I am willing to fix the bug, but I would need some guidance and goodwill from the gods of RestrictedPython. Anyone? Regards, Stephan -- Stephan Richter Web Software Design, Development and Training Google me. Zope Stephan Richter ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: SQLAlchemy (zope.sqlalchemy) integration
Hermann Himmelbauer wrote: Am Mittwoch, 4. Juni 2008 22:09 schrieb Laurence Rowe: Hermann Himmelbauer wrote: In my application, I then use getSASession() to retrieve my session. However, what I think is not that beautiful is the s.bind = engine part. Are there any suggestions how to improve this? You have two options If you ever need to mix objects from different `sites` into the same session, you should use an adapter on your root object like: If you don't need to mix objects from different `sites` then you can register a local utility for ISessionConfig. def scope(): return getUtility(ISessionConfig).uid, thread.get_ident() def factory(): engine = Engine(getUtility(ISessionConfig).url) return create_session( transactional=True, autoflush=True, bind=engine extension=ZopeTransactionExtension(), )) Session = scoped_session(factory, scopefunc=scope) Then you can just import Session and use: session = Session() Ok, great, thanks for help. The only thing I don't understand is what uid from the SessionConfig utility is. Below is my full database integration code which works for me, perhaps this is helpful to someone else. uid is some id that distinguishes your various application instances. On zope 2 I would probably use getPhysicalPath(). I don't know what the zope3 equivalent is. Looking at your code, why did you decide to store the engine on a _v_ attribute? I don't think you need to save it at all. You can access a connection through session.connection() Btw., I'd suggest to put such code / session use cases in some Zope package, maybe into zope.sqlalchemy, or e.g. zope.sqlalchemy_utility as it's really difficult for non-insiders to set this up. We would need to work out what parts are useful to the various higher level sqlalchemy / zope packages. Once we can agree on a common core then we should at least make simple use cases available through zope.sqlalchemy directly. Laurence ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: Restricted Python not handling slices correctly
Hey Stephan, Stephan Richter wrote: I am starting to use Restricted Python a lot I'm curious to learn what you're using it for. Regards, Martijn ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Re: Restricted Python not handling slices correctly
On Thursday 05 June 2008, Martijn Faassen wrote: Stephan Richter wrote: I am starting to use Restricted Python a lot I'm curious to learn what you're using it for. I cannot give you the full details yet, but Keas, the company I am working for now, has been developing a domain-specific language that is based on Python. We did some cool stuff overriding slicing and item lookup; I will be able to say more once we launched. Clearly we do not allow to run unrestricted Python and run everything in restricted Python. The slicing and getitem syntax is very central to us, so then the problem popped up pretty quickly. Regards, Stephan -- Stephan Richter Web Software Design, Development and Training Google me. Zope Stephan Richter ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: Restricted Python not handling slices correctly
Stephan Richter wrote: On Thursday 05 June 2008, Martijn Faassen wrote: Stephan Richter wrote: I am starting to use Restricted Python a lot I'm curious to learn what you're using it for. I cannot give you the full details yet [snip hints] Thanks for the info nonetheless. My curiosity has only increased now, but that can't be helped. :) Keas sounds interesting! Regards, Martijn ___ 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] fast_listen - fast-listen for 2.11
I'd like to sneak the following patch into 2.11 before final. The idea is that zope.conf option names should use dashes and not underscores. The downside is that it will break all zope.conf files that already use this option. Objections? Stefan +Bugs Fixed + + - Fixed against-the-rules zope.conf option 'fast_listen' to read +'fast-listen' (dash, not underscore). + Zope 2.11 rc 1 (2008/05/08) Bugs Fixed Index: skel/etc/zope.conf.in === --- skel/etc/zope.conf.in (revision 84838) +++ skel/etc/zope.conf.in (working copy) @@ -975,8 +975,7 @@ # # To defer the opening of the HTTP socket until the end of the # startup phase: - # fast_listen false - # + # fast-listen off /http-server # Examples: Index: lib/python/ZServer/component.xml === --- lib/python/ZServer/component.xml(revision 84838) +++ lib/python/ZServer/component.xml(working copy) @@ -19,10 +19,10 @@ receive WebDAV source responses to GET requests. /description /key - key name=fast_listen datatype=boolean default=on + key name=fast-listen datatype=boolean default=on description - Defines wether the http server should listen to requests immediately - or only after zope is ready to run + Defines whether the HTTP server should listen for requests + immediately or only after Zope is ready to run. /description /key key name=use-wsgi datatype=boolean default=off / -- Anything that, in happening, causes something else to happen, causes something else to happen. --Douglas Adams ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Restricted Python not handling slices correctly
Stephan Richter wrote: Hi everyone, I am starting to use Restricted Python a lot and I found the following problem with slicing: from zope.security import checker l = [1, 2] l[-3:] [1, 2] lp = checker.ProxyFactory(l) lp[-3:] [2] The problem is that -3 gets converted to 1 somewhere, but it should be a negative number signalizing the slice to start at the beginning of the sequence. The problem exists both in Python 2.4 and 2.5 and affects both Zope 2 and 3, since both Zopes use the RestrictedPython package. I suspect that the problem lies with the new slicing syntax introduced in Python 2.4. I am willing to fix the bug, but I would need some guidance and goodwill from the gods of RestrictedPython. Anyone? Are you in fact using RestrictedPython? The code snippet looks like it only uses a security proxy. RestrictedPython is a custom Python compiler; you're not using it unless your interactive Python prompt uses RestrictedPython to compile all expressions. The behavior you saw is exactly what happens when an object implements __getitem__ and __len__ but not __getslice__. If lp matches that description, and the length of lp is 2, then Python evaluates lp[-3:] as lp.__getitem__(slice(-1, 2147483647, None)). I wish Python would instead evaluate it as lp.__getitem__(slice(-3)), but maybe there are historical reasons for this. OTOH, if RestrictedPython really is involved, RP will convert the expression to _getitem_(lp, slice(-3, None)), which would probably do what you wanted, assuming the _getitem_ function is not too clever. BTW, here's the code I used to answer this email. :-) class itemgetter: ... def __getitem__(self, i): ... return i ... def __len__(self): ... return 2 ... itemgetter()[-3:] slice(-1, 2147483647, None) Shane ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] fast_listen - fast-listen for 2.11
On Fri, Jun 06, 2008 at 01:37:16AM +0200, Stefan H. Holek wrote: I'd like to sneak the following patch into 2.11 before final. The idea is that zope.conf option names should use dashes and not underscores. The downside is that it will break all zope.conf files that already use this option. Hmm. Was this around in 2.10 already? If yes, then I'd consider it a bit late to make a cosmetic fix that breaks config files. If no, then it's probably not as bad and should be done to avoid config files getting created with a variable we know will change. Christian -- Christian Theune · [EMAIL PROTECTED] gocept gmbh co. kg · forsterstraße 29 · 06112 halle (saale) · germany http://gocept.com · tel +49 345 1229889 7 · fax +49 345 1229889 1 Zope and Plone consulting and development ___ 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 )