[Zope-dev] Comparing folder instances
Hi, A quick question. How do I compare folder instances ?(or any instances as a matter of fact). Here is a simple code showing what I tried: dtml-in "objectValues(['Folder'])" dtml-var "_.getitem('sequence-item')" dtml-var "images" dtml-var "_.getitem('sequence-item')==images" /dtml-in Here is now the resulting HTML Folder instance at 85cf958 Folder instance at 85cf958 0 Folder instance at 858a168 Folder instance at 85cf958 0 Why isn't the first comparison returning true? What I want to use is something like: dtml-in "objectValues(['Folder'])" dtml-if "_.getitem('sequence-item')==images" EQUAL dtml-else NOT EQUAL /dtml-if /dtml-in Thanks a lot in advance for your comments. Carl ___ 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] Re: Acquisition Wrappers Bit Again ;-)
Hi Criss, Thanks a lot for your quick response!! Since I'm a new Zope user, I guess I'll just cut-paste the line you suggest without trying to understand for the moment ;-) Carl Carl Robitaille wrote: dtml-var "_.getitem('sequence-item')" dtml-var "images" dtml-var "_.getitem('sequence-item')==images" Folder instance at 85cf958 Folder instance at 85cf958 Congratulations, you've just been bitten by the thing that confused me for half a day... You see, while they say Folder instance at 85cf958, they're actually lying ;-) The objects you're comparing are actually acquisition wrappers. IMHO, == should work with acquisition to make problems like the above not happen. I suggested this, and Jim Fulton agreed: http://zope.nipltd.com/public/lists/dev-archive.nsf/ByKey/08240A8E0D50AEE0 Sadly, nothing seems to have been done about it :( Maybe you should chuck it in the collector as a bug in the ExtensionClass? cheers, Chris PS: In the meantime, the following should work: dtml-in "objectValues(['Folder'])" dtml-if "_.getattr(_.getitem('sequence-item'),'aq_base',_.getitem('sequence-item'))==_.getattr(images,'aq_base',images)" EQUAL dtml-else NOT EQUAL /dtml-if /dtml-in ___ 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] Re: Acquisition Wrappers Bit Again ;-)
Hi, Just for the record, Criss' suggestion didn't work for me. I don't quite get why though Here's the code again, where images is a Folder: dtml-in "objectValues(['Folder'])" dtml-if "_.getattr(_.getitem('sequence-item'),'aq_base',_.getitem('sequence-item'))==_.getattr(images,'aq_base',images)" EQUAL dtml-else NOT EQUAL /dtml-if /dtml-in The error I get from Zope is: File /home/zope/Zope2/lib/python/DocumentTemplate/DT_Util.py, line 337, in eval (Object: _.getattr(_.getitem('sequence-item'),'aq_base',_.getitem('sequence-item'))==_.getattr(images,'aq_base',images)) (Info: images) File string, line 0, in ? File /home/zope/Zope2/lib/python/DocumentTemplate/DT_Util.py, line 140, in careful_getattr AttributeError: aq_base It's looks like aq_base is not available. I read Shane's Acquisition Understander How-To. I created the ExternalMethod that used aq_base and it works like a charm. I tried a lot of things even if I didn't have a good undersanding of the problem. The only time I got a valid code (Zope not complaining when hitting the Change button) was with that line: dtml-if "_.getattr(_.getitem('sequence-item'),'images.aq_base',_.getitem('sequence-item'))==_.getattr(images,'images.aq_base',images)" You probably know why it doesn't give the right result, but I don't have a clue. It's still not returning true when sequence-item is matching the images Folder. Is there anything I can read to understand what I'm dealing with? Or maybe somebody knows what I'm doing wrong... again Carl Carl Robitaille wrote: Hi Criss, Thanks a lot for your quick response!! Since I'm a new Zope user, I guess I'll just cut-paste the line you suggest without trying to understand for the moment ;-) Nih! Welcome to the deep end ;-) 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 )
Re: [Zope-dev] Weird Data.fs corruption...
Hi, That's because your problem only existed for a few hours. Sigh. I'm using the CVS version of Zope2. We try to keep this stable, but no guarantees. Some changes were checked into CVS on Monday night that caused the problem you observed. That's all right. I'm just an unlucky bastard, that's all ;-) Right. The bug caused the file pointer to get incorrectly set at 0, so transactions after the copy/paste errors were written at the beginning of the file. Thanks for the info. Carl ___ 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] Weird Data.fs corruption...
Hi everybody, I looked around the Zope site and mailing lists, but I wasn't able to find an answer to my problem. I'm using the CVS version of Zope2. I did an update yesterday. Since then, there's been some commits. I just started my web site project using Zope running with ZServer, when I began to have problems doing Cut-Paste operations. I thought at first that I messed the permissions or something because of my lack of experience with Zope. Little did I know at that moment that my Data.fs was corrupted very badly. So I tried to restart Zope, but it refused giving me this backtrace: [zope@petechie ~/Zope2]$ ./start Traceback (innermost last): File "/home/zope/Zope2/z2.py", line 554, in ? exec "import "+MODULE in {} File "string", line 1, in ? File "/home/zope/Zope2/lib/python/Zope/__init__.py", line 110, in ? DB=ZODB.FileStorage.FileStorage(Globals.BobobaseName) File "/home/zope/Zope2/lib/python/ZODB/FileStorage.py", line 303, in __init__ self._pos, self._oid, tid = read_index( File "/home/zope/Zope2/lib/python/ZODB/FileStorage.py", line 1515, in read_index if read(4) != packed_version: raise FileStorageFormatError, name ZODB.FileStorage.FileStorageFormatError: /home/zope/Zope2/var/Data.fs I then logged to Zope web site to get information on how to get my Data.fs fixed. I read the http://www.zope.org/Members/itamar/CorruptedZODB document and downloaded the tranalyzer.py python program. I then understood what the backtrace already told me. The first 4 bytes of any ZODB files should be something like "FS21". Instead, I have garbage in my Data.fs: [zope@petechie var]$ python tranalyzer.py Data.fs | more Traceback (innermost last): error: Not a .fs file (at least, not a kind I know about) magic = 6TÆ Just for the record, Data.fs.in is read easily by tranalyzer.py. How can this happen? Any idea? My only "guess" is that it has to do with the Data.fs file being used by ZServer over an NFS partition on Linux. This is only a guess, but I really can't see any other thing I could have done wrong. This doesn't really bug me for the moment as I only had a couple of hours put in my site, but I would like to prevent it from happening again yes I do backups, but only once a day ;-) Thanks for your help/comments. Carl Carl Robitaille [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 )