Re: [Zope3-Users] MemoryError Evolving a ZODB
On Wed, Dec 12, 2012 at 12:39:18AM -0800, Jeroen Michiel wrote: Thanks for the reply! I already tried transaction.savepoint() every minute, but that didn't help: I only saw the memory usage dropping the first time, but never after. I changed the code to what you suggested, but it still doesn't seem to help. Something must be wrong somewhere along the line, but I don't have a clue where to begin looking. Would using something like guppy (or heapy, or what it's called) reveal something? (I tried to figure out guppy/heapy once, gave up.) Could it be something about objects with circular references not being able to be garbage-collected? The objects in my DB are quite complex, so something like that might actually be happening. Usually when a Python process eats too much memory, your server ends up in swappy death land. My gut feeling is that MemoryError means a corrupted pickle that tries to allocate a large amount of memory (e.g. multiple gigabytes) all in one go. Can you add a try:/except MemoryError: import pdb; pdb.set_trace() in there? See if the process memory usage is really big. Write down the object OID (ZODB.utils.u64(obj._p_oid)), try to load it from a separate Python script process (with the same sys.path, so custom classes are unplickleable): db = ZODB.DB.DB(ZODB.FileStorage.FileStorage('Data.fs', read_only=True)) conn = db.open() obj = conn.get(ZODB.utils.p64(0xX))# creates a ghost try: obj._p_activate() # tries to load it except MemoryError: import pdb; pdb.set_trace() See if you get a memory error there. If so, try do disassemble the pickle (pickletools.dis) maybe -- if you've got pdb, you can find the pickle itself one stack frame up. Marius Gedminas -- I want patience, and I WANT IT NOW! signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org https://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form: small patch
On Thu, Oct 21, 2010 at 03:47:16PM +0200, Toni Mueller wrote: Hello, since the zope3-dev list appears to be dead, It was merged into the zope-dev list. and since I have no better idea about where to put this, I send you a small patch for z3c.form version 2.4.1. The bug tracker (launchpad) is a good place for patches, in theory. Background: https://bugs.launchpad.net/singing-dancing/+bug/620608 Marius Gedminas -- http://pov.lt/ -- Zope 3/BlueBream consulting and development signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org https://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] zope3.4.1
On Thu, Sep 17, 2009 at 12:58:09PM +0530, Milind Khadilkar wrote: Thanks everybody. I was (and am) wondering why on http://www.zope.org/Products/Zope3/3.4.1 we find this: QUOTE: Version: 3.4.1 http://www.zope.org/Products/Zope3/3.4.1 Release Date: 2009-08-06 06:01:52 Last Modified: 2009-08-06 07:33:17 Author: jim License: ZPL Categories: Maturity: Stable UNQUOTE By date and version number, and being stable, it should be THE current stable release. There is obviously some mismatch that has lasted more than the customary time taken to update announcement pages and get them in sync. Or the information on the page is misleading. I am using the 3.4.1 version for over a month now. It does look as if not all the places are updated. For example, http://download.zope.org/zope3.4/ has no knowledge of 3.4.1. Marius Gedminas -- Don't trust a statistic you haven't faked yourself. -- Seen in another posting by Markus Kuhn signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org https://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] [ZCML] Issue with conflicting browser:page decl
On Wed, Aug 05, 2009 at 04:14:49PM +0200, Andreas Jung wrote: On 05.08.09 16:11, Marius Gedminas wrote: On Tue, Aug 04, 2009 at 07:22:36PM +0200, Andreas Jung wrote: Hi there, I'm really puzzled about the following ZCML configuration conflict where I am trying to override a browser:page for defined in dateable.chronos.browser.events.EventListingView.upcomingEvents with slightly customized implementation within my own idg.theme package. Both ZCML configuration are of course identical except the the 'class' is different. Anything I am missing? The ingenious model of ZCML overrides. My configuration was almost right - including the includesOverrides statement within my configure.zcml. However I was using includesOverrides file=overrides.zcml / instead of includesOverrides file= / What on Earth does that do? From reading the source code I can see that it's equivalent to includesOverrides file=configure.zcml / but still -- are you including the file within itself, using includeOverrides? Black-'n-dirty-magic, Marius Gedminas -- For vi emulation of emacs, just type :sh emacs (without the quotes). signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Persistent obj with attr hooks
On Thu, Jul 23, 2009 at 01:41:57PM -0400, Jim Pharis wrote: I have a class that inherits from Persistent but also needs to hook into setattr and getattribute. class Test(Persistent) ... def __setattr__(self, name, val) def __getattribute__(self, name) Before when this class inherited from object the __setattr__ and __getattribute__ calls were simple and straight forward with object.__getattribute__(name). However, now that I inherent from Persistent, the equivalent Persistent.__getattribute__ and Persisent.__setattr__ don't seem to set/get my attributes. Can someone help me out. What call should I be using instead? Works For Me(TM): from persistent import Persistent class Test(Persistent): ... def __setattr__(self, name, value): ... print setting %s to %r % (name, value) ... super(Test, self).__setattr__(name, value) ... def __getattribute__(self, name): ... print getting %s % (name) ... return super(Test, self).__getattribute__(name) ... apple = Test() apple.color = 'green' setting color to 'green' apple.color getting color 'green' Show us your code if you want more advice. Marius Gedminas -- IBM motto: TEN vowels? Don't you know vowels are scrd? -- Linus Torvalds signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] functional doctest and testbowser with zopeproject
On Tue, Mar 31, 2009 at 02:09:34PM -0700, Douglas Cerna wrote: Hi. I had a similar error and fixed it modifying: browser.addHeader('Authorization', 'Basic mgr:mgrpw') To: browser.addHeader('Authorization', 'Basic globalmgr:globalmgrpw') Both principals are defined in the ftesting.zcml file of your project, but just the globalmgr has the Manager role assigned. This is intentional and tends to expose bugs in your application. If you have an object without a correct __parent__ chain leading to the ZODB root, your object will never see local security grants (such as mgr:mgrpw has) so any users defined TTW won't be able to access it. The fix is to ensure that *every* object of your application has a __parent__. (Note that this use of __parent__ for security is independent from containment -- you don't need your objects to provide ILocation, or have __name__'s -- the Zope 3 security mechanism looks at __parent__ attributes without checking interfaces.) Marius Gedminas -- Life begins when you can spend your spare time programming instead of watching television. -- Cal Keegan signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Run starup code with zope 3.
On Thu, Feb 12, 2009 at 07:28:23PM +0100, Sebastian Bartos wrote: Was playing with the event system a bit, and ended up with the following, which works fine: import zope.event class MyEvent: pass event = MyEvent() def f(event): if isinstance(event, zope.app.appsetup.interfaces.ProcessStarting): Put stuff you want to execute after server startup here. principalPermissionManager.grantAllPermissionsToPrincipal(use) zope.event.subscribers.append(f) ... Is this a good zopey way? An emphatic No. This slows down the processing of every event by performing an extra function call and an if statement, instead of using a hash-driven dispatch that zope.component provides for subscribers. The subscriber / ZCML directive is a good Zopey way. ZCML: subscriber handler=.module.grantStuffOnStartup / Code: @zope.component.adapts(zope.app.appsetup.interfaces.ProcessStarting) def grantStuffOnStartup(event): principalPermissionManager.grantAllPermissionsToPrincipal(use) Also, if you're hardcoding the principal ID here, you might as well just do it in ZCML: grantAll principal=use / and if you're not hardcoding/want to be able to adjust the grant later through the web, you should really use the IPrincipalRoleMap adapter on the root folder that will store the grant persistently in the DB rather than in memory. Marius Gedminas -- There is an almost obvious extension of interfaces that would allow formal specification of arguments and return values. We suspect it leads to the dark side. -- Jim Fulton signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] container items
On Sat, Jan 17, 2009 at 11:28:02PM -0500, Jim Pharis wrote: I've been struggling with a container view that displays attributes of the items contained in the container. In the page template for the container, I want to display some attributes from each of the items. The following works fine div tal:content=python:context['item1'].text /div The following produces a Forbidden Attribute error div tal:repeat=item context/items This iterates over the *names* of the items. div tal:content=item/text/div /div What am I doing wrong? Should I be accessing the items in the container a different way? Yes. You want div tal:repeat=item context/items/values HTH, Marius Gedminas -- It's my understanding that although in principle TCP can handle huge throughputs in practice many stacks haven't been optimized for that case, so you have to either use a utility which opens multiple TCP sessions in parallel or do something really radical like upgrade to the latest version of the linux kernel. -- Bram Cohen signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Need help with an urgent problem
On Wed, Jan 07, 2009 at 01:28:24PM -, kevin gill wrote: I am having a problem on my live site. The problem is todo with a DataBase connector object which ends up in an incorrect state: This is the important part of the traceback. File /home/kevin/src/castingzone.tables/castingzone/tables/person/extraaccount_db.py, line 460, in IsValidUser result = self.execute('extraaccount.IsValidUser', self.IsValidUser.__doc__, **params) File /home/kevin/src/castingzone.utility/castingzone/utility/db/db.py, line 125, in execute return queryForResults(connection, query) File /home/kevin/src/castingzone.utility/castingzone/utility/db/db.py, line 28, in queryForResults cursor.execute(query) File /srv/zope/hosting/castingzone/instance/hacks/psycopgda-1.0-py2.4.egg/psycopgda/adapter.py, line 417, in execute return ZopeCursor.execute(self, operation, parameters) File /srv/zope/hosting/castingzone/eggs/zope.rdb-3.4.0-py2.4.egg/zope/rdb/__init__.py, line 261, in execute operation, parameters = self._prepareOperation(operation, parameters) File /srv/zope/hosting/castingzone/eggs/zope.rdb-3.4.0-py2.4.egg/zope/rdb/__init__.py, line 278, in _prepareOperation encoding = self.connection.getTypeInfo().getEncoding() File /srv/zope/hosting/castingzone/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Connection.py, line 798, in setstate raise ConnectionStateError(msg) ConnectionStateError: Shouldn't load state for 0x1d54 when the connection is closed If I'm not mistaken, this error typically occurs when you try to hold a reference to a Persistent object across transaction boundaries (e.g. by storing it in a global). Don't do that. Sometimes this happens in unexpected places (e.g. having a schema with an Object field that has a default value, and an edit form -- the default value is never explicitly copied, so you may end up with multiple references to it). I'm not saying this could be your problem; I'm just trying to remind you that some globals may be difficult to notice if you haven't been burned by them before. Once the server gets into this state, it seems to repeat often. The object in question is a database connection object. Are you talking about the persistent object with oid 0x1d54? I have just retrieved it via an adapter lookup. It is not stored. connection= zope.component.getUtility(IZopeDatabaseAdapter, CONNECTION_NAME, self.context)() The database connection is provided by a global utility. The important code is as follows: def connection_directive(_context, name=CONNECTION_NAME, connection_string='', encoding='latin-1'): Process a db:Connection zcml directive # Don't delay to the end of the configuration process - gAdapter = PsycopgAdapter(connection_string) gAdapter.setEncoding(encoding) gAdapter.connect() provideUtility(gAdapter, IZopeDatabaseAdapter, name) This looks okay-ish to me (latin-1, yuck, is this the 20th century still?). Any help in narrowing down this problem would be greatly appreciated. It is making my live system unworkable. Start a debug console (zopectl debug or bin/debugzope), then take a look at oid 0x1d54: from ZODB.utils import p64 app.root()._p_jar.get(p64(0x1d54)) The interesting bit of information is the class name of that object. Then look through the sources trying to determine the lifetime of that object: where are references to it created? Marius Gedminas -- I doubt, therefore I might be. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Smarter values for values = [] in Choice schema fields?
On Thu, Nov 06, 2008 at 02:13:56PM +0100, Hermann Himmelbauer wrote: I quite often have Choice schema fields in my applications. In many cases, these choice fields should have fixed values, thus I do it like this: color = Choice( title=uColor, values=['red', 'green', 'yellow']) My application then uses the these values for further processing, e.g.: if color == 'red': stop_traffic() The problem is, that often it is more appropriate to have one value for display, and another for internal processing (e.g. when msgid strings are involved, when the program needs specific values etc.) The only way I found is to set up a vocabulary and use SimpleVocabulary.createTerm(key, n, name), however, that's quite tedious, as I need to write quite some code, register the vocabulary etc. Not really. So, perhaps there's a simpler solution? I'd favour something like this: color = Choice(titel=uColor, values = [('red', 0, uRed), ('green', 1, uGreen)]) Is that possible? Define a helper function def vocabulary(*terms): return SimpleVocabulary([SimpleTerm(value, token, title) for value, token, title in terms]) and use it color = Choice(title=uColor, vocabulary=vocabulary( (0, 'red', u'Red'), (1, 'green', u'Green'), )) HTH, Marius Gedminas -- Undergraduates owe their happiness chiefly to the fact that they are no longer at school...The nonsense which was knocked out of them at school is all gently put back at Oxford or Cambridge -- Sir Max Beerbohm (1872-1956) signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] i18nextract.py issue
On Thu, Oct 30, 2008 at 11:39:03PM +0900, hass wrote: I have been struggling to extract messageIDs out of my application and list save them into a .POT file. I only know that this used to be a relatively straightforward process untill 3.2 when zope was installed from the source code but what about now? I have installed a big bunch of zope eggs using zopeproject and have a running server. Now that I want to translate my site, I found out that the old i18nextract script is mysteriously missing. I checked the internet and there is no explanation how to obtain it. So the first problem will be how to obtain the i18nextract.py script in the standard way?. Check out lovely.recipe. Here's all the documentation I could find: http://svn.zope.org/*checkout*/lovely.recipe/trunk/src/lovely/recipe/i18n/README.txt Marius Gedminas -- Please don't put a strain on our friendship by asking me to do something for you. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Issue with xmlrpc call to zope3 xmlrpc view hanging, until original call interupted.
On Thu, Oct 16, 2008 at 04:39:13PM +0800, Tim Hoffman wrote: I wonder if anyone can shed some light on a problem I am having with xmlrpc calls to a zope3 server. I am running zope3 from buildout on python2.5 on unbuntu. I have a view defined for xmlrpc (zope.app.publisher 3.5.0) the same view is also defined for jsonrpc using z3c.jsonrpc I am testing with xmlrpclib and the z3c.jsonrpc proxy Everything works fine when testing the jsonrpc call. However when performing the xmlrpc call the call hangs, until I either kill the server, or the ctl ^c the test. I know the zcml registration for the view is correct as I end up in the method of the view on the server,because I can put import pdb pdb.set_trace() in the method in question, and when I kill the client socket the server thread advances to the set_trace call It seems as if the publisher for xmlrpc is not reading everything from the socket. This sounds strangely familiar. Is the request in plain-text, or is it going over SSL? I have been using xmlrpclib for years against zope2 and never experienced sort of problem, and my current python 2.4 and 2.5 xmlrpclib in ubuntu works fine against existing zope2 servers. xmlrpclib works fine for me against zope 3 using zserver (or maybe zope.app.twisted) on python 2.4, no SSL. I am using paste.httpserver . If I'm not mistaken, paste.httpserver will sometimes hang forever if you send a request with a body and no Content-Type field. Can you check whether xmlrpclib sends it? Any ideas, things I could try to diagnose the problem? Change other variables (no SSL if you have it; python 2.4 versus 2.5; zserver instead of paster), try to see where the hang occurs on the server side. Marius Gedminas -- Some of the more environmentally aware dinosaurs were worried about the consequences of an accident with the new Iridium enriched fusion reactor. If it goes off only the cockroaches and mammals will survive... they said. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Buildout seems to be broken due to missing back35.py in zope.app.component.
On Wed, Oct 15, 2008 at 10:59:24AM -0400, Benji York wrote: On Wed, Oct 15, 2008 at 10:46 AM, Hermann Himmelbauer [EMAIL PROTECTED] wrote: Hi, It seems that buildout is broken: Are you referring to the Zope 3 trunk buildout? What's that, exactly? zope.release trunk? Marius Gedminas -- Premature optimization is the root of all evil. -- D.E. Knuth signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Buildout seems to be broken due to missing back35.py in zope.app.component.
On Wed, Oct 15, 2008 at 01:15:15PM -0400, Benji York wrote: On Wed, Oct 15, 2008 at 1:07 PM, Marius Gedminas [EMAIL PROTECTED] wrote: On Wed, Oct 15, 2008 at 10:59:24AM -0400, Benji York wrote: On Wed, Oct 15, 2008 at 10:46 AM, Hermann Himmelbauer [EMAIL PROTECTED] wrote: Hi, It seems that buildout is broken: Are you referring to the Zope 3 trunk buildout? What's that, exactly? zope.release trunk? I was referring to svn://svn.zope.org/repos/main/Zope3/trunk. I can only assume that's what the OP was referring to. That's not a buildout: it has no buildout.cfg, nor bin/buildout, nor bootstrap.py. What I was hoping to find was the equivalent for the KGS, but without explicit version restrictions; to test whether the latest versions of all the zope packages work together. Marius Gedminas -- The difference between Microsoft and 'Jurassic Parc': In one, a mad businessman makes a lot of money with beasts that should be extinct. The other is a film. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] WrongContainedType
On Fri, Oct 10, 2008 at 06:19:48PM +0200, Roger Ineichen wrote: Hi Tim Betreff: Re: AW: [Zope3-Users] WrongContainedType On Fri, 2008-10-10 at 17:46 +0200, Roger Ineichen wrote: I guess not, normaly such an error has an empty representation and the list is not empty. Try to do errors[0] or type(errors[0]) and you probably see something. If not I'm confused Well, I'm confused anyway, but that isn't difficult. ;-) After commenting the the if test on errors and the raise. With print 'Object schema validation errors=',type(errors[0]): I get: Object schema validation errors= class'zope.schema._bootstrapinterfaces.RequiredMissing' Object schema validation errors= class'zope.schema._bootstrapinterfaces.RequiredMissing' With print 'Object schema validation errors=',errors[0]: I get: just the string Object schema validation errors= printed on each line. With print 'Object schema validation errors=',errors: I get: Object schema validation errors= [] Object schema validation errors= [] That's because RequiredMissing subclasses ValidationError, which defines def __repr__(self): return ' '.join(map(str, self.args)) That's bad code! No cookie! If you do print [RequiredMissing()] you will see [] which is not distinguishable from an empty list. Things to fix: * ValidationError's __repr__ should consider the corner case when self.args is empty and return, say, self.__doc__. * the piece of code that raises RequiredMissing should always supply some arguments (at the very least, the name of the field with the missing value) The error (probably, not sure) means that the object you like to store has a missing value. Can you check the schema of this object and set required=False in all fields? If there is a problem, can you post the interface and class of this object as a sample? And probably the code which tries to store the object. That is the correct path to fixing Tim's problem, but I think we should fix Zope as well. Marius Gedminas -- I used to be an agnostic, but now I'm not so sure. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] WrongContainedType
On Fri, Oct 10, 2008 at 09:17:08PM +0200, Roger Ineichen wrote: Also this doesn't work: terminologiesAvailable=List( title=_(uTerminologies), description=_(uList of terminologies in this ontology.), required=True, value_type=TextLine(), default=[], Ouch, careful! If you have a mutable object as the default value of a field, it's really easy to accidentally end up with multiple objects sharing the same value object. ) if 'terminologies_available' in sections: ontObj.terminologiesAvailable = parsed_adl.ontology['terminologies_available'][0] else: ontObj.terminologiesAvailable = [] Here you're trying to set an empty list as value. The schema says required=True and that's not the case with ontObj.terminologiesAvailable = [] It's interesting, but I always thought required=True meant the field couldn't be None, and [] is not None. Then again I never quite completely understood all the corners of zope.schema. In the sample above just remove the else condition. The object whould return an empty list as defined in default anyway. I hope I catched the right interfaces and didn't mess tings up. Is there another terminologiesAvailable attr defined in another interface? btw, I really dislike this invalid schema definitions. With invalid I mean the default value is not a vaild value if ou try to store them. because of: required=True default=[] This is a combination which is not valid and it's not possible to store the default value again. Marius Gedminas -- World domination. Fast. -- Linus Torvalds signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] ZCML Layout Decision?
On Thu, Oct 09, 2008 at 02:56:16AM -0300, Tim Cook wrote: What are your thoughts on the best way to implement the configure.zcml files for this application framework? The framework is a nested structure up to five levels deep in places of approximately 150 classes. Would it be better/more efficient to create a configure.zcml in each package or just one at the top level? A configure.zcml in each package is the norm. (If one gets too big to comprehend, it is often split into several smaller ones by topic, e.g. feature1.zcml, feature2.zcml or browser.zcml, security.zcml, etc.) Another design decision is that this is a framework for application developers and probably 99% of them will have no previous Zope experience. So teaching them how to setup zcml for their own security declarations etc will be an issue as well. Have you considered Grok? Marius Gedminas -- After having done some test using hi-tech istruments (moving my mouse during a kernel build) [...] -- Davide Libenzi on lkml signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] WrongContainedType
On Thu, Oct 09, 2008 at 08:42:21AM -0300, Tim Cook wrote: I am having difficulty understanding this error. It occurs in the call: ontObj.parentArchetype = ObjectRef(oid,u'openehr',u'ARCHETYPE') The first parameter for ObjectRef is declared in the schema as: refId = Object( schema=IObjectId, title = _(u'Id'), description = _(u'Globally unique id of an object (of type ObjectId), regardless of where it is stored.'), required = True ) If I print the parameter 'oid' it does correctly report: oship.openehr.rm.support.identification.objectid.ObjectId object at 0x1b70210 the other two parameters for ObjectRef are declared as TextLines. The traceback is: zope.schema.interfaces.WrongContainedType: [, []] Oh dear. That's one of the worst error messages I've seen. What I do not understand is how to interpret the [, []] By reading the source code. Object field validation actually attempts to validate the schema (IObjectId in this case) of the object you're trying to store (the ObjectId object, in this case). If any of the fields cannot be validated during this nested validation, you get a WrongContainedType with the list of errors (one for each field). Apparently those errors have horrible __repr__s. That ought to be fixed. I'm not passing a list nor is the schema using a list. I realize that this may be pretty basic but I am missing something in reading the error. I'd put a breakpoint in zope.schema._field, specifically, in Object._validate, and try to see what's wrong by single-stepping. Marius Gedminas -- We're sysadmins. To us, data is a protocol-overhead. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.formjs - global js-variables and form-content in scripts
On Wed, Sep 17, 2008 at 11:26:28PM -0700, Paul Carduner wrote: On Wed, Sep 17, 2008 at 4:48 PM, garz [EMAIL PROTECTED] wrote: my goal is to write a general sequence-form, that can display a sequence consisting of an arbitrary widget. it should provide delete-buttons for every element. in add-forms, the functionality of these should be realized through javascript, dom-manipulation plus submit and in edit-forms without submit but with ajax. This particular use case I think is too high level for a package like formjs, but would certainly be a great addition as an example in formjsdemo. It seems quite similar to the tree editor demo in formjsdemo: http://demo.carduner.net/z3c.formjsdemo/test If it were a widget for List fields, it would be a great addition to, um, z3c.widget? z3c.listwidget? I think. The ancient Zope 3 widget for List fields is pretty bad. Marius Gedminas -- Key emulation: [ ] Intuitive [*] Emacs(Seen in an MCEdit dialog) signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] NotFound Exceptions
On Wed, Sep 17, 2008 at 10:18:49AM -0400, David Johnson wrote: We're having a Zope problem and I wonder if anyone has experience with it. Basically, we're getting NotFound exceptions randomly. This occurs at frequency around 10% of the time. It does not matter which component or view, and we're using a custom skin based upon the Rotterdam skin. We're using Zope 3.3.1. The errors occur in all applications within this one particular instance on one particular server. I've included a traceback here: http://jsa.pastey.net/96278 I bet you're seeing https://bugs.launchpad.net/zope3/+bug/98440. Upgrade to zope.publisher 3.4.6 (or at least 3.4.4) and the problems should be gone. OTOH a conflict error for 10% of request seems very high. Do you use zope.annotation.factory? If so, upgrade to zope.annotation 3.4.1; the fix for https://bugs.launchpad.net/zope3/+bug/261620 stops it from writing to __parent__/__name__ on every access. Marius Gedminas -- This is, or so I'm told, a classic book. I can see why. It is long and it requires a great effort to finish it. If you go through a great effort to suffer for a long time, you are allowed to sneer at people who can't be bothered. That's the surest sign of classic art. -- Lars Wirzenius signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c, GET variables handling pattern
On Thu, Sep 11, 2008 at 03:19:08PM -0400, Daniel Fimiarz wrote: I am new to plone/zope. I am trying to use z3c forms with plone to fetch some data from RDBMS but I am having an issue with variables passed to edit forms using GET and POST variables. From what I read, the edit form needs to override the getContent function: def getContent(self): #get the id from the request object personid = int(*self.request['entityid']*) Well, the usual idiom is to access the object through traversal, so the form can work with self.context. However it can be made to work the way you're trying to get it to work. #use the id to look up the person person = sql.getPerson(personid) #create a return a dictionary content = dict( [ (name, getattr(person,name)) for name in self.fields.keys()]) return content I haven't used z3c.form that much, but I'm think you could just return the person object here instead of creating a dict. This works and I can display values just fine, but when I do something similar in the action handler @button.buttonAndHandler(u'Apply',name='applyView') def handleApplyView(self,action): self.handleApply(self,action) if not self.widgets.errors: url = absoluteURL(self.context,self.request) url += '/person-view?id=' + *self.request['entityid'] * self.request.response.redirect(url) I get an error that there is no entityid key in self.request. Inspecting the request object seems to confirm that. To get it you'd need to add a hidden field to your form, e.g. in the page template input type=hidden name=entityid tal:attributes=value request/entityid / That would mean overriding the default form template, if you're not doing that already. I guess my other options are to: - Get the value from form directly with *self.request.form.widgets.entityid*(seems like an ugly thing to do) - Get the value from *data[]* dictionary. Won't work. What would be the best pattern for handling this type of processing? I have used z3c.formdemo and their example (sqlmessage) but for some reason self.request['id'] seems to work for them. That's because they do exactly what I suggested: override the page template and add a hidden field. Take a look at z3c/formdemo/sqlmessage/edit.pt HTH, Marius Gedminas -- ... there is always a well-known solution to every human problem -- neat, plausible, and wrong. -- H. L. Mencken (1880-1956), Prejudices signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Apache config. for skinned sites
Hi, On Thu, Aug 21, 2008 at 05:04:30PM +1200, andrew wrote: Say I've got a site at: http://127.0.0.1:8080/mysite and I've mapped this to a domain (mysite.com) pointed to by an Apache rewrite rule: RewriteRule ^/(.+) http://127.0.0.1:8080/mysite/++vh++http: %{HTTP_HOST}:80/++/$1 [L,P] Warning: HTTP_HOST sometimes includes the port number. It all depends on what the browser sends you. I'm also somewhat surprised to see you using (.+) rather than (.*). but I've now created a skin for the site that I want to point skin2.mysite.com at. The following rewrite rule works: RewriteRule ^/(.+) http://127.0.0.1:8080/mysite/++vh++http: %{HTTP_HOST}:80/++/++skin++skin2/$1 [L,P] except that the skin URL component ends up in viewlet URLs, which sort of makes sense since it's after the virtual host stuff. However, it would be nice to get rid of the skin URL component altogether in page resources since it's being handled by Apache already. Also, I still want to be able to test the skin at: http://mysite.com/++skin++skin2/ so in this case the skin component would have to stay there. I've tried moving the skin URL component before the virtual host component in the rewrite rule: RewriteRule ^/(.+) http://127.0.0.1:8080/mysite/++skin++skin2/++vh ++http:%{HTTP_HOST}:80/++/$1 [L,P] but when accessing, e.g., http://skin2.mysite.com/testpage I get: File '/opt/vortex/buildout/vortex/var/eggs/zope.publisher-3.4.1-py2.4.egg/zope/publisher/http.py', line 568 in shiftNameToApplication raise ValueError(Can only shift leading traversal ValueError: Can only shift leading traversal names to application names Any ideas how I can have my cake and eat it too ? :-) It's an intentional limitation of the ++skin++ directive: it is only allowed at the very beginning of a URL (and, I think, due to an implementation detail, just after the ++vh++ directive). IIUC it's a security measure: you don't want your users to switch to other skins that may have views that shouldn't be available to them. You can try RewriteRule ^/(.+) http://127.0.0.1:8080/++skin++skin2/mysite/++vh++http:%{HTTP_HOST}:80/++/$1 [L,P] instead. Marius Gedminas -- MCSE == Marginal Computer Software Enthusiast signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] building zope 3 instances?
On Wed, Aug 20, 2008 at 03:02:32AM +0200, Sebastien Douche wrote: On Wed, Aug 20, 2008 at 00:11, Chris Withers [EMAIL PROTECTED] wrote: Please don't remove things! Never ever. People might still be using them. That is getting a bit old. The confusion from having this cruft lying around (in the same way as accidentally released packages) is causing a lot more hurt tham people who're already using this (and hence already have a local copy of the egg, which they can keep using should no egg be available on pypi) would experience if they went away. +1. Yes, ideally there should be some way to hide them on pypi such that setuptools still finds them but that they don't strip up unsuspecting users. Does pypi support this? At the *very* least it's take about 2 minutes for a package manager to put a large DO NOT USE - THIS IS ONLY HERE TO SUPPORT EXISTING SETUPS at the top of the text on pypi to stop innocent bystanders getting caught out. That's a very good idea. It should also point people to the current package that does the same thing. E.g. the description of zope.app.form currently says More advanced alternatives are implemented in zope.formlib and z3c.form. near the top. Remove packages on Pypi only (and not on download.zope.org). You'll get shouted at if you remove something from PyPI. Trust me. The response here is find-links option, I think. I heard people complaining a lot about find-links in setup.py files. find-links in your buildout.cfg might be OK. Marius Gedminas -- Bumper sticker: No radio - Already stolen. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Configuration Problems?
On Fri, Aug 01, 2008 at 12:29:28PM -0300, Tim Cook wrote: When it comes to actually viewing our content with a browser we fail. I thought that certainly a workshop full of bright people working all day on this problem would be able to discover what is missing; nope. ... we get a ComponentLookupError (traceback below). I just can't seem to figure out WHERE the look up error is coming from. The traceback shows you the WHERE, but that's not interesting. The WHY is interesting, and I could make a guess. The source is available at: http://www.openehr.org/svn/ref_impl_python/TRUNK/oship ... = URL: http://127.0.0.1:8080/%2B%2Bskin%2B% 2BDemoAT/AR/openEHR-EHR-EVALUATION.goal.v1/%40%40index.html ... Module z3c.form.form:189 in __call__ Module z3c.form.form:184 in update Module z3c.form.form:134 in update Module z3c.form.form:126 in updateWidgets Module z3c.form.field:241 in update Module zope.component._api:103 in getMultiAdapter adapter = queryMultiAdapter(objects, interface, name, context=context) if adapter is None: raise ComponentLookupError(objects, interface, name) return adapter raise ComponentLookupError(objects, interface, name) ComponentLookupError: ((zope.schema._bootstrapfields.Field object at 0x7f9af8717ad0, zope.publisher.browser.BrowserRequest instance URL=http://127.0.0.1:8080/++skin ++DemoAT/AR/openEHR-EHR-EVALUATION.goal.v1/@@index.html), InterfaceClass z3c.form.interfaces.IFieldWidget, u'') = Your form schema contains a plain Field() field. Zope has no widgets for this. Usually this happens when you define a content object's interface inheriting from IContained or ILocation. The fix is to omit __name__ and __parent__ from the interface. Without looking very deeply into your project, I suspect http://www.openehr.org/svn/ref_impl_python/TRUNK/oship/src/oship/browser/atdemo.py and I'd change it to class ATDemoDisplayForm(form.Form): A simple display form Archetypes. fields = field.Fields(IArchetype).omit('__name__', '__parent__') mode = DISPLAY_MODE Marius Gedminas -- If it wasn't for C, we'd be using BASI, PASAL and OBOL signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] buildout recipe for ReportLab
On Thu, Jul 10, 2008 at 09:21:57PM +0200, Lorenzo Gil Sánchez wrote: I'd like to ask if anybody is using a buildout recipe to install ReportLab in the buildout. I believe SchoolTool does. Browsing around in http://bazaar.launchpad.net/~ignas/schooltool/schooltool_buildout/files I see that they declare 'ReportLab' as an egg dependency and then mirror ReportLab-2.1.tgz in their HTTP/FTP site. Marius Gedminas -- [...] the basic your gun, your foot, your choice memory model. -- jtv on lkml signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] NOTICE: zope.org server move
On Wed, Jun 11, 2008 at 01:22:18AM -0500, Jens Vagelpohl wrote: The zope.org-related servers and services maintained by Zope Corporation will be moving to a new home late Thursday night Eastern Standard Time. How long will the outage last? The servers will be moved physically to a new hosting provider. There will be an outage of about 2 hours for the physical move, as well as an outage while the new DNS information for these services propagate throughout the internet. If the sysadmins reduce the DNS TTLs to something like 5 minutes, and do that well in advance of the physical move (say, couple of days before), then new DNS information should propagate quickly. Regards, Marius Gedminas -- Microsoft is not the answer. Microsoft is the question. No is the answer. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] IIntIds in test environment
On Wed, Jun 04, 2008 at 05:19:11PM +0200, Kai Diefenbach wrote: to register a IntIds utility by startup I'm using following subscriber: snip ensureUtility(root_folder, IIntIds, '', IntIds, copy_to_zlog=False) snip This is working when zope is running. I wonder why it isn't within tests. Are you talking about unit or functional tests? the code above is executed but the IntIds utility is not available. This sounds like functional tests to me. With: snip from zope.app.intid.interfaces import IIntIds from zope.component import getUtility intids = getUtility(IIntIds) This looks more like a unit test to me. Are you setting the site in the test fixture? Local utilities can only be found when you set the site (running zope does this for you when processing requests) or pass some context to getUtility. /snip I get: File /Users/Kai/Zope/instances/iqpp.qab/src/iqppqab/actions/adapters/actions .txt, line 28, in actions.txt Failed example: intids = getUtility(IIntIds) Exception raised: ... ComponentLookupError: (InterfaceClass zope.app.intid.interfaces.IIntIds, '') I guess I don't understand the whole SiteManager thing. Is there a working example of how to setup a test environment with IntIds. zope/app/catalog/README.txt could be an example. I haven't looked deeply, but it seems that it is registering an IIntIds utility as a global utility, which is much simpler and therefore more suitable for tests. Regards, Marius Gedminas -- ... there is always a well-known solution to every human problem -- neat, plausible, and wrong. -- H. L. Mencken (1880-1956), Prejudices signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How can I determine (in code) if the instance is running in devmode or not?
On Wed, May 28, 2008 at 04:45:13PM +0200, Andreas Johnsen wrote: I want to insert some extra HTML from a viewlet manager when running in devmode. How can I determine (in code) if the instance is running in devmode or not? from zope.app.appsetup.appsetup import getConfigContext def is_devmode_enabled(): Is devmode enabled in zope.conf? config_context = getConfigContext() return config_context.hasFeature('devmode') Regards, Marius Gedminas -- Don't trust a statistic you haven't faked yourself. -- Seen in another posting by Markus Kuhn signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How do I find out references to objects in ZODB
On Fri, May 02, 2008 at 10:17:46PM +0800, Yuan HOng wrote: Is it possible to find out what other objects are referencing a particular object in ZODB? Not easily -- you'd have to traverse the object graph yourself to see if you can find any references. In particular, I want to prevent some content objects, like images, from being removed from the folder if they are used in some other content object, like a news article. Do I have to keep track of object referencing in ZODB myself through events or there are some built-in mechanism in ZODB to take care of this for me? Your best bet is to keep track of this yourself. Indexes and catalogs may help. Marius Gedminas -- Given enough eyeballs all bugs are shallow. -- Eric S. Raymond, The Cathedral and the Bazaar signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] missing some tabs in the ZMI
Hello! On Sun, Apr 27, 2008 at 10:18:00PM +0200, Andrea Ratto wrote: Hello, I am learning Zope 3, following the well known book Web Component Development with Zope 3. The first edition, or the second? It mentions and shows an Interface Browse tab in the ZMI, under /++etc ++site, that I don't have in my instance, along with some other tabs like Tasks or Services. Am I missing some configuration or perhaps something changed with newer zope versions? Something changed with newer Zope versions. The Interface Browser was retired in favour of APIDoc, I think. I don't remember the Tasks or Services tabs, but services as a concept were removed a while ago, in the great component architecture simplification. Now we have only adapters and utilities. Marius Gedminas -- Actually, the Singularity seems rather useful in the entire work avoidance field. I _could_ write up that report now but if I put it off, I may well become a weakly godlike entity, at which point not only will I be able to type faster but my comments will be more on-target.- James Nicoll signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] zope.app.wsgi doesn't register product configurations properly
On Thu, Apr 17, 2008 at 03:35:09PM +0800, Yuan HOng wrote: Tyring out z3c.extfile, I added in zope.conf file the following product configuration section: product-config z3c.extfile storagedir var/filestorage /product-config This doesn't not work as expected when I am using Paste and wsgi. Looking into the code, I think the config function in zope.app.wsgi should be patched by adding: from zope.app.appsetup.product import setProductConfigurations def config(...) ... if options.product_config: setProductConfigurations(options.product_config) ... This is exactly what zope.app.server does when starting up the server. Or is product configuration explicitly not desired with zope.app.wsgi? I think it's a simple bug. Would you mind adding it to the bug tracker? https://launchpad.net/zope3/+bugs Marius Gedminas -- Linux: the operating system with a CLUE... Command Line User Environment. (seen in a posting in comp.software.testing) signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Weird behaviour of ViewPageTemplateFile()
Hi! On Thu, Apr 10, 2008 at 03:22:33PM +0200, Martin J. Laubach wrote: I just stumbled over something that utterly baffles me and hope someone can point out the absolutely obvious to me. Sure. I've got a view defined in a configure.zcml that points to this class: class MyView(BrowserView): def __call__(self): self.pt = ViewPageTemplateFile('empty.pt') data = self.pt() return data That works fine. I'm actually surprised that this works. The usual way in Zope 3 is class MyView(BrowserView): pt = ViewPageTemplateFile('empty.pt') def __call__(self): data = self.pt() return data which can also be shortened to class MyView(BrowserView): __call__ = ViewPageTemplateFile('empty.pt') However, I don't really need pt as instance variable, so I turned it into a local variable: class MyView(BrowserView): def __call__(self): pt = ViewPageTemplateFile('empty.pt') data = pt() return data And that version throws an exception: 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 mjl.example.browser.myform, line 31, in __call__ Module Shared.DC.Scripts.Bindings, line 313, in __call__ Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec Module Shared.DC.Scripts.Bindings, line 1, in ? Module Shared.DC.Scripts.Bindings, line 293, in _getTraverseSubpath This does not look like Zope 3 to me. AttributeError: 'str' object has no attribute 'other' Okay, I know why the code doesn't work, but I don't know why you get this strange Zope 2 error. I'll answer just the first part. Same if I just do the simpler return ViewPageTemplateFile('empty.pt')() of course. I simply do not understand why, what or who does care how I name my variables or where I put them? Please hit me hard with a cluebat. Twice. You have encountered the magic of Python descriptors. Feel free to skip the detailed explanation if you're in a hurry: ViewPageTemplateFile is a descriptor, which is a fancy way of saying object that has a method named __get__. When you access a descriptor from an instance, Python silently calls __get__ for you, so class MyView(BrowserView): pt = ViewPageTemplateFile('empty.pt') def __call__(self): pt = self.pt() is more or less equivalent to class MyView(BrowserView): def __call__(self): pt = ViewPageTemplateFile('empty.pt') pt = pt.__get__(self, ViewPageTemplateFile) ViewPageTemplateFile.__get__ returns a BoundPageTemplate object (it's a bit like the difference between unbound and bound methods) that knows which view it is bound to and can pass it via the view name to your TALES expressions. Now when you invoke ViewPageTemplateFile's __call__, you have to pass the view as the first argument: class MyView(BrowserView): def __call__(self): pt = ViewPageTemplateFile('empty.pt') return pt(self) but when you invoke BoundPageTemplate.__call__, it knows and provides the view argument itself: class MyView(BrowserView): def __call__(self): pt = ViewPageTemplateFile('empty.pt') bound_pt = pt.__get__(self, ViewPageTemplateFile) return bound_pt() which is more or less the same as class MyView(BrowserView): pt = ViewPageTemplateFile('empty.pt') def __call__(self): bound_pt = self.pt return bound_pt() [End of explanation] So, if you really want to use a local variable instead of a class attribute, pass the view itself as the first argument to __call__ class MyView(BrowserView): def __call__(self): pt = ViewPageTemplateFile('empty.pt') data = pt(self) return data HTH, Marius Gedminas -- Anyone can do any amount of work provided it isn't the work he is supposed to be doing at the moment. -- Robert Benchley signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: [Zope-dev] Zope 3.4.0 candidate 1 Released
On Thu, Mar 27, 2008 at 01:38:06PM -0400, Benji York wrote: Kurt Zitze wrote: if you want to raise the userbase of zope, the first and most obvious thing to do is, get a forum running! mailing lists are bu*** and completly out of date. it is max cumbersome to login into your email account to do a post and so on, i think i dont need to enumerate all the disadvantages of a mailing list compared to a forum. forums (and capitalization) are way too cumbersome we should switch to texting each other with our mobile phones how bout a zope3 page on myspace?lol *shudder* Marius Gedminas -- The death rate on Earth is: (computing) One per person. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Cloning interfaces/interface fields - how?
On Wed, Feb 20, 2008 at 01:12:18PM -0500, Stephan Richter wrote: On Wednesday 20 February 2008, Hermann Himmelbauer wrote: Yes, I also use z3c.form, but my problem is that the field has the required flag set to True, which is appropriate for an add/edit form but may not be appropriate for a search form. If I change the required flag on the field level, e.g. in the update() method, the change is permanent in the interface, which is not appropriate. And changing it on the widget level seems to be very complicated, at least, I found no way to do it. Mhh, I think that form fields should support this. Let me look at the code briefly. So yes, you need to change it on the widget level; here is what you have to do in your form: class MyForm(Form): def updateWidgets(self): super(MyForm, self).updateWidgets() self.widgets['prefix.myfield'].required = False Is that too difficult still? Does that actually work? I vaguely seem to remember that I tried this approach once (making the widget not required when the field was required), but some code from the field itself raised validation errors. Of course that could've been a bug in Zope 3.2, fixed since. Marius Gedminas -- Go not unto the Usenet for advice, for you will be told both yea and nay (and quite a few things that just have nothing at all to do with the question). signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] if make check(test) failure, should I make install?
On Wed, Feb 20, 2008 at 09:22:06AM +0800, Fet Biz wrote: What to do next? If the make test results: -- Ran 9471 tests with 4 failures and 9 errors in 12 minutes 31.391 seconds. Tell us what version of Zope you were testing. Tests with errors: testInheritanceAcrossModules (zodbcode.tests.test_class.TestClass) testPersistentSubclass (zodbcode.tests.test_class.TestClass) testSavePersistentSubclass (zodbcode.tests.test_class.TestClass) testClass (zodbcode.tests.test_module.TestModule) testUpdateClass (zodbcode.tests.test_module.TestModule) testClassReload (zodbcode.tests.test_module.TestModuleReload) zodbcode is old, unmaintained and broken. This is not surprising. testAPPE (zope.server.ftp.tests.test_ftpserver.Tests) testSTOR (zope.server.ftp.tests.test_ftpserver.Tests) testSTOR_over (zope.server.ftp.tests.test_ftpserver.Tests) If you don't plan to use Zope's FTP server, ignore these. Tests with failures: checkOldStyleRoot (ZODB.tests.testPersistentMapping.PMTests) This one I'd be worried about. Can you post the full traceback? testPatch (zodbcode.tests.test_patch.TestPatch) testPASS (zope.server.ftp.tests.test_ftpserver.Tests) zodbcode and FTP again. /root/zope3/Zope-3.4.0c1/build/lib.linux-i686-2.4/zope/testing/testrunner-layers-ntd.txt I would like to see this traceback and then fix it. I've sort of volunteered to maintain zope.testing Judging from the pathname, you were testing Zope 3.4.0c1. Let me try it... Marius Gedminas -- Apologies for taking up the bandwidth with the apology. Anything else I can apologise for .. er no can't think of anything, sorry about that. Andy Hunt (Member of British Olympic Apology Squad) signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How do you develop in zope 3?
On Tue, Feb 19, 2008 at 11:22:12AM -0400, [EMAIL PROTECTED] wrote: How do you develop in zope 3? The old-fashioned way, still. I haven't made the jump to eggs yet. So basically, what I do is: # Create a virtual environment $ python2.4 bin/virtual-python.py --prefix=~/zope3/ # install easy_setup $ ~/zope3/bin/python bin/ez_setup.py Check out virtualenv. It's a better virtual-python that automatically installs easy_install for you. # Install zopeproject (of course, all these steps are made just once) $ ~/zope/bin/easy_install zopeproject # make the projects $ ~/zope/bin/zopeproject webdev Marius Gedminas -- Every nonempty totally-disconnected perfect compact metric space is homeomorphic to the Cantor set. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form - how to set single default values from another object?
On Wed, Feb 20, 2008 at 01:10:57PM +0100, Hermann Himmelbauer wrote: Hi, I have here an add form which is based on an interface like this: class IMyObj(Interface): value1 = TextLine() value2 = TextLine() In my add form, I need to display a default value for value2. This default value is stored in another object, however, no default value should be given for value1. I'm desperatingly trying to implement this via z3c.form through various ways, but none seems to work. I am not familiar with z3c.form (being stuck with maintaining a project based on Zope 3.2 means you don't get to play with new toys). With zope.formlib you could solve this by passing an initial data dict to the setUpWidgets call. Doesn't z3c.form have something like that? You mentioned that you looked at the source where the widgets were updated. I suggest you look at the place where the widgets are created initialized. Marius Gedminas -- Nothing ever goes missing that they don't look at me, ever since that time I lost my horse. As if that could be helped. He was white and it was snowing, what did they expect? -- Dolorous Edd in A Storm of Swords by George R. R. Martin signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Error in testbrowser documentation
On Thu, Feb 14, 2008 at 05:32:31AM +0100, Encolpe Degoute wrote: Hello, I obtain write access last week. Can someone review my first commit (83809) ? Looking at http://svn.zope.org/?view=revrev=83809 now... No, that seems wrong. getLink('text', index=42) is useful functionality and it works perfectly. It's the IBrowser.getLink that lags behind and should be updated. I'll do it. Encolpe Degoute a écrit : Hello, On http://pypi.python.org/pypi/zope.testbrowser you can read: When a link text matches more than one link, by default the first one is chosen. You can, however, specify the index of the link and thus retrieve a later matching link: browser.getLink('Link Text') Link text='Link Text' ... browser.getLink('Link Text', index=1) Link text='Link Text with Whitespace Normalization (and parens)' ... But now the getLink signature is like this: def getLink(self, text=None, url=None, id=None) In zope.testbrowser.interfaces.IBrowser, yes. In zope.testbrowser.browser.Browser, no: def getLink(self, text=None, url=None, id=None, index=0): See zope.testbrowser.interfaces.IBrowser Browser was last modified in rev 71429, IBrowser was last modified in rev 40065. I guess the person who added the index argument forgot to update the interface definition. Fixed now. Marius Gedminas -- The irony is that Bill Gates claims to be making a stable operating system and Linus Torvalds claims to be trying to take over the world. -- seen on the net signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3ext
On Wed, Feb 13, 2008 at 11:29:39AM +0530, Baiju M wrote: Installing z3ext CMS was very easy. I have few suggestions. 1. I think your CMS application can be renamed to something else. Instead of using 'z3ext.portal' as the main entry point, a non-namespace package would be better. (z3extcms, z3extportal or something like that). By the way, what does z3ext mean? I see ext, I have flashbacks to Zope 2 ExternalFile or ExternalEditor products. Marius Gedminas -- ...Unix, MS-DOS, and Windows NT (also known as the Good, the Bad, and the Ugly). -- Matt Welsh signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Datetime Error
Hi, On Sat, Feb 09, 2008 at 08:45:00PM -0200, Ronaldo Z. Afonso wrote: I'm just installing Zope-3.3.1 with Python-2.2.4 and make check is raising the following error: Failure in test show (zope.app.file.browser.file.FileView) Failed doctest test for zope.app.file.browser.file.FileView.show File /usr/src/Zope-3.3.1/build/lib.linux-i686-2.4/zope/app/file/browser/file.py, line 39, in show -- File /usr/src/Zope-3.3.1/build/lib.linux-i686-2.4/zope/app/file/browser/file.py, line 79, in zope.app.file.browser.file.FileView.show Failed example: datetime.fromtimestamp(zope.datetime.time( request.response.getHeader('Last-Modified'))) Expected: datetime.datetime(2006, 1, 1, 0, 0) Got: datetime.datetime(2006, 1, 1, 1, 0) Can anybody help me with this? It looks like a timezone error to me. I cannot reproduce it with Zope 3 trunk. Perhaps it was fixed in a later version? I wouldn't worry too much. Marius Gedminas -- If the ancients were right and to think is to exist, does Microsoft exist? signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Slow response time with zope3
On Tue, Feb 05, 2008 at 02:41:56PM +0100, Jeremy Cook wrote: I have been struggling to understand why my zope3 site has a high latency (ie initial response time is slow). Bandwidth seems to be adequate, it just seems that it can take several seconds from clicking on a link, to actually seeing that my server is awake and responding. The server has no load or anything on it. I even started ZEO but see little improvement. Usually the first request is slower than the rest because the ZODB object caches are empty and it has to load everything from disk (or ZEO). The strange thing is that when I click a link in 2 browsers on 2 different hosts at the same time (right hand on desktop, lefthand on laptop) I seem to get a faster response from both. I have tried both with and without apache forwarding requests and dont seem to see any difference. The problems seems to be something to do with zope3 taking time to initially respond. Any ideas where to look or how to optimise anyone? Have you tried profiling that first request? You could, e.g. easy_install profilehooks (http://mg.pov.lt/profilehooks) and wrap the publish function with the @profile decorator, then hit ^C after Zope 3 serves the first request. Marius Gedminas -- (Pdb) operationerr.w_value.w_value.w_value.w_value.w_value.w_value pypy.interpreter.executioncontext.OperationError instance at 0x5eee30 -- one of the clearer PyPy debugging sessions (seen in Michael Hudson's sig) signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: [Zope-dev] Zope 3.4.0 candidate 1 Released
On Fri, Feb 01, 2008 at 05:26:14PM -0500, Chris McDonough wrote: Marius Gedminas wrote: On Fri, Feb 01, 2008 at 11:06:48AM -0500, Chris McDonough wrote: I typed four more paragraphs full of markety stuff here but deleted them. *cheers* I'll take that as STFU ;-) It wasn't intended that way. I know from personal experience how hard it is to suppress rants I've written. I was just applauding your self-control. Uhh, not that I'm implying your markety stuff was a rant. I'll shut up now. :-) Marius Gedminas -- Place mark here -[ ]- if you want a dirty monitor. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: [Zope-dev] Zope 3.4.0 candidate 1 Released
On Fri, Feb 01, 2008 at 11:06:48AM -0500, Chris McDonough wrote: I typed four more paragraphs full of markety stuff here but deleted them. *cheers* Marius Gedminas -- The clothes have no emperor. -- C.A.R. Hoare, commenting on ADA. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Literal double quoted string within single quoted attribute in ZPT
On Sun, Jan 27, 2008 at 01:08:09PM -0500, Stephan Richter wrote: On Monday 17 December 2007, David Pratt wrote: Hi. Is there solution for create a single quoted attribute using tal:attributes containing literal double quoted items. I am using a python method for generating the string. I understand structure will unquote but it does not work with an attribute. Well, attributes must always be quoted based on the XML spec, right. Otherwise TAL could produce invalid XML. What does the spec actually say about this? XML 1.0 spec says this: Attribute ::= Name Eq AttValue AttValue ::= '' ([^] | Reference)* '' | ' ([^'] | Reference)* ' In other words, you can use either double quotes or single quotes. References: http://www.w3.org/TR/REC-xml/#dt-stag http://www.w3.org/TR/REC-xml/#NT-AttValue XML 1.1 spec says the same: http://www.w3.org/TR/xml11/#dt-stag http://www.w3.org/TR/xml11/#NT-AttValue HTML 4 spec agrees: http://www.w3.org/TR/html401/intro/sgmltut.html#h-3.2.2 I see there is a new z3c.tal package based on lxml. Will I have to go as far as customizing tal to do this? I realize this may be best on the zpt list but it it rarely if ever used these days. Many thanks. Well, if the XML specification allows for your output, we could consider it not working this way a bug. Why? A missing feature, surely, but why would generating attr=quot; instead of attr='' be considered a bug? However, it would make the code much more complicated, I think (unless we support structure as well in this case). Marius Gedminas -- Despite all appearances, your boss is a thinking, feeling, human being. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Instance - increase number of threads
On Mon, Jan 28, 2008 at 08:07:48PM +0200, Marius Gedminas wrote: On Mon, Jan 28, 2008 at 10:47:58AM +0100, Meier Daniel wrote: Hi there, Newbie question: Where can I increase the number of threads for a zope3 instance? Edit the zope.conf and add threads 5 for whatever value of 5 you wish (the default is 4, IIRC). Note that ZODB has per-thread object caches, so increasing the number of threads might increase the server memory usage. Of course I meant will increase, not might increase. Marius Gedminas -- Do not meddle in the affairs of sysadmins, they are quick to anger and have no need for subtlety. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Instance - increase number of threads
On Mon, Jan 28, 2008 at 10:47:58AM +0100, Meier Daniel wrote: Hi there, Newbie question: Where can I increase the number of threads for a zope3 instance? Edit the zope.conf and add threads 5 for whatever value of 5 you wish (the default is 4, IIRC). Note that ZODB has per-thread object caches, so increasing the number of threads might increase the server memory usage. PLEASE NOTE This message may contain confidential, proprietary, or legally privileged snip These are *annoying* Marius Gedminas -- Writing setattr hooks properly is a black art. Writing persistent setattr hooks is more like hearding bees blindfolded... -- Casey Duncan signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: Fwd: [Zope3-Users] z3c-form meta.zcml error
On Wed, Jan 23, 2008 at 06:40:08PM -0500, Stephan Richter wrote: On Wednesday 23 January 2008, Martijn Pieters wrote: On Jan 23, 2008 10:12 AM, Peter Koppatz [EMAIL PROTECTED] wrote: What has changed between 1.7.0 and 1.7.2? ls -al | wc -l 1.7.0 -- 76 1.7. 2 -- 47 there are no *-txt , *.zcml anymore! Someone must have built the release tarball from a fresh SVN export; setup.py does not include txt and zcml files and such by default when building a release tarball, while a development egg would include those. In other words, the maintainer of z3c.form (and I mean YOU, Stephan) should add a MANIFEST.in with the lines global-include *.txt and global-include *.zcml in it and re-roll the release. The problem are faulty ZIP files that do not open correctly in Linux. The ZCML and Text files are there, but are not extracted correctly by setuptools. When we encountered this problem during the Foliage sprint, the problem was not the use of .zip instead of .tar.gz, but a manifest with \r\n line endings inside the archive. setuptools did rstrip('\n') on the lines and then tried to copy nonexistent files with a names that ended in '\r'. The bug was fixed on the same day in a newer setuptools 0.6 prerelease. Marius Gedminas -- Funny off-topic messages are always on-topic. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] zmi menu error
On Mon, Jan 14, 2008 at 06:01:27PM +0100, Christophe Combelles wrote: john saponara a écrit : I get reasonable edit screens for my car and driver classes when I use a url like limoService/car1/edit.html but when I try to add the edit screens as zmi menu entries I get an error: File C:\Python24\Lib\site-packages\zope\app\publisher\browser\menu.py, line 62, in getMenuItems result = [(ifaces.index(item._for or Interface), ValueError: list.index(x): x not in list It looks like there is a class instead of an interface somewhere. Maybe try to register your CarView and DriverView for ICar and IDriver interfaces instead of Car and Driver classes. That's right. This is a Zope 3 bug that's been fixed in SVN: http://svn.zope.org/?rev=79035view=rev Marius Gedminas -- Cheap, Fast, Good -- pick two. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Copy / Move ZODB Content From Dev Zope3Instance to Production Zope3 Instance?
On Tue, Jan 22, 2008 at 12:54:52PM -0500, Jeremy Roberts wrote: It's true, I am looking for an easy way to move both content space objects and software space objects between ZODB storages. I'd considered simply copying Data.fs files but I learned that there is a small but possible risk of making a copy while a transaction is incomplete, risking data integrity. My understanding is that this is perfectly safe: ZODB will ignore the incomplete transaction record at the end of the Data.fs, so you'll get a snapshot of earlier state. If you try to make any changes, ZODB will overwrite that fragment with a new transaction record and truncate the Data.fs. (If my understanding is incorrect, I'd like someone to thwack me with a cluebat.) I then stumbled upon the repozo.py script which can safely handle making copies of Data.fs files while the database is in use. Unfortunately it doesn't seemed to be included in my linux Zope 3.3.1 install. It lives in ZODB/scripts in the source tree. Or, alternatively, here: svn://svn.zope.org/repos/main/ZODB/trunk/src/ZODB/scripts/repozo.py I am only just starting to play with eggs, but I did find that the repozo.py script is packaged with a recent ZODB3-3.8.0b3 egg install. Even so, this approach (replicating entire Data.fs files) affords no control over the objects that are transfered between storages - it's all or nothing. This is not a deal breaker for many types of development situations, but I anticipate finding myself in other types of situations where it would be useful to be able to be able to transfer a few objects here and a few objects there - even if it required some premeditation on my part in terms of the z3 components available to me in the instances to make it possible. I miss Zope2-style .zexp files every now and then. My needs stem from my desire to provide the client with a dev instance, a production instance, and a sane controlled process for moving not only file system code (easy: darcs), but also content objects in ZODB or ZEO storage between the instances. fssync would've solved that problem (and more -- it would let you keep your data objects in a revision control system). You could probably cobble some solution from zc.copy. PS Is there a way to mount multiple Data.fs files in a Zope3 instance via configuration? I've only seen it done with code in the debugger prompt. I have found description of how to acheive this with configuration in Z2 (mount-point directive in zope.conf's zodb element), but not Z3... If I had that capability, the only problem left for me would be the reference vs deep copy problem which occurs when using copy operations through the ZMI between storages. zope.location.pickling.locationCopy and zc.copy solve that problem. (A hopefully unrelated accident: I used Zope 2.9 ZMI to *cut* and paste an object across storages -- from a TemporaryStorage to a FileStorage. The next day I discovered that my object kept some reference to TemporaryStorage objects that got garbage-collected in the meantime. Oops.) I had a friend recently point me towards the python __deepcopy__ api which I haven't looked at yet, and zc.copy. Do look at zc.copy (I just did). It works by (smartly) making a pickle that includes some objects and references other objects, and then unpickling it in the next breath. What you need to do to get Zope2-style object import/export is take that logic, verify that all objects are included in the pickle and there are no external references (other than a single __parent__ reference from the original object you're exporting, which you should convert to None before pickling) and then write that pickle to a file (or return it as the response body to a GET request). On the other system just unpickle and stick it in a container somewhere. But beware of the big can of worms you're opening: - pickles can execute arbitrary code, so be sure you only unpickle strings received from trusted sources - ZODB schema is implicit and not explicit, so make sure you're not letting your users break your system by importing objects with incompatible attributes (from earlier/later DB generations). - if you use catalogs or indexes, make sure you'll update them properly after importing a pickled bundle of objects - in general, be very wary of direct references between objects that may cross the export boundaries - beware of objects providing ILocation that aren't properly attached (i.e. have None as the __parent__) -- these will never be copied/exported In general, I'd say it's impossible to provide reliable object copying (or import/export) without knowing (or limiting) what your application stores in the DB. Marius Gedminas -- No sane person should use frame buffers if they have the choice. -- Linus Torvalds on lkml signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3
Re: [Zope3-Users] Transforming formlib field data on save
On Tue, Jan 22, 2008 at 12:28:22PM +1300, andrew wrote: I'm struggling with how to transform some input data into an object property using an auto-generated formlib edit form, schema, etc. I see how the simple flow works, i.e.: 1. Create a schema 2. Build the form from the schema 3. Use applyChanges to update context object properties with input data But what if I want to do something other than just set an object property ? In this case, I'm working on a content page editor where the underlying data is stored as the content of a page template, so I want to be able to map a form content field to / from the page template content instead of a property on the page template. You can always write a custom action that stores the data wherever you want. class MyPage(form.EditForm): form_fields = form.Fields(...) actions = form.Actions() # remove the default Apply action # and replace it with a custom one: @form.action(_(Apply), condition=form.haveInputWidgets) def apply_action(self, action, data): self.context.pt_edit(data['content']) self.status = _('Saved changes') You can also combine manual actions with formlib's applyChanges, if you want to -- just make sure you remove those fields you don't want formlib to process from the data dict before you call applyChanges. @form.action(_(Apply), condition=form.haveInputWidgets) def apply_action(self, action, data): self.context.pt_edit(data.pop('content')) form.applyChanges(self.context, self.form_fields, data) self.status = _('Saved changes') I'm leaving some details (such as sending IObjectModified events, or not doing anything if you haven't actually changed any of the values) as an exercise for the reader. Read the zope.formlib.form source code for examples of that. Anyone got a simple example of how to go about this ? I'm guessing it's something to do with providing an adapter on the content field so I can override the get/set methods of the field, but I'm stuck at that point. If you want to do it via adapters, here you go: class ITemplateSource(Interface): source = SourceText(title=uTemplate source) class TemplateSource(object): adapts(IMyTemplateInterface) provides(ITemplateSource) def __init__(self, context): self.context = context def _getSource(self): return self.context.read() def _setSource(self, new_source) self.context.pt_edit(new_source, 'text/html') source = property(_getSource, _setSource) # Make sure to provideAdapter(TemplateSource) or the equivalent in # ZCML for the following to work: class MyPage(form.EditForm): form_fields = form.Fields(..., ITemplateSource) Since ITemplateSource.source is defined in the ITemplateSource interface, formlib will try to adapt your context to ITemplateSource. Disclaimer: all code in this email is untested. HTH, Marius Gedminas -- An algorithm must be seen to be believed. -- D.E. Knuth signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] InvalidObjectReference error
On Mon, Jan 21, 2008 at 11:32:13AM +0100, Frank Burkhardt wrote: my zope 3 server contains a modified principal folder which is updated on a regular basis via XMLRPC. This usually works fine but after some days, the update process makes the zope server raise this error: InvalidObjectReference: Attempt to store a reference to an object from a separate connection to the same database or multidatabase Restarting the server fixes the problem for some days. I'm quite sure, this is some bug in my update code but I don't really know, what I've to look for. Does anyone have an idea? I suspect you're abusing global variables. Zope has one ZODB connection per thread. Somehow an object loaded/stored in one thread is being referenced from a different thread. The most common way to pass data between threads is to use globals (or accidental shared state, e.g. class attributes, or mutable default method arguments). Marius Gedminas -- Westheimer's Discovery: A couple of months in the laboratory can frequently save a couple of hours in the library. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Status of zsync
On Sat, Jan 19, 2008 at 04:46:47PM +0100, Achim Domma wrote: I'm interested in zsync, but cannot find much information via google. I'm using Zope 3.4b2 and there are docs for zsync but the tool seems not to be included!? It was never fully implemented. I guess people forgot to remove the docs when they removed the nonfunctional prototype from the source tree. I'm developing a small zope app and I want to sync my ZPT pages with the filesystem. Or is there another way to develop ZPT pages via filesystem using a text editor like vim? If you're developing a Zope 3 app, then all of your application, including page templates, should be developed on the filesystem. Use ViewPageTemplateFile for templates instead of ZPTPage. Marius Gedminas -- Some people around here wouldn't recognize subtlety if it hit them on the head. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] ImportError running bin/zopectl run myScript.py
On Thu, Jan 17, 2008 at 05:46:56PM +0100, Achim Domma wrote: I try to run a script on my zope instance via bin/zopectl run myScript.py. I get the following error: Traceback (most recent call last): File /Users/domma/develop/zope/demo/bin/scriptzope, line 22, in ? import paths ImportError: No module named paths I cannot find a paths.py on my system. Any hint what I'm doing wrong? I haven't seen any reply to this, so I'll bite, even though I've never used bin/zopectl run in my life. It appears that you've found a bug. There's no paths.py on my system either. The bin/debugzope script doesn't have these two lines, so I suggest you remove them: import paths paths.addPackagePaths() I've filed a bug: https://bugs.launchpad.net/zope3/+bug/185219 Marius Gedminas -- Get a life? Well, once I nearly found one, but the link was broken. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] public view on a private object
Hi, On Wed, Dec 19, 2007 at 08:32:02PM +0100, Lorenzo Gil Sanchez wrote: snip require permission=zope.ManageContent interface=.interfaces.IMyContent / ... page for=mypackage.interfaces.IMyContent name=welcome.html class=.views.IndexView permission=zope.View template=index.pt title=Index menu=zmi_views / ... As you can see there is a contradiction here: the view is 'public' but the object is 'private'. I see it now but it tooked my a while to discover it. Obviously I have a bunch of content types, packages and configure.zcml files so it was not so easy. So the real problem in my opinion is how Zope helps us to discover this kind of configuration bugs. All I have was an 'Internal Server Error' (500) and a stack trace like this: --- exception caught here --- File /home/lgs/Python-2.4.4/Zope-3.3.1/lib/python/twisted/web2/wsgi.py, line 139, in run result = self.application(self.environment, self.startWSGIResponse) File /home/lgs/Python-2.4.4/Zope-3.3.1/lib/python/zope/app/wsgi/__init__.py, line 55, in __call__ request = publish(request, handle_errors=handle_errors) File /home/lgs/Python-2.4.4/Zope-3.3.1/lib/python/zope/publisher/publish.py, line 141, in publish publication.handleException( File /home/lgs/Python-2.4.4/Zope-3.3.1/lib/python/zope/app/publication/zopepublication.py, line 261, in handleException self._logErrorWithErrorReportingUtility(object, request, exc_info) File /home/lgs/Python-2.4.4/Zope-3.3.1/lib/python/zope/app/publication/zopepublication.py, line 215, in _logErrorWithErrorReportingUtility 'error reporting utility') File /home/lgs/Python-2.4.4/Zope-3.3.1/lib/python/zope/app/publication/zopepublication.py, line 384, in beginErrorHandlingTransaction self.annotateTransaction(txn, request, ob) File /home/lgs/Python-2.4.4/Zope-3.3.1/lib/python/zope/app/publication/http.py, line 55, in annotateTransaction txn = super(BaseHTTPPublication, self).annotateTransaction( File /home/lgs/Python-2.4.4/Zope-3.3.1/lib/python/zope/app/publication/zopepublication.py, line 197, in annotateTransaction path = locatable.getPath() File /home/lgs/Python-2.4.4/Zope-3.3.1/lib/python/zope/location/traversing.py, line 147, in getPath path.append(context.__name__) zope.security.interfaces.Unauthorized: (mypackage.mycontent.MyContent object at 0xa9e3aec, '__name__', 'zope.ManageContent') Some questions arises: - Why didn't it pop up the typical http challengue asking me for credentials when it discovered that I was trying to access an object and I didn't have the appropiate permissions? It appears to be a bug. You're not seeing the original exception, but a second one that happened when Zope was trying to log the original one. I suppose ZopePublication.annotateTransaction should removeSecurityProxy() from ob before adapting it to IPhysicallyLocatable. - Why do I have to define permissions for a view if I already configured the same permissions for the class? The view should always have more restrictive permissions that the content type class or is there any use case for the opposite? The view doesn't know the permission of the content class. Note that your view is registered on IMyContent, and not on MyContent directly. You might register more than one content class implementing IMyContent, and register different permissions. Another thing -- you might protect different attributes with different permissions, and the view directive cannot be smart enough to analyse all your source code and page templates to see which of those content attributes you want to use in this particular view. - Is the above stack trace clear enough for experienced zope3 developers so they can quickly spot the problem or is it just me that I couldn't figure it out for a long time? I've seen before the sort of tracebacks left by an exception that happens when Zope is trying to render an exception view. The exception caught here seems familiar, and self._logErrorWithErrorReportingUtility in the traceback is a big hint. HTH, Marius Gedminas -- We don't really understand it, so we'll give it to the programmers. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] TAL expression and ascii
On Fri, Dec 14, 2007 at 01:20:52AM +0100, Justin Fletcher wrote: I am trying to migrate some data into the ZODB. I am storing this data in a string, and later presenting the data in a ZPT similar to this: span tal:replace=context/content / This works fine for text that does not have any characters outside of the ascii range, but for text that does I receive this error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3283: ordinal not in range(128) You are mixing non-ASCII str objects with Unicode strings somewhere. The characters are typically things like what the HTML code eacute; would generate, but it is a fairly significant amount of text so I am unsure specifically what characters are causing the problem. Any that are non-ASCII. My understanding is that Zope3 strings are Unicode so I don't understand why the ascii range is a restriction. Shouldn't these characters be stored and presented transparently? There's no magic. Zope 3 strings are Unicode is a convention, and Zope makes it easy to follow by decoding all HTTP request strings into Unicode objects. If you're migrating existing non-Unicode data into ZODB with a simple Python script, you'll have to take care of converting your binary strings to Unicode yourself. Am I misunderstanding something or doing something wrong? I think so. If you could show us how you're migrating some data into the ZODB, we could give you more advice. Regards, Marius Gedminas -- lg_PC.gigacharset (lg = little green men language, PC = proxima centauri) -- Markus Kuhn provides an example of a locale signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Why all of the names of the interfaces in the zope3 are the same 'InterfaceClass'?
On Wed, Dec 12, 2007 at 02:06:08PM +0800, 曹星明 wrote: I'm a newbie to the zope 3. Today I was at a loss because I found all of the names of the interfaces are the same 'InterfaceClass'. from zope.interface.interface import InterfaceClass from zope.component import interfaces for x in dir(interfaces): obj = getattr(m,x) if isinstance(obj, InterfaceClass): obj.__class__.__name__ InterfaceClass InterfaceClass .. .. InterfaceClass InterfaceClass who can tell me why? Because interfaces are objects of class InterfaceClass. How can I get the real name of the interface? Forget the __class__. for x in dir(interfaces): ... obj = getattr(interfaces, x) ... if isinstance(obj, InterfaceClass): ... obj.__name__ I'd also suggest using IInterface instead of InterfaceClass to distinguish interfaces from other objects: from zope.interface.interfaces import IInterface for x in sorted(dir(interfaces)): ... obj = getattr(interfaces, x) ... if IInterface.providedBy(obj): ... obj.__name__ HTH, Marius Gedminas -- C is for Cookies. Perl is even better for Cookies. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Introducing z3c.form - widget snippets
On Fri, Jul 13, 2007 at 01:53:04PM -0400, Stephan Richter wrote: On Friday 13 July 2007 13:34, Marius Gedminas wrote: tal:block define=widget view/widgets/mywidget Almost. You need a nocall: there Not true, I think. :-) z3c.form widgets are not callable; they only have a render() method. Aargh. You know, you're breaking people's assumptions about what form and widgets are and how they behave by introducing new ones that behave differently but are called the same. It's the first time I see 'macro:' in TALES expressions. Interesting. See z3c.macro. It is an attempt to make the use of macros simpler. Do you blog? A Planet Zope 3 with people boasting about great new packages they created would be a good way to familiarize with the new great packages. (A mailing list is also full of discussions and questions, and due to its higher volume, harder to track.) Marius Gedminas -- Cool. Does it also recode ISO10646-1 pcf files into the funny permutations and subsets used a long time ago in a galaxy far far away on the planets Isolatinus XV and Koiruski VIII ... -- Markus Kuhn inquires about libXft signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Introducing z3c.form - widget snippets
On Fri, Jul 13, 2007 at 12:42:55PM -0400, Stephan Richter wrote: So, in my snippet-way, it looks like that for every widget: span replace=structure view/widgets/mywidget/snippets/foo / Too many slashes! My brain is exploding. And in the macro-style? Perhaps like that? span metal:use-macro=snippets/foo span metal:fill-slot=snippet span replace=structure view/widgets/mywidget/render / /span /span This is overcomplicated. If I remember correctly, you can do: tal:block define=widget view/widgets/mywidget Almost. You need a nocall: there tal:block define=widget nocall:view/widgets/mywidget span metal:use-macro=macro:snippet / It's the first time I see 'macro:' in TALES expressions. Interesting. /tal:block Also, if you do not like macros, you can register simple views to have: span replace=structure view/widgets/mywidget/foo / For me the cost of the snippet is too high: 1. It introduces a new pattern for cases that are well-covered otherwise. 2. It requires a new directive. But as I said before, you should publish your work and see how people like it. FWIW I'm with Stephan on this one. Too many new concepts. Marius Gedminas -- A computer without Windows 9x is like a fish without a bicycle. -- With apologies to Gloria Steinem signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] mkzopeapp and zope.publisher/zope.exceptions incompatibility?
import HTTPRequest, HTTPResponse File /home/mg/src/playing-with-mkzopeapp/lib/python2.5/zope.publisher-3.4.0b2-py2.5.egg/zope/publisher/http.py, line 48, in module from zope.publisher.base import BaseRequest, BaseResponse File /home/mg/src/playing-with-mkzopeapp/lib/python2.5/zope.publisher-3.4.0b2-py2.5.egg/zope/publisher/base.py, line 27, in module from zope.exceptions.exceptionformatter import print_exception ImportError: cannot import name print_exception (Isn't the size of the traceback scary? Reminds me of Java-land somewhat.) zope.exceptions 3.2.0.2-py2.5 doesn't define a print_exception function which zope-publisher 3.4.0b2-py2.5 expects. Could this be fixed with a versioned dependency in zope-publisher's setup.py? Is it normal to see a zope.foo package versioned 3.2.something, or did setuptools download an obsolete version from somewhere? I also see zope.thread version in the 3.3 range, while most of the other zope eggs are in the 3.4 range. A few are in the 3.5 version range. Marius Gedminas -- Always forgive your enemies. Nothing annoys them more. -- Oscar Wilde signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Getting view result from Python
On Wed, Jun 27, 2007 at 04:59:07PM +0200, Thierry Florac wrote: Le mercredi 27 juin 2007 à 14:31 +0200, Christophe Combelles a écrit : Thierry Florac a écrit : I'd like to get a view output from some Python code. Actually, I don't have any problem if I use a page template with a simple tal:x content=structure context/@@viewname / expression and return self.template() in Python. But it should certainly be cleaner and less expensive to get view output directly from Python code, which I don't actually manage to do... It depends on what you call a view, if this is a BrowserPage, you have a __call__ method that returns the output. so just call your view(). If this is a BrowserView, there is no __call__ because a BrowserView is not intended to be published as is. But you can have any method that returns HTML. If you use getMultiAdapter to get the view, all these differences are hidden and you can call the view to get its output. If this is a Viewlet or a ContentProvider, there is a render method that returns the output. (provided you first call the update method) Then it's not really a view, is it? ;-) In fact it's a little bit more complicated... What I have at first is a BrowserPage view, which is generally called from a page template with context/@@viewname syntax, without any problem. But I need also to be able to get the same view output from a JSON call, so that I can update a little bit of HTML code dynamically. I don't have any problem when defining a template with the same syntax. But if I call in python : view = zapi.getMultiAdapter((myContext,myRequest), Interface, name=u'viewname') This should work. You don't have to pass Interface explicitly, by the way, view = getMultiAdapter((context, request), name='...') will work as well. I receive an error message : __init__() takes at least 3 arguments (1 given) I don't believe you :-) Can you show the full traceback? getMultiAdapter definitely passes the context tuple to the adapter's __init__. There must be some other piece of code that fails for you. So zapi.getMultiAdapter creates the view, but how can I initialize it with it's required parameters (context and request) ? getMultiAdapter does that. I speak from personal experience. Marius Gedminas -- ...the only place for 63,000 bugs is a rain forest signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Calling a view in a doc test
On Mon, Jun 18, 2007 at 10:14:14PM +0200, Florian Lindner wrote: Am Dienstag, 5. Juni 2007 schrieb Marius Gedminas: I would suggest that you remove everything and keep just def blogSetUp(test): zope.testing.module.setUp(test, 'Blog.doctest') it worked after I've added the line above. That's good. (I've no idea what zope.testing.module.setUp does). setup.placelessSetUp() setup.setUpTraversal() def blogTearDown(test): setup.placelessTearDown() and this is my README.txt containing the test: context = MyBlog You may want to actually create the object: context = MyBlog() MyBlog is the instance. That's confusing. In Python it is customary to have class names start with a captial letter, and function/variable names start with a lowercase letter. (Factory functions, whose primary purpose is to create new objects, are also sometimes named with a starting capital letter.) Regards, Marius Gedminas -- Any time somebody tells you that you shouldn't do something because it's unprofessional, you know that they've run out of real arguments. -- Joel Spolski signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z3c.form and subforms in an AddForm?
On Fri, Jun 15, 2007 at 10:52:24AM -0700, gnosis wrote: I've been trying out the new z3c form package and like what I see. I am having problems getting a subform in an AddForm though. The subform.txt covers EditForms where you have a context object to work on, in an AddForm the context is the underlying IContainer. Really? Usually in Zope 3 (zope.app.form or zope.formlib) the context of an add form is the IAdding view. To get the container you have to use self.context.context. Here is what I have, using formdemo examples as the basis. Any help on getting this to work is greatly appreciated. IRestaurant with address attribute using schema.Object holding an IAddress. browser/restaurant.py class RestaurantAddForm(AddFormLayoutSupport, form.AddForm): Add form template = None layout = None contentName = None label = u'Add Restaurant' fields = field.Fields(IRestaurant).omit('address') def update(self): self.address = AddressAddForm(self.context.address, self.request) ## Problem area You did not say what the problem was. I suspect that you ought to have a simple subform here (nor an add form, since you're not going to add the address object into a container -- you're going to set it on an attribute; also not an edit form since the address object doesn't exist yet). I'm not familiar with z3c.form, but I'm betting that it follows the same conventions as the older Zope 3 form modules. self.address.update() super(RestaurantAddForm, self).update() def create(self, data): r = Restaurant() r.name = data['name'] r.description = data['description'] r.address = data['address'] return r def add(self, object): self._name = object.name self.context[self._name] = object return object def nextURL(self): return absoluteURL(self.context[self._name], self.request) browser/address.py class AddressAddForm(AddFormLayoutSupport, form.AddForm): template = None layout = None contentName = None label = u'Address' fields = field.Fields(IAddress) prefix = u'address' browser/configure.zcml !-- Restaurant Add Form -- z3c:pagelet name=addRestaurant.html for=zope.app.folder.interfaces.IFolder class=.restaurant.RestaurantAddForm layer=metrod.app.layer.IMetroDBrowserLayer permission=zope.Public / z3c:template template=restaurant.pt for=.restaurant.RestaurantAddForm layer=metrod.app.layer.IMetroDBrowserLayer / !-- Address Add Form -- z3c:pagelet name=addAddress.html for=metrod.restaurant.interfaces.IAddress class=.address.AddressAddForm layer=metrod.app.layer.IMetroDBrowserLayer permission=zope.Public / z3c:template template=address.pt for=.address.AddressAddForm layer=metrod.app.layer.IMetroDBrowserLayer / Marius Gedminas -- Despite all appearances, your boss is a thinking, feeling, human being. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Evolution of ZoDB after changing python modules structure (moving content classes to another module)
On Sun, Jun 10, 2007 at 09:14:24AM +0200, Aleksander Kowalczyk wrote: On 6/8/07, Alek Kowalczyk [EMAIL PROTECTED] wrote: Alek Kowalczyk [EMAIL PROTECTED] writes: Hi, I moved my content class from mypackage.mymodule.MyContentClass into mypackage.mysubpackage.mymodule.MyContentClass. But when started Zope and went to visit an object I have previously created (of MyContentClass), I get: ComponentLookupError: ((persistent broken mypackage.mymodule.MyContentClass instance '\x00\x00\x00\x00\x00\x00\x02q', zope.publisher.browser.BrowserRequest instance I found a quite well working solution on http://mail.zope.org/pipermail/zodb-dev/2006-September/010382.html There was only one issue: this solution assumes that we have given a DB, while Zope evolve method receives already open connection. Unfortunately classFactory from DB is cached in Connection's private fields in constructor. Because of that I could not assign my custom 'renaming' class factory using: def evolve(context): #won't work! context.connection.db().classFactory = myClassFactory Instead I had to do some dirty private fields substitution in Connection's ObjectReader: def evolve(context): #this works nice context.connection._reader._factory = myClassFactory I shouldn't announce success too early. The solution works but only during first Zope run (i.e just after evolving the schema). Although classFactory returns proper class during evolve, the new class name is not saved in ZoDB, so after next unghosting object get old class names again. Here is my evolve script. I really don't know what more should I do to make Zope/ZoDB write the new class name in ZoDB. Can someone help me a bit... :) ? def convertingClassFactory(connection, moduleName, globalName): #convert class name to new one and return the class object def evolve(context): #dirty hack to substitute classFactory context.connection._reader._factory = convertingClassFactory root = context.connection.root().get(ZopePublication.root_name, None) for object in findObjectsMatching(root, lambda x: True): if hasattr(object, '_p_activate'): object._p_activate() object._p_changed = True Note that findObjectMatching will not return all the persistent objects, but only those that are directly placed in containers. Other objects (e.g. ones stored in annotations) refer to your old classes, you'll need to do more. Stephan Richter once figured out how to do that for SchoolTool, IIRC it involved looping through all OIDs in the database and marking them as _p_changed. Marius Gedminas -- Whom the gods would destroy, they first teach BASIC. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope3 profiler ?
On Tue, Jun 12, 2007 at 06:39:57PM +0200, Thierry Florac wrote: I'm looking for a simple solution to profile a Zope3 application, some kind of 'ZopeProfiler' product which was available for Zope2. That would be a nice thing to have. Any link or advise would be welcome... So far the easiest way I've found is to use my @profile adapter on the view's __call__: from profilehooks import profile class MyViewClass(BrowserView): template = ViewPageTemplateFile('templates/mytemplate.pt') @profile(immediate=True) # if you specify immediate, each request will print the profile to stdout # if you don't, you'll get an aggregate profile when you stop the server def __call__(self): return self.template() You can find profilehooks.py (MIT licence) with some usage examples at http://mg.pov.lt/blog/profiling.html You might also be interested in http://mg.pov.lt/blog/benchmarking-zope3-apps.html Marius Gedminas -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Utility for removing unneeded import statements
On Tue, Jun 05, 2007 at 12:59:32PM +0200, Adam Groszer wrote: Tuesday, June 5, 2007, 12:50:40 PM, Hermann wrote: During development and especially refactoring, I'm often confronted with cleaning up import statements. Missing imports are reported by Python, however, unneeded imports are not. I don't know if unneded imports are a performance issue, nevertheless it probably makes sense to clean them up from time to time. Therefore I wonder if there's some tool that can automatically check if an import is needed or not. Probably this is easy to write, but perhaps somebody has already done so? What would be nice, would also be a tool that crawls through a python package and also checks any missing imports and reports all of them at once. When I refactor code, I often have to restart zope3 over and over, only due to missing import statements. I have a quick-and-dirty python script that does exactly this. It cannot handle the new Zope import style which is import somepackage.somesubpackage from somepackage import otherpackage import somepackage.otherpackage.othersubpackage x = somepackage.somepackage.somevar y = otherpackage.othersubpackage.othervar and which I don't personally use. (If I wanted verbosity, I know where to find Java). (And while I'm on the topic of strong opinions: A: No. Q: Should I include quotations after my reply? ) Z3 has an importchecker: Import checker This utility finds unused imports in Python modules. Its output is grep-like and thus emacs-friendly. ... I ought to try this one out some day... Althought pyflakes works for me better. http://www.divmod.org/projects/pyflakes pyflakes doesn't handle imports that are used by doctests only, e.g.: import doctest import something def doctest_foo(): use something def doctest_bar(): use something def test_suite(): return doctest.DocTestSuite() Can the import checker in Z3 handle this? Marius Gedminas -- To stay awake all night adds a day to your life. -- Stilgar (Frank Herbert _Children_of_Dune_) signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Calling a view in a doc test
On Tue, Jun 05, 2007 at 04:49:37PM +0200, Florian Lindner wrote: Am Montag, 4. Juni 2007 schrieb Marius Gedminas: On Mon, Jun 04, 2007 at 03:14:16PM +0200, Florian Lindner wrote: in a doctest I have an object which has a view registered. I want to call this view and test for the XML it returns. How can I call the view so that it is being rendered, just like called by a browser? I have thes setup and tearDown methods: import unittest import zope.testing.module from zope.testing import doctest from zope.component import testing, eventtesting from zope.app.container.tests.placelesssetup import PlacelessSetup from zope.app.testing import setup container_setup = PlacelessSetup() def blogSetUp(test): zope.testing.module.setUp(test, 'Blog.doctest') testing.setUp(test) eventtesting.setUp(test) container_setup.setUp() setup.placelessSetUp() setup.setUpTraversal() def blogTearDown(test): setup.placelessTearDown() zope.testing.module.tearDown(test) testing.tearDown(test) Oh, my, this feels like cargo-cult programming[1] to me. For example, zope.app.testing.setup.placelessSetUp() calls zope.app.container.tests.placelesssetup.PlacelessSetup().setUp() for you already, you don't need to do it twice. In fact the CleanUp().cleanUp(), which is the first thing that placelessSetUp() calls, undoes all the changfes made by container_setup.setUp(). The same applies to zope.component.testing.setUp. [1] http://en.wikipedia.org/wiki/Cargo_cult_programming I would suggest that you remove everything and keep just def blogSetUp(test): setup.placelessSetUp() setup.setUpTraversal() def blogTearDown(test): setup.placelessTearDown() and this is my README.txt containing the test: context = MyBlog You may want to actually create the object: context = MyBlog() and sometimes it is a good idea to put it into the containment hierarchy, if you're going to look up things like absolute URLs: from zope.app.folder import rootFolder root = rootFolder() root['my_blog'] = context from zope.publisher.browser import TestRequest from browser.views import RSSFeed request = TestRequest() view = RSSFeed(context, request) print view() Since my code includes a call to absoluteURL I have added your setup and tearDown methods. But there is still an error: File /home/florian/Zope3/src/zope/traversing/browser/absoluteurl.py, line 34, in absoluteURL return zope.component.getMultiAdapter((ob, request), IAbsoluteURL)() File /home/florian/Zope3/src/zope/traversing/browser/absoluteurl.py, line 55, in __str__ raise TypeError(_insufficientContext) TypeError: There isn't enough context to get URL information. This is probably due to a bug in setting up location information. Do you know what's missing here? See above. Thanks, Florian BTW: What would be the name of the MyViewClass if the page would be registered without a class set? There isn't one. When you use the browser:page directive, the ZCML maaagick creates a new class (with a funky name) at runtime, with extra attributes and methods. You cannot access that class from a unit test, because it doesn't exist in your source code. My suggestion is don't do that. If you want a view with just a template, and you want to render it in a unit test, define a view class class MyTrivialViewClass(BrowserPage): __call__ = ViewPageTemplateFile('mytemplate.pt') HTH, Marius Gedminas -- You have moved the mouse. NT must be restarted for the changes to take effect. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Utility for removing unneeded import statements
On Tue, Jun 05, 2007 at 06:10:36PM +0200, Adam Groszer wrote: Hello Marius, Tuesday, June 5, 2007, 6:03:52 PM, you wrote: pyflakes doesn't handle imports that are used by doctests only, e.g.: ... Can the import checker in Z3 handle this? I don't think so. As I remember it did not find all unnecessary imports, that's why I switched to pyflakes. By pyflakes doesn't handle I meant it found too many unnecessary imports, some of which were actually very necessary (for the doctests). Marius Gedminas -- Linux is not user-friendly. It _is_ user-friendly. It is not ignorant-friendly and idiot-friendly. (Seen somewhere on the net.) signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Calling a view in a doc test
On Mon, Jun 04, 2007 at 03:14:16PM +0200, Florian Lindner wrote: Hello, in a doctest I have an object which has a view registered. I want to call this view and test for the XML it returns. How can I call the view so that it is being rendered, just like called by a browser? Is that in a unit test, or a functional test? In a unit test you can do it like this: context = ...yourcontentobject... from zope.publisher.browser import TestRequest request = TestRequest() view = MyViewClass(context, request) print view() some xml or whatever output here If you want to provide, e.g., form parameters, pass them to the request: request = TestRequest(form={'foo': u'Lalala\u1234'}) If your view does anything interesting (e.g. use TALES expressions, or refer to other views like context/@@absolute_url), you will need to register a whole bunch of components in your doctest setUp methods. Don't forget to tear them down afterwards. IIRC you will need from zope.app.testing import setup def setUp(test): setup.placelessSetUp() setup.setUpTraversal() def tearDown(test): setup.placelessTearDown() at the very least. Accessing other views, resources, or, god forbid, forms, will require other component registrations. At some point you have two choices: figure out this stuff once and then use copy paste (actually, helper functions defined once in your project), or switch to testing your views with functional tests. Marius Gedminas -- Cool. Does it also recode ISO10646-1 pcf files into the funny permutations and subsets used a long time ago in a galaxy far far away on the planets Isolatinus XV and Koiruski VIII ... -- Markus Kuhn inquires about libXft signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Add unittest
On Tue, Apr 17, 2007 at 08:37:29PM +0200, Florian Lindner wrote: I've tried to add a test to my package (I must confess it's my first test.) I've added an directory tests, created an empty __init__.py in it and a file named test_proxycache.py which contains: .. Now I try to run the tests: [EMAIL PROTECTED] ~/Zope3 $ python test.py -vpu --dir ../Desktop/zope/lib/python/ProxyCache/ ... Running tests at level 1 Traceback (most recent call last): ... File /home/florian/Zope3/src/zope/testing/testrunner.py, line 1236, in import_name __import__(name) ValueError: Empty module name This smells like a bug in the testrunner. Would it work if you removed the trailing slash from the command line? test.py -vpu --dir ../Desktop/zope/lib/python/ProxyCache Also, nowadays it is customary to pass package/module names to test.py instead of directory names: test.py -vpu -s ProxyCache Marius Gedminas -- [...] the basic your gun, your foot, your choice memory model. -- jtv on lkml signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: execution time of a request?
On Sat, Apr 07, 2007 at 01:21:39PM +0200, Jürgen Kartnaller wrote: By the way, marius, thanks for your great profiling library. That's a bit misleading. The profiling library resides in the Python standard library, I just wrote a convenient decorator for it (mostly because I could never remember how to use the profile/hotshot modules). http://mg.pov.lt/blog/profiling.html Speaking of which, has anybody ever succeeded in profiling Zope 3 unit tests? I get an exception at the very end, and no useful results. Marius Gedminas -- One picture is worth 128K words. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] OOBTree instances lose attributes upon restart
On Fri, Apr 06, 2007 at 12:53:06AM -0700, Douglas Douglas wrote: Here's my class definition: class Variable(OOBTree, Contained): implements(IVariable, IAttributeAnnotatable) name = None units = None I start the server and everything works like a charm. My AddForm works OK for the Variable class. I checked its create() method (with assert statements) and the returned instances contain the name and units attributes set from the form. But if I stop the server and restart later, my data (datetimes and floats) are still there, but my name and units attributes are None!! OOBTree is at fault here. I'm sure that if you investigated it, you'd find a custom __getstate__. I suggest that you do not subclass OOBTree but instead contain it in an attribute and delegate all the methods. class Variable(Persistent, Contained): implements(...) def __init__(self): self.data = OOBTree() def __getitem__(self, key): return self.data[key] ... Marius Gedminas -- I dont know about madness (and anyway, the little green martians dancing around me tell me not to worry...), but I've implemented something not unlike this just now. -- Peter Sabaini signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] boolean value of adapted objects
On Tue, Apr 03, 2007 at 12:46:25PM +0200, Thierry Florac wrote: I have a little question about boolean values of adapted objects. For example, I had the following code : info = ISharedDataInfo(context, None) or \ IPrivateDataInfo(context, None) if info is not None: return context return None Even if context is correctly adapted to the first interface, the boolean value matching the adapted object is not always True ; in these cases, the second test is done, and the global result is set to None instead of context. Of course, it's easy to modify this code with two tests instead of one, but I'm sure there's an easy way to handle such things, so any information would be really great !! There isn't. Write the longer, more explicit code: info = ISharedDataInfo(context, None) if info is None: info = IPrivateDataInfo(context, None) In your particular example, since you do not use info anywhere, you can write if (ISharedDataInfo(context, None) is not None or IPrivateDataInfo(context, None) is not None): return context return None or if (ISharedDataInfo(context, None) is None or IPrivateDataInfo(context, None) is None): return None return context whichever seems clearer. Marius Gedminas -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] z.a.component.vocabulary.UtilityNameTerm bad implementation ?
On Sat, Mar 31, 2007 at 08:51:44AM +0300, Shaar Gabriel wrote: hi using zope3.3.0 on gentoo zope.app.component.vocabulary.UtilityNameTerm is marked as implementing ITokenizedTerm, but in fact tries to implement ITitledTokenizedTerm, and fails at that, because token and title are implemented as methods not properties. bug ? I think so. BTW, the UtilityName vocabulary that uses UtilityNameTerms does not appear to be used anywhere. Marius Gedminas -- You'll find creativity working hand in hand with engineering. It will feel strange and you might feel like things are out of control. Relax - they are. -- Richard Gabriel on software http://www.dreamsongs.net/LessonsFromNothing.html signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope3 startup
On Fri, Mar 02, 2007 at 12:31:22PM -0500, Giovannetti, Mark wrote: Thanks for confirming some of my questions! Is there a book that you would recommend that explains how python deals with all this? I liked Mark Pilgrim's _Dive into Python_. I don't remember if it goes into details about how Python modules work. In fact, this is how Python imports modules: it executes the .py file of the module. (It does this at most once during the program's execution, unless you explicitly ask it to reload modules. Zope 3 never asks.) Great, now I think I have a good handle on what is going on. This also explains why I have to restart zope when I make code changes (something that puzzled me very briefly when I started learning). So if I wanted to register utilities without using ZCML, I could place the provideUtility(...) calls in an __init__.py or directly within the utility's .py module. Yes? Yes, but only if you could make sure that your package or module was imported during Zope 3 startup. Grok uses a similar scheme, as far as I understand: you declare your adapters and utilites in Python code, and then a single ZCML directive in the grok: namespace loads your package and registers everything. Does Grok have a website? Google doesn't give me anything more useful than these blog posts: http://faassen.n--tree.net/blog/view/weblog/2006/11/09/0 http://faassen.n--tree.net/blog/view/weblog/2007/01/09/0 http://www.z3lab.org/sections/blogs/philipp-weitershausen/2007_01_09_you-thought-zope-3-wasn Marius Gedminas -- The laser etcher can accept most any image data, (think logos or screen dumps!) and render it on a heat-sensitive surface. There's a big tunable exhaust fan, so the thing can be dialed in to Not vaporize your laptop. -- Stuart Kreitman signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope3 with RDBMS (avoiding ZODB)?
Hi, On Wed, Feb 28, 2007 at 03:01:57PM +0100, Stefan Krumbiegel (Galileo Press) wrote: 1. Is Zope3 already in use in productive environments? Where are they (URLs)? Yes. http://launchpad.net/ is one example of a Zope 3 site that uses a SQL database instead of ZODB. Now, where should we start with it in Zope3 to connect it to an RDBMS? I do not have practical experience here. I would look at sqlos. (I would also probably investigate TurboGears of Django as a possible alternative. The grass always seems greener on the other side.) 3.1 We have found 'PostGreSQL Database Adapter' and 'MySQL Database Adapter'. Both are from the Isar sprint (2004-11-06). Are they out of date, or just 'nearly perfect'? Is anybody using these adapters? I think that nobody uses them. 5. The ZMI: In Zope2 we never used it. Do we need the ZMI in Zope 3 No. You may have a fun time studying the Zope 3 internals if you decide that you want to get rid of the ZODB and any vestiges of ZMI (such as the default root folder with the associated site and local utilities). I am absolutely certain that it is doable, but I am afraid that you will have to figure out how to do it by yourself. 6. Last but not least two quotes from the zope3-dev mailinglist (http://mail.zope.org/pipermail/zope3-dev/2006-February/018217.html): Shane Hathaway wrote: It could turn out that people who don't want ZODB really shouldn't use Zope at all. This has been the case in my experience... Chris Withers ... Discussion 'Zope 3 without ZODB' in the zope3-dev mailinglist (http://www.mail-archive.com/zope3-dev@zope.org/msg07517.html): ... I expect that such an application would look a lot like applications built with other web frameworks. Jim Fulton What do you say about that? Does that mean that we should definitively not use Zope3 if we don't want to use the ZODB but our RDBMS instead? No, but that is not a typical use of Zope 3 (although it's been done), so you should not expect much in the way of documentation. Marius Gedminas -- Nuclear war can ruin your whole compile. -- Karl Lehenbauer signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Can I override IntId's subscriber in overrides.zcml?
On Wed, Feb 28, 2007 at 04:35:07PM +, Alek Kowalczyk wrote: I think I'll start another thread (based on http://permalink.gmane.org/gmane.comp.web.zope.zope3.user/5692) because I think this is a new question. I would like to override IntId's subscriber (to catch NotYet exception there) with my own subscriber. The original subscriber is defined as: subscriber handler=.addIntIdSubscriber / How to override such subscriber in my etc/overrides.zcml? I'm pretty sure that is not possible. IIRC you found a better solution to the problem: redefine the IKeyReference adapter for your objects so that the NotYet exception never occurs. Marius Gedminas -- The laser etcher can accept most any image data, (think logos or screen dumps!) and render it on a heat-sensitive surface. There's a big tunable exhaust fan, so the thing can be dialed in to Not vaporize your laptop. -- Stuart Kreitman signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope3 startup
On Wed, Feb 28, 2007 at 11:47:15AM -0500, Giovannetti, Mark wrote: Hello, One of the problems that I've had learning zope 3 (and python at the same time) is that I did not understand how code 'got executed'. This was a big stumbling block for someone coming from a non-object oriented background who was used to creating 'normal' websites--i.e. the html/cfm/whatever file is the 'callable'. This concept, to me, doesn't exist in zope3 as far as I can tell. Some questions, then, regarding how parts of code get executed in zope3. If anyone has the time to answer them, or confirm my understanding, it would be appreciated. My descriptions are likely oversimplified/incorrect. 1. At zope startup, each *-configure.zcml in etc/package-includes is read. Q. The __init__.py file for each package is then executed, correct? A. Yes, since my testing indicates this is the case. I had problems understanding this since the idiom is to just place a comment in the __init__ file and it seemed rather useless to a new user. The __init__.py file is executed when you import a package. That happens as a side effect when ZCML directives refer to classes and functions in packages. The purpose of a __init__.py is to define names that could be imported, and not to run some initialization code. In fact, this is how Python imports modules: it executes the .py file of the module. (It does this at most once during the program's execution, unless you explicitly ask it to reload modules. Zope 3 never asks.) 2. Each configure.zcml file in the package's root directory (the one pointed to by the *-configure.zcml in package-includes) is parsed. Q. Does each class referred to in a class.. directive have the class' entire module loaded/executed or is the class just registered somewhere for future use? A. ? Yes, the module is imported. 3. Utilities and such in zcml. Q. Does each utility have its module executed to create the instance (utilities are instances, right?) A. I think so, but I'm not sure, see #2. Yes, the module is imported. I hope someone can clear this up for me. I never managed to find a good explanation of the flow of control for zope3 startup and initialization. I have read both books already. In brief, Zope 3 reads the configuration file (zope.conf), finds out the name of the root zcml file (site.zcml, usually), then loads the ZCML configuration (which involves parsing all the zcml files that include each other, importing Python modules and accessing names defined in those), executes the configuration (which involves modifying global registries of adapters, utilities, security declarations etc), opens or creates the ZODB database, and then starts listening on network ports. Marius Gedminas -- Any sufficiently advanced magic is indistinguishable from technology. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problem with macro
On Mon, Feb 26, 2007 at 02:40:13PM +0100, Florian Lindner wrote: Am Sonntag, 25. Februar 2007 15:03 schrieb Marius Gedminas: On Sun, Feb 25, 2007 at 02:02:43PM +0100, Florian Lindner wrote: I have a simple problem. A template: html metal:use-macro=views/standard_macros/view i18n:domain=xgm.de/Blog body metal:block metal:define-macro=Blog ... That is registered as view.html. Now I want to use the macro in another page: div metal:use-macro=context/Blog/@@view.html/Blog / (tried different variations) Ah, but did you try metal:use-macro=context/Blog/@@view.html/index/macros/Blog / No, have not tried it yet. But div metal:use-macro=context/Blog/@@view.html/index/macros/Blog / gives an error too: File /home/florian/Zope3/src/zope/tales/expressions.py, line 124, in _eval ob = self._traverser(ob, element, econtext) File /home/florian/Zope3/src/zope/app/pagetemplate/engine.py, line 65, in __call__ object = object[name] KeyError: 'Blog' Blog in a object contained by the xgm object. Blog is object that has the view.html registered. Do you know which 'Blog' is the one that gives you the error? The macro or the item on 'context'? It could very well be that your define-macro doesn't take effect, because it is inside a use-macro and outside any fill-slot. Marius Gedminas -- Lost packet, 42 bytes, last seen on a saturated OC3, reward $$$. -- Eric^2 on Slashdot signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Question about IOrderedContainer interface
On Mon, Feb 26, 2007 at 05:28:12PM +0100, Thierry Florac wrote: I have a little question about the IOrderedContainer interface. Actually, this interface is derived from IContainer, and only contains a single method, updateOrder() which is an updating method. When I create a subclass of OrderedContainer for which I'd like only a limited set of roles to have reordering permission, ... So I can see only three ways to make this working : ... - wait for someone else to give me another solution, which wouldn't need to modify Zope source code :-) require interface=IReadContainer permission=zope.View / require interface=IWriteContainer permission=zope.ManageContent / require attributes=updateOrder permission=zope.ManageContent / Marius Gedminas -- There's an old story about the person who wished his computer were as easy to use as his telephone. That wish has come true, since I no longer know how to use my telephone. -- Bjarne Stroustrup signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] External content with ZPT
On Mon, Feb 26, 2007 at 01:08:17PM -0500, Sam Young wrote: Is there a simple way to use ZPT to include external content? Assuming that your ZPT is a template used for a view, span tal:replace=structure view/whatever / where your view class has a method called 'whatever' that reads/downloads/acquires by whatever means necessary the external content you want. Something that resembles Apache SSI--I was hoping there is something along the lines of tal:include=addr but it does not appear to be quite this easy. The content in question is a script that I'd rather not rewrite. There is no direct way to access files or URLs within ZPTs. Marius Gedminas -- To be intoxicated is to feel sophisticated but not be able to say it. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problem with macro
On Sun, Feb 25, 2007 at 02:02:43PM +0100, Florian Lindner wrote: I have a simple problem. A template: html metal:use-macro=views/standard_macros/view i18n:domain=xgm.de/Blog body metal:block metal:define-macro=Blog metal:block metal:fill-slot=body h1 tal:content=context/title / div tal:replace=context/description / [...] /div /metal:block /metal:block /body /html That is registered as view.html. How? browser:page name=view.html template=foo.pt / ? Now I want to use the macro in another page: div metal:use-macro=context/Blog/@@view.html/Blog / (tried different variations) Ah, but did you try metal:use-macro=context/Blog/@@view.html/index/macros/Blog / ? When you attach a page template to a view with ZCML, it defines a view attribute 'index' behind the scenes. So, @@view.html refers to the view, @@view.html/index revers to the template, and @@view.html/index/macros refers to the macros defined in that template. Marius Gedminas -- For every complex problem, there is a solution that is simple, neat, and wrong signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Schema fields vs custom metadata
On Fri, Feb 23, 2007 at 02:34:30PM +0100, Svenn Helge Grindhaug wrote: I'm trying to make a system for course registration. The user will get a list of available courses, select one and register for the course. I have the following interfaces: class ICourse(IContainer): Store information about the course and store participants contains('ers.interfaces.IParticipant') class IParticipant(IContained): Store information about participants containers('ers.interfaces.ICourse') How do I store the information about the course - when course is a container? As schema fields or as custom metadata? I have tried both without success and need to know which of the two are the correct way or if I need to change the hole design. I would use schema fields. Which way is more correct depends on your application. Marius Gedminas -- I spent a lot of time in the Java world. I'm so glad I'm on Planet Python now :-) -- Steve Alexander signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: OrderedContainer.keys() does not return newely added key in ObjectAddedEvent
On Tue, Feb 20, 2007 at 07:53:14PM +0100, Philipp von Weitershausen wrote: Alek Kowalczyk wrote: I have subscribed to the ObjectAddedEvent for my OrderedContainer. There is the a strange behavior in the event handler: - myObj is my contained object - myObj.__parent__ is my OrderedContainer. 1. this returns True when called in the event handler: myObj.__name__ in myObj.__parent__ 2. this returns False when called in the event handler: myObj.__name__ in myObj.__parent__.keys() Code inspection of OrderedContainer.__setitem__ shows the following: 1. first call setitem, which triggers event as side effect setitem(self, self._data.__setitem__, key, object) 2. after that add key to the _order, which is returned by keys() method: if not existed: self._order.append(key) Is it bug or just works-as-designed? I think that this behavior is improper or at least confusing a bit. Event should be called *after* the keys() method is able to return list with added object, so that: (myObj.__name__ in myObj.__parent__) == (myObj.__name__ in myObj.__parent__.keys()) Yes. I think if not existed: self._order.append(key) should be executed before setitem(self, self._data.__setitem__, key, object) setitem() may raise various exceptions (e.g. DuplicationError). It would be good to not have extra names left in _order in that case. Perhaps you can round up a patch, including a test that tests this from an event handler perspective? You can submit the patch and the original bug report to the Zope 3 bug collector (http://www.zope.org/Collectors/Zope3-dev). Marius Gedminas -- Corsac yeah, i'm reading the answers, currently Corsac but what I see is that there is no real procedure to rebuild initfs Corsac the common way seems to use a loop device with a jffs2 filesystem, put original files there, and add other files, then umount, flash and pray dwd Corsac: You forgot ritual sacrifice of a medium sized rodent. Without that, it'll never work. zuh And if it doesn't work the first time, re-adjust towel ordering in the restroom and try again -- #maemo signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Grant role top zope.anybody
On Sun, Feb 18, 2007 at 11:47:06AM +0100, Florian Lindner wrote: Am Samstag, 17. Februar 2007 23:35 schrieb Marius Gedminas: On Sat, Feb 17, 2007 at 12:48:05PM +0100, Florian Lindner wrote: ZCML is order-dependent (sadly). You need to put your grant after the principal definition. This means doing it in principals.zcml, or in some file that is included in site.zcml after principals.zcml. The grant is contained in a security.zcml which is invoked from a configure.zcml from a package residing in the zope instance. I don't know about the order. Are the package configure.zcml invoked before principal.zcml? Yes. Look at site.zcml, which is the top-level file that includes everything. Marius Gedminas -- Be cheerful. Strive to be happy Oh, and we just set fire to your desktop. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Grant role top zope.anybody
On Sat, Feb 17, 2007 at 12:48:05PM +0100, Florian Lindner wrote: Hello, I've tried to grant a role to zope.anybody (any user that visits the site). Tried it this way: grant role = my.role principal = zope.anybody / But this gives a unknown principal id error, even though I have: unauthenticatedPrincipal id=zope.anybody title=Unauthenticated User / in my principal.zcml. How to do it right? ZCML is order-dependent (sadly). You need to put your grant after the principal definition. This means doing it in principals.zcml, or in some file that is included in site.zcml after principals.zcml. Marius Gedminas -- If something has not yet gone wrong then it would ultimately have been beneficial for it to go wrong. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: formlib vs. cancel button
On Thu, Feb 15, 2007 at 09:55:19AM +, Martin Aspeli wrote: Dennis Schulz wrote: I dont know if it is the proper way, but when I return an empty string there is no validation error. This was also one of the strangest things I found out with formlib. I found that returning {} also works. The validator is supposed to return a list of errors. Neither '' nor {} are lists. () is a list. I use @form.action(Cancel, validator=lambda *a: ()) def cancel(self, action, data): ... But this is clearly a design weakness if there is no other way of doing it. Something like validator=NULL_VALIDATOR would be fine, or some kind of decorator. +1 for allowing @form.action(Cancel, validator=form.no_validation) Note that as a side effect of an empty validator you will always get an empty data dictionary in the handler method. Marius Gedminas -- Corsac yeah, i'm reading the answers, currently Corsac but what I see is that there is no real procedure to rebuild initfs Corsac the common way seems to use a loop device with a jffs2 filesystem, put original files there, and add other files, then umount, flash and pray dwd Corsac: You forgot ritual sacrifice of a medium sized rodent. Without that, it'll never work. zuh And if it doesn't work the first time, re-adjust towel ordering in the restroom and try again -- #maemo signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Error when calling addform
On Tue, Feb 13, 2007 at 07:15:11PM +0100, David Johnson wrote: I thought zope.formlib was more complex. That may be true, under the hood, but it is certainly simpler to use. I never fully understood how to use (and extend) forms generated by ZCML addform/editform directives. As I understand you must create custom browser classes, True. and page templates. That is not necessary. Then you must register those with a page or view ZCML browser directive, each of which is more complicated than the addform. The initial complexity may be a little higher, but you get a flexible solution that scales well when you need to change something. Form directives may work well for trivial cases, but they don't scale when you need to change things. My point is that if there is something new here, I would like to learn. :) You will not regret learning zope.formlib. Marius Gedminas -- Linux was made by foreign terrorists to take money from true US companies like Microsoft. -Some AOL'er. To this end we dedicate ourselves... -Don (From the sig of Don [EMAIL PROTECTED]) signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Zope 3 mkzopeinstance OverflowWarning Error Condition
On Thu, Feb 15, 2007 at 02:44:51PM -0500, Bernie Pursley wrote: I have used zope2 for a couple of years and I have experimented from time to time with zope3. Today, I configured zope3 with python2.5 Zope 3 does not work with Python 2.5 yet. This OverflowWarning error is just the tip of the iceberg. Marius Gedminas -- BYTE editors are people who separate the wheat from the chaff, and then carefully print the chaff. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: formlib vs. cancel button
On Thu, Feb 15, 2007 at 05:37:52PM +0100, Philipp von Weitershausen wrote: Martin Aspeli wrote: Marius Gedminas wrote: On Thu, Feb 15, 2007 at 09:55:19AM +, Martin Aspeli wrote: Dennis Schulz wrote: I dont know if it is the proper way, but when I return an empty string there is no validation error. This was also one of the strangest things I found out with formlib. I found that returning {} also works. The validator is supposed to return a list of errors. Neither '' nor {} are lists. () is a list. I use @form.action(Cancel, validator=lambda *a: ()) def cancel(self, action, data): ... But this is clearly a design weakness if there is no other way of doing it. Something like validator=NULL_VALIDATOR would be fine, or some kind of decorator. +1 for allowing @form.action(Cancel, validator=form.no_validation) I added something similar to plone.app.form, but there really, really should be support for this use case in formlib in a non-hacky way. We happily accept patches through collector entries. Actually, aren't you a committer? :) I'd be happy to implement and commit something, but I'd be happier if someone else designed the API. When I try to design APIs myself, I tend to change my mind too often. Now I want @form.action(Cancel, validator=None) to mean do no validation. But perhaps that's not backwards-compatible enough? Marius Gedminas -- The *REAL* Y2K is the year 2048. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Permission problem on adapter
On Sun, Feb 11, 2007 at 09:24:34AM +0100, FB wrote: On Sun, Feb 11, 2007 at 01:16:51AM +0100, Dominique Lederer wrote: i created a trusted adapter on a content object. then i created a formlib edit page for the ZMI, to be able to edit the new attributes on the adapted content object. the adapters interface is correctly rendered to the form. if i try to edit, an unauthorized error is shown, which i also get, when i register the user as Site Manager via Grant in the ZMI. The global admin *can* edit the adapters attributes (the one which is set globally via ZCML). For future reference, when you get into a situation when the global manager can do something, but a local manager cannot, know what you have a broken __parent__ chain somewhere. Every object that has security declarations and can be security proxied must have a valid __parent__ chain leading to the ZODB root, or you will have problems like this. i registered the adapter like this: adapter factory=.MyClassAnnotations trusted=true / Try to add the attribute 'locate=true' to the adapter-statement. Cool, I didn't know about that one. I'd've suggested setting the adapter's __parent__ manually in the constructor. Marius Gedminas -- Where do you think you're going today? signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Can't find MessageIDFactory
On Sun, Feb 11, 2007 at 11:00:51PM +1100, George Wright wrote: OnFri, 9 Feb 2007 20:59:07 -0500 Vinny wrote: You'll need to use the newer boilerplate (I am running zope 3.3.0 FYI): from zope.i18n import MessageFactory _ = MessageFactory(translationdomain) This can be found here: http://kpug.zwiki.org/WhatIsNewInZope33 See section 7 Porting to Zope 3.3.0 There is other useful information on how to deal with the other areas of the book which are slightly out of date as well. Thanks Vinny I used from zope.i18n import MessageFactory _ = MessageFactory(worldcookery) as suggested and made a bit of progress. Yet to work out necessary changes to the time_report.mapping['time_to_cook'] = 45 line - but working on it. This is what you need to do: time_report = _(time_report, mapping={'time_to_cook': 45}) Or, if you have time_report = _(your message here) just above, condense them all to time_report = _(Your message here, mapping={'time_to_cook': 45, 'something_else': 'here'}) Marius Gedminas -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Error when calling addform
On Sun, Feb 11, 2007 at 07:26:21PM +0100, Florian Lindner wrote: Hello, I have an addform registered: addform label=Add Blog Comment name=AddBlogComment.html schema=..interfaces.IBlogComment content_factory=..blog.BlogComment permission=Blog.AddComment / class IBlogComment(IContained): containers(IBlogEntry) name = TextLine( title = uYour name, description = uYour name or nickname, default = uGuest, required = True) email = TextLine( title = uE-Mail, required = False) content = Text( title = uBlog comment content, default = u, required = True) but when I call the addform resp. click on the addMenuItem I get an system error: ... ComponentLookupError: ((zope.schema._bootstrapfields.Field object at 0x9e95b2c, zope.publisher.browser.BrowserRequest instance URL=http://localhost:8080/xgm/Blog/2007_02_10_erster_post/+/AddBlogComment.html), InterfaceClass zope.app.form.interfaces.IInputWidget, u'') what do I have misconfigured here? You have containers(IBlogEntry) in your schema. That's equivalent to __parent__ = Field(constraint=ContainerTypesConstraint(IBlogEntry)) Your add form is trying to find a widget suitable for Field, but there isn't one. Note also that you will inherit __name__ = TextLine(...) from IContained. I do not think you want __name__ and __parent__ in your add form. To skip those fields you'll have to explicitly enumerate all the other fields: addform ... schema=..interfaces.IBlogComment fields=name email content ... / Alternative solution: split the schema into a separate interface, specify it in the addform directive, then define an interface for your content object that inherits IContained, your schema, and specifies the container constraint. It's probably not worth bothering, given that you need to enumerate only three fields. An even better solution: learn zope.formlib and use it. Much better than the bare standard forms. Here's a very short example of an add form with zope.formlib: http://mg.pov.lt/blog/formlib-adding I'll copy a part of it here: class FruitAdd(form.AddForm): form_fields = form.Fields(IFruit) Now if you want to omit some fields from the schema, like in your example above, you can do class BlogCommentAdd(form.AddForm): form_fields = form.Fields(IBlogComment).omit('__name__', '__parent__') Marius Gedminas -- * philiKON wonders what niemeyer is committing :) *** benji_york is now known as benji benji murder? -- #zope3-dev signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] css/page template ?
On Sat, Feb 10, 2007 at 10:34:51AM +0100, Dominique Lederer wrote: tyson schrieb: I am having trouble getting my style sheet to load in my page template. I added my .css file within the local package directory. How can I point to this file on the filesystem. I tried using a layer with a resource in my configure file, but that didn't work. Any help would be much appreciated, thanks. just register your .css file as ressource via ZCML: ... browser:resource name=yourfile.css file=yourfileonfilesystemin samefolder.css / ... you can access it then via {$site}/@@/yourfile.css {$site} is the URL of the nearest site. Which you can easily find in a page template, if you use link rel=stylesheet tal:attributes=href context/++resource++yourfile.css / Marius Gedminas -- You can't have megalomania. *I* have megalomania. -- Joe Bednorz signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] PT, i18n and dynamic attributes...how to?
On Fri, Feb 02, 2007 at 08:20:42AM +0100, Sascha Ottolski wrote: Sure. It might very well be my stupidity, but up to now I couldn't find a solution to this problem. Note that it's not solved like most examples would suggest with p i18n:translate= Hi, please a tal:attributes=href view/click_url i18n:name=clickclick/a here! /p cause that would replace the whole a tag, so the tal:attributes gets lost (and none of the docs I've seen so far has got an example for my case). If I'm not mistaken, that would result in msgid=Hi, please ${click} here! which is certainly not what I want. How about p i18n:translate= Hi, please a tal:attributes=href view/click_url i18n:name=click i18n:translate=click/a here! /p ? That should give you two msgids: Hi, please $click here! and click . Marius Gedminas -- Life was simple before World War II. After that, we had systems. -- Grace Murray Hopper, 1987 signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How To Kill Zope
On Wed, Jan 31, 2007 at 10:28:14AM -0500, Stephan Richter wrote: On Wednesday 31 January 2007 08:49, Tom Gross wrote: the first one should be fine, it displays the contents of the request. The second one tries to render the template within the template within the template a classic recursion error. What do you want to do? Really? template should not even be available as top-level namespace. It should raise a TraversalError or somesuch. Why? I sometimes use div metal:define-macro=foo ... /div div metal:use-macro=template/macros/foo ... /div in a page template. Marius Gedminas -- A secret: don't tell DARPA I'm not building the sun destroying weapon they think I am. -- Michael Salib, the author of Starkiller signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Problems with custom EditForm
Hello, On Mon, Jan 22, 2007 at 05:03:43PM +0100, Alex Furlong wrote: i have some problems with creating a custom edit form. Here is my complete test code: from zope.formlib import form from zope.publisher.browser import TestRequest class MyEdit(form.EditForm): def __init__(self, context, request): self.context = context self.request = request import pdb;pdb.set_trace() # set debugger break point action = form.Action('Edit', success='handle_edit_action') Ah, this is going to be fun :) self.actions = form.Actions(action) def test(): request = TestRequest() obj = object() myform = MyEdit(obj, request) If i use this code in Zope then i get an error like this: Action object does not have an attribute 'form' . *nod* So my first question is, where does the 'form' attribute come from? Magic. Do you know how methods work in Python? You assign a function to a class attribute, and when you access that attribute on an instance of the class, you get back a bound method. The bound method knows which instance you used -- that's why it's called a bound method. Under the hood this is implemented using descriptors. A descriptor is an object that has a special __get__ method. When the value of a class attribute is a descriptor, and you access that attribute on an instance, the descriptor's __get__ gets called and return the value that you'll get. The __get__ of an unbound method will create a bound method object. Likewise, the formlib's form.Action class has a __get__ method that returns a copy of the action, with the 'form' attribute set. This mechanism only works when you assign descriptors to class attributes. It does not work when you assign descriptors to object attributes, or local variables, like you did. The simplest way to fix your problem is to bind the actions manually: def __init__(self, context, request): self.context = context self.request = request action = form.Action('Edit', success='handle_edit_action') action = action.__get__(self) self.actions = form.Actions(action) Or you can do it all in one go def __init__(self, context, request): self.context = context self.request = request action1 = form.Action('Edit', success='handle_edit_action') action2 = form.Action('Edit Again', success='handle_edit_action') actions = form.Actions(action1, action2) self.actions = form.Actions(actions).__get__(self) I do not know whether there are cleaner solutions. (I always feel a bit dirty when I call a method that starts with an underscore on an object other than 'self'.) HTH, Marius Gedminas -- TCP_UP - The 16-bit TCP Urgent Pointer, encoded as the hex representation of the value of the field. The hex string MUST be capitalized since it is urgent. -- RFC 3093 signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Access to request in content object and object path in doctests
On Wed, Jan 24, 2007 at 11:50:21PM +0100, Maciej Wisniowski wrote: Is this possible to get request object in content class. In Zope2 this was possible with simple self.REQUEST. In Zope3 I tried self.request but I only get errors. Maybe this is a feature, and I'm not supposed to access request object from content class? Yes. You're not supposed to do that. Views work with requests, not content objects. If you told us what you want to achieve, we could help you find a way to do it that works with Zope 3 rather than against it. Another question. I'm trying to write tests for my content object. Because I want some caching facilities I'm using getLocationForCache from zope.app.cache.caching. and because of this: zapi.getPath(obj) In short it is like: class MyClass(Persistent): (...) def myfunction(self): location = zapi.getPath(self) return location In the tests I always get location == None. I'm using doctests like: test_content = MyClass() test_content.myfunction() placefulsetup adds some objects like root etc. but I'm not sure how I should add my object to this. Any clues? Lately I've been using this pattern in my tests: #!/usr/bin/env python import unittest from zope.testing import doctest from zope.app.testing import setup from zope.app.folder import rootFolder from zope.traversing.api import getPath from mypackage import MyObject def doctest_something(): Bla bla bla root = rootFolder() root['my_object'] = my_object = MyObject() getPath(my_object) '/my_object' def setUp(test): setup.placelessSetUp() setup.setUpTraversal() def tearDown(test): setup.placelessTearDown() def test_suite(): return doctest.DocTestSuite(setUp=setUp, tearDown=tearDown) if __name__ == '__main__': unittest.main(defaultTest='test_suite')) I avoid setup.placefulSetUp, and I avoid zapi/ztapi. Cheers, Marius Gedminas -- System going down at 5 this afternoon to install scheduler bug. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Skinning problem
On Thu, Jan 18, 2007 at 10:10:20PM +0100, Florian Lindner wrote: Yes, it works fine but now I have another problem: The tempate contains links like: a tal:attributes=href context/@@contact.html/@@absolute_urlkontakt/a contact.html is registered for the interface (IXGM) of the object in which the object that should use the template (IBlog) resides. But in the IBlog context there is no contact.html. So, if I understand you correctly, you have URLs like /foo/bar/xgm/blog/@@myview.html where myview.html uses the template above, and you want that view to have an absolute URL to /foo/bar/xgm/@@contact.html ? What is the best way to work around this? - Register contact HTML for all interfaces? No? - Make them static (no TAL) links? That would work. a href=../../contact.html.../a Both are ways I don't really like. Or you could use a tal:attributes=href string:${context/zope:parent/@@absolute_url}/@@contact.htmlkontakt/a The pattern is to get to the desired new context of the view you want to link to, apply @@absolute_url to it, and then concatenate the new view name to that string. (It might be a nice extension to the AbsoluteURL view(s) to make them traversable so that you could say obj/@@absolute_url/something_to_append in a TALES expression. But it wouldn't work when something_to_append starts with '@@'.) Marius Gedminas -- Never, ever expect hackers to be able to read closed proprietary document formats like Microsoft Word. Most hackers react to these about as well as you would to having a pile of steaming pig manure dumped on your doorstep. -- ESR (http://www.tuxedo.org/~esr/faqs/smart-questions.html) signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Skinning problem
On Wed, Jan 17, 2007 at 09:50:58PM +0100, Florian Lindner wrote: Hello, I have a ressourceDirectory with a file styles.css resourceDirectory directory=files name=files / I refer to it in my default template: link rel=stylesheet type=text/css tal:attributes=href context/@@/files/styles.css / That's no good. The /@@/ view only works when context is a site. Besides, I'm not sure you can use it in a TALES expression like this. You want link rel=stylesheet type=text/css tal:attributes=href context/++resource++files/styles.css / I think. (I'm sure href context/++resource++name.css is the right solution for plain resource files, but I haven't used resourceDirectory much.) Marius Gedminas -- A: No. Q: Should I include quotations after my reply? signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Empty ZCML file
On Mon, Jan 15, 2007 at 03:01:38PM -0800, Michael Bernstein wrote: I've seen plenty of examples of bare include directives (and they obviously work). Aside from the issue I had, is this not considered a good practice? XML requires a document to have one and only one top-level element. ZCML does not care if that element is configure or include or something else. I think a single include is fine for package include files, as they are not intended to be modified. The idea is that if you don't want one, you'll remove it from the package-includes directory. Marius Gedminas -- Get a life? Well, once I nearly found one, but the link was broken. signature.asc Description: Digital signature ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users