[Zope-dev] acquisition interfering with []?
Hopefully this is enough context for this question. When I subclass Acquisition.Implicit or .Explicit, I find myself losing the foo["item"] and foo[slice:slice] syntax. __getslice__ and __getitem__ aren't affected. When I don't subclass Acquisition, the [] syntax works fine. I can get them back by explcitly redefining them __getslice__ and __getitem__ (even though those methods never had any problems), but is there a better way around this? I'm doing a lot of other craaazzy stuff with these classes, I may be causing this problem myself elsewhere. I'm not defining foo.__getslice__, rather I'm defining __getattr__ in a superclass, and returning the result of a call on a proxied object for attr names that match a list. But this does look like the [] syntax is running into the fact that you need to call inheritedAttribute rather than the superclass method directly, or something. Here's what I'm doing to make this work: class ManageableNodeList(ManageableWrapper, DOMProxy.NodeListProxy, Acquisition.Implicit): def __getslice__(self, i, j): return self.__getattr__("__getslice__")(i,j) def __getitem__(self, i): return self.__getattr__("__getitem__")(i) -- Karl Anderson [EMAIL PROTECTED] ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Re: ThreadSafeCounter
Andy McKay wrote: | The ideal solution would be to use an object that lives in the ZODB, | I wonder if there is a way to keep the 'object history' empty? That | is, keeping the counter 'packed' while retaining 'object history' | information on all other objects. That would work, however I just dont think that fits neatly into the ZODB in any way since all objects are appended. Don't get ZODB confused with FileStorage. What you say is true of FileStorage, not of ZODB. I'm no ZODB expert, but I think the short story is that you can't have this across several threads -- because you would have to use _v_ attribs. And what good is a ThreadSafeCounter if it's not threadsafe? Well it would be threadsafe since the object cannot be written too by multiple threads as discussed earlier it will keep try 3 times and then fail. To me the ideal answer is a simple FileSystem product that allows you to mount a file system inside the ZODB. This would implrement locking and be hence be thread safe. Its a real science project. This would also have to be ZEO friendly, but to be honest for my use and most other peoples, this isnt a huge concern. A simpler solution is to use a mounted storage that doesn't do undo, and stores changes in place. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] FTP error messages
Jonothan Farr wrote: I've now added the ability to set the message to be sent back to the FTP client on FTPResponse. The patch is attached. We'll be using it and I hope that it, or something similar, makes it into the 2.3.1. Try submitting it to the collector. It's likely to get lost on the mailing list. Sorry, I wanted to get the reaction of zope-dev lurkers before firing it off to the Collector. If I get no responses soon, I will submit the patch to the Collector. Richard -- Richard Jones [EMAIL PROTECTED] Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] FTP error messages
[EMAIL PROTECTED] wrote: I've now added the ability to set the message to be sent back to the FTP client on FTPResponse. The patch is attached. We'll be using it and I hope that it, or something similar, makes it into the 2.3.1. Please, please, please put this in the collector :-) I'd always assumed those messages couldn't be changed on the client side, but if your patch works, it'd make FTP _SO_ much more usuable... cheers, Chris ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Acquisition muddleness!
Hi - let me preface this message by saying that I _thought_ I knew how acquisition worked, but now I'm starting to doubt. A simple enough scenario: Python 1.5.2 (#1, Sep 30 2000, 18:08:36) [GCC 2.95.3 19991030 (prerelease)] on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam import ExtensionClass import Acquisition class A(ExtensionClass.Base): ... def foo(self): ... print repr(self), type(self) ... class B(Acquisition.Implicit): ... pass ... a=A() print repr(a), type(a) A instance at 80ec588 extension class __main__.A at 80eb1e0 a.b=B() print repr(a.b), type(a.b) B instance at 80dc9c0 extension class Acquisition.ImplicitAcquirerWrapper at 401460e0 a.b.foo() A instance at 80ec588 extension class __main__.A at 80eb1e0 Now, I would've expected to see a.b.foo() print out exactly the same information as repr(a.b), type(a.b). In fact, I even scrounged up the Acquisition doc (it really isn't that easy to find these days...) and I can quote from it in support of what I believe should be happening: ''' Acquisition and methods Python methods of objects that support acquisition can use acquired attributes as in the 'report' method of the first example above. When a Python method is called on an object that is wrapped by an acquisition wrapper, the wrapper is passed to the method as the first argument. This rule also applies to user-defined method types and to C methods defined in pure mix-in classes. ''' The middle sentence is the kicker. The behaviour in DTML is as I'd expect - I mean, standard_html_header still reports the correct title_or_id for me, so it must be working correctly. But using the same codebase to do the above interactive test, I run into problems... Please, how did I get myself in this muddle? Richard -- Richard Jones [EMAIL PROTECTED] Senior Software Developer, Bizar Software (www.bizarsoftware.com.au) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Python Product as DataSkin
Steve Alexander wrote: Michael R. Bernstein wrote: File /home/webmaven/Products/ZPatterns/DataSkins.py, line 208, in __set_attr__ (Object: ElementWithAttributes) KeyError: (see above) What version of ZPatterns are you using? 0.4.3b2 on Zope 2.2.0 I certainly don't have the __set_attr__ method covering line 208 in my version. In my DataSkins.py, line 208 is the one marked below: def __set_attr__(self,name,val,_v_dm_=_v_dm_): try: 208 dm = self.__dict__[_v_dm_] except KeyError: if name=='id' and val==self.__dict__['id']: return raise If they don't, you'll get the error that you're reporting. Well, that's the version I've got, and that is how the __set_attr__ method reads. What do I check next? Backtracking a bit more, line 46 in ArchiveImage.py is in the manage_addArchiveImage method, marked below: def manage_addArchiveImage(self, id, file, title='', displays=None, precondition='', content_type='', REQUEST=None): """ Add a new ArchiveImage object. """ # This constructor basically ripped off from Image/File id, title = cookId(id, title, file) self=self.this() # First, we create the ArchiveImage without data: 46self._setObject(id, ArchiveImage(id,title,'',displays,content_type,precondition)) # Now we "upload" the data. By doing this in two steps, we # can use a database trick to make the upload more efficient. self._getOb(id).manage_upload(file) if REQUEST: try:url=self.DestinationURL() except: url=REQUEST['URL1'] REQUEST.RESPONSE.redirect('%s/manage_main' % url) return id Does this help? Thanks, Michael Bernstein. ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] DTML Documents/Folders in ZClasses fail to access anything
Itai Tavor wrote: Hi, I got a ZClass 'Test', with a DTML Method 'view' containing dtml-var id, and a DTML Document 'view2' with the same line. instance/view works. instance/view2 returns (ZDebug output): From SimpleItem.py: """Direct use of the 'id' attribute is deprecated - use getId()""" The difference you're seeing is because the DTML Method is acquiring the id attribute, whereas you're getting the DTML Document's own id attribute. -- Steve Akexander Software Engineer Cat-Box limited http://www.cat-box.net ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] ZPatterns: commitSubtransaction() gives AttributeError on commit_sub
I have the following form action pythonscript: req = context.REQUEST context.propertysheets.info.manage_changeProperties(longdesc=req.form['longdesc']) context.commitSubtransaction() req.RESPONSE.redirect(req['URL1']+'/edit_longdescForm') context is a DataSkin instance. When I submit the form, I get an Attribute Error on commit_sub (traceback below in case it helps anyone). As far as I can see from the ZPattern's source, I'm making the call correctly and it is an appropriate call. Any clues? This is Zope 2.3.1b1 and Steve's convenience release of ZPatterns. --RDM Traceback: File /usr/local/zope/Zope231b1/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /usr/local/zope/Zope231b1/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/zope/Zope231b1/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: tales) File /usr/local/zope/Zope231b1/lib/python/ZPublisher/Publish.py, line 175, in publish File /usr/local/zope/Zope231b1/lib/python/Zope/__init__.py, line 235, in commit File /usr/local/zope/Zope231b1/lib/python/ZODB/Transaction.py, line 276, in commit AttributeError: (see above) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] initializing objects in ZPatterns
Hi! I just encountered another problem with ZPatterns (well not exactly with ZPatterns but the way I use it.. ;-) I have some Specialist with a normal rack which stores data persistently in the ZODB. Everytime I am creating a new object I want to create an object of another specialist on the fly and store it's id inside my first object. Thus I have setup a SkinScript with the following content: INITIALIZE OBJECT WITH company_address=addresses.createAddress() WITH addresses.getItem(self.company_address) COMPUTE company_addr=RESULT STORE company_address IN SELF The createAddress is called actually and it returns the ID of the new object (thus the object is created). Unfortunately the id is not stored inside company_address. After reading the new object again this value is still empty (and thus also no address object is return by the address specialist). Same happens when just using some dummy property and filling it with a fixed string. This also disappears.. So what do I have to do to get it stored? (the other data which is handled via the default plugins is stored and all the attributes are defined inside the ZClass..) Hope, anyone knows how this might be fixed.. regards, Christian -- COM.lounge http://comlounge.net/ communication design [EMAIL PROTECTED] ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )