Re: [Zope-dev] Common Icons or Free Icon collection
Thomas Weholt wrote: > > Hi, > > I need some icons/pics for my Zope project. Are there any common icons for > Zope I could use, and if not, shouldn`t there be such a thing? Does anybody > know of any other collection of free icon-collections available ? KDE has a large collection of icons. I don't know what the license is for them, and I don't know if they are the right size. Take a look at Gnome's icons too. Again, you'd best check out the sizes and license. -- 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 )
[Zope-dev] Prototyped folders?
Hi Hamish, I've answered your message in Zope-Dev, as this seems to be more of a developers' question. Hamish wrote: > If a folder doesn't itself contain a required object or method, I'd > like to have another folder looked in instead. The fall-back folder > won't necessarily (and often can't) be higher in the hierarchy, so > acquisition doesn't seem to be a solution. This looks like a job for a Python class that uses the new Traversal interface. http://www.zope.org/Members/michel/Projects/Interfaces/Traversal Your requirements sound very much like those for Shane Hathaway's Transparent Folders product, except that instead of briefly diverting acquisition into the transparent folder, you want to briefly divert acquisition into some other arbitrary folder. Last I heard, Shane was going to revitalize Transparent Folders when the various interfaces it uses are finalized for Zope 2.2. I suggest that after Shane has re-released his product, you make a product based on Transparent Folders that works in this slightly different way. Or, if it is appropriate, consider your changes an enhancement to Transparent Folders, and offer it as a patch. If you don't have sufficient python-hacking-zope-hacking-Zen to do it yourself, I think I might have a go (and hopefully learn some Zope internals Zen in the process). Transparent Folders were here: http://www.zope.org/Members/hathawsh/ - but the link to them is broken -- I guess because the product was withdrawn as there was a problem with it under Zope 2.1.6. -- 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] Racks and Specialists Simplified
Shane Hathaway wrote: > > "Phillip J. Eby" wrote: > > At 02:33 PM 6/11/00 -0600, Shane Hathaway wrote: > > >I believe I have come to understand the basics of ZPatterns and would > > >like to be sure I understand correctly, as well as help others > > >understand also. > > > > Bravo! An exquisite introduction to the purpose of ZPatterns. May I post > > an edited version of your message to the ZPatterns Wiki, and make it or > > subsequently edited versions a part of the ZPatterns documentation? (With > > attribution, of course.) > > By all means! Thank you. The truth is that several of us at DC have > had trouble making sense of it all, so I wrote it not only for the > community, but DC and myself as well. :-) I just looked over the ZPatterns Wiki for Shane's explanation, but I can't find it. If it isn't there (hiding somewhere), perhaps I can add it from Shane's original email? -- 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 )
[Zope-dev] ZPatterns: DropZone example
Hi folks, I've been looking at the DropZone example Phillip Eby provided on the ZPatterns Wiki. http://www.zope.org/Members/pje/Wikis/ZPatterns/DropZoneExample I've decided to start implementing it, so as to give myself an educational experience in using ZPatterns. I have an open question: The suggested specialists in the Accounting framework are: Invoices Orders Customers Products What I'm finding is that these are just the White-box specialists. A clean design would seem to want all the specialists above, plus at least one Black-box specialist to do the "heavy lifting. Let's call it the "AccountingProcessor" specialist. Now, if I had a third-party accounts package (something by Sage perhaps), I could make the AccountingProcessor specialist expose various functions to the four other White-box specialists. It would implement these by making equivalent calls on the underlying accounting package. I could also swap the heavy-lifting portion of my framework by swapping the black-box AccountingProcessor specialist for one that talks to some software by Quicken, or perhaps some software that is written in Python as a conventional Zope product. The same goes for the Resource Scheduling framework. We have some White-box specialists, ripe for customisation: Resources Reservations ResourceUsers And then for the heavy-lifting we have the black-box ResourceScheduler specialist. Again, this might be a Zope Python Product, or it might be an interface to some application written on top of Microsoft Exchange. Are specialists intended to be placed inside other specialists, as "contents"? So in this case, would the white-box specialists live inside the black-box specialist -- so they become the customisable aspects of the overall framework? Or would both black-box and white-box specialists live inside an uber-specialist? Or is this just down to taste? -- 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 )
[Zope-dev] ZTopic displays wrong tabs
Hi folks, I'm using ZTopic. One thing I've noticed about the management interface is that, although an appropriate tab is highlighted when you click that tab, if you go to a subsequent screen, often "contents" will erroneously become the highlighted tab. This is causing problems as I explain to non-technical folk how to use ZTopics. I say "select the contents tab", and they say "but the contents tab **is** selected!". I have a fix for this, but the real problem is in the logic of lib/python/App/manage_tabs.dtml: Here, the variable 'a_' represents the "active" tab. If the last part of the URL matches one of the manage_options of the current object, then that tab will be the highlighted one. Otherwise, the first tab will be highlighted. It should ideally be possible to tell manage_tabs what tab should be highlighted, imperatively, when required. However, in the absence of such a mechanism, I have changed the DTML files in ZTopic like this: The form searchEdit.dtml is really part of the "Search Criteria" logic, so I want that tab highlighted. That tab's action attribute is called "editForm". Therefore, in the file searchEdit.dtml, I replace this: Edit catalog search criterion number on Catalog . With this: Edit catalog search criterion number on Catalog . (I modernised the to along the way.) To get the full effect, you'd need to do a similar trick with the other dtml files in ZTopic. Any takers for a full patch? Or, is there a better way of doing this that I don't know about? -- 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] ZTopic displays wrong tabs
Steve Alexander wrote: > > > > > > > Edit catalog search criterion number > on Catalog . Or, I could have used the less-clear one-liner: Any preference? -- 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 )
[Zope-dev] adding attributes to a python product
Hi folks, I have a Python Product that I'm developing. During the course of development, I want to add a new attribute. All new instances get this attribute, as it is defined with a default value in the constructor. In addition, all instances that get edited via the web get the attribute, as the edit-processing method is defined to have a default value for this attribute. Is there any way of interacting with the ZODB persistence machinery to add the default attribute to all instances as they are brought out of persistent storage -- so that I can just restart Zope, and have all of my instances updated as I use them ? I can't find the right method or whatever in the ZODB on-line docs, or in the source. Thanks for any help. -- 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] Product Data Storage
Andy Dawkins wrote: > > So my question is this: > What are peoples opinions on storing shared product data? Where should it > be placed? Should this ability be added to Zope as a standard? > So, this would be the zope equivalent of the unix "/etc/" directory? Perhaps you could have "etc (Product Settings)" as a subfolder of control panel. -- 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] ZPatterns Specialist Question
Chris Withers wrote: > > Just a quickie: > > If, as the the ZPatterns Wiki states, 'Specialists are not classes', > then why is there a 'Specialist' python class in the ZPatterns > distribution? ZClasses are coded (implemented) using Python classes, and each instance of a ZClass represents a particular application-level class in Zope: DTML Methods are coded (implemented) using Python classes, and each instance of a DTML Method represents a particular application-level method in Zope. Specialists are coded (implemented) using Python classes, and each instance of a Specialist represents a particular ZPatterns Specialist object in Zope. I think you're getting your levels of abstraction confused with your meta-levels of abstraction :-) -- 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] Help needed: why is this DTML not working in zope 2 ?
Gilles Lavaux wrote: > > Argh!!! > > no, I made a typo error : it was .the syntax was good. > Ok, I will use the new syntax in my new sites. But for my old site, I will > not modify my ~500 dtml methods, except if there is a way to automate the > change. You can write a pretty simple external method to walk your Zope object heirarchy looking for DTML Methods and DTML documents, then altering the syntax. Shouldn't take more than an hour to write and debug and test and document, if you've written stuff in Python before. I'm off to a meeting for a few hours, but harrass me later and I'll send to the list a proof-of-concept external method to get you started. -- 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] Help needed: why is this DTML not working in zope 2 ?
Steve Alexander wrote: > > Gilles Lavaux wrote: > > > > Argh!!! > > > > no, I made a typo error : it was .the syntax was good. > > Ok, I will use the new syntax in my new sites. But for my old site, I will > > not modify my ~500 dtml methods, except if there is a way to automate the > > change. > > You can write a pretty simple external method to walk your Zope object > heirarchy looking for DTML Methods and DTML documents, then altering the > syntax. Shouldn't take more than an hour to write and debug and test and > document, if you've written stuff in Python before. > > I'm off to a meeting for a few hours, but harrass me later and I'll send > to the list a proof-of-concept external method to get you started. An external method for automated change from old syntax to new syntax follows. * Use at your own risk * No warranty implied or given * Use on a copy of your main Zope site * Back up data.fs three times before starting * Not guarenteed not to spin your processor and never terminate * Run on a copy of Zope in debug mode (-D) to see the print statements * Barely tested, if at all import re def convert_dtml(self): """Convert DTML Methods and DTML Documents from old syntax to new syntax. Warning: recursive! Might just eat all your stack. Does not work on subclasses of DTML Method and DTML Document. Preserves normal comments, and handles instances of "-->" in quotes. """ print 'convert_dtml: id=%s' % self.title_and_id() if hasattr(self, 'meta_type') and \ (self.meta_type == 'DTML Method' or \ self.meta_type == 'DTML Document'): convert(self) # should this be "isPrincipiaFolderish"? if hasattr(self, 'isAnObjectManager') and self.isAnObjectManager: for v in self.objectValues(): v.convert_dtml() _convert_regex = re.compile('') def convert(dtml_item): print 'converting...' title = dtml_item.title # like document_src, but doesn't require RESPONSE data = dtml_item.PrincipiaSearchSource() print '----data----' print data newdata = _convert_regex.sub('<\g<1>dtml-\g<2>>', data) print 'newdata' print newdata print 'end' dtml_item.manage_edit(newdata, title) -- 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] Help needed: why is this DTML not working in zope 2 ?
Steve Alexander wrote: > > > An external method for automated change from old syntax to new syntax > follows. > > * Use at your own risk > * No warranty implied or given > * Use on a copy of your main Zope site > * Back up data.fs three times before starting > * Not guarenteed not to spin your processor and never terminate > * Run on a copy of Zope in debug mode (-D) to see the print statements > * Barely tested, if at all > > _convert_regex = re.compile('') Actually, I missed something in the original regex, above. (Funny how I noticed just after I pressed the 'send' button!) It should read like this: _convert_regex = re.compile('''''') The whole thing again -- same disclaimers apply, only more so :-) import re def convert_dtml(self): """Convert DTML Methods and DTML Documents from old syntax to new syntax. Warning: recursive! This assumes that DTML Method and DTML Document haven't been subclassed. """ print 'convert_dtml: id=%s' % self.title_and_id() if hasattr(self, 'meta_type') and \ (self.meta_type == 'DTML Method' or \ self.meta_type == 'DTML Document'): convert(self) # should this be "isPrincipiaFolderish"? if hasattr(self, 'isAnObjectManager') and self.isAnObjectManager: for v in self.objectValues(): v.convert_dtml() _convert_regex = re.compile('''''') def convert(dtml_item): print 'converting...' title = dtml_item.title # like document_src, but doesn't require RESPONSE data = dtml_item.PrincipiaSearchSource() print 'data' print data newdata = _convert_regex.sub('<\g<1>dtml-\g<2>>', data) print 'newdata' print newdata print 'end' dtml_item.manage_edit(newdata, title) -- 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] How to use document templates
Jarkko Veijalainen wrote: > > Hi! > > Where can i find S_I_M_P_L_E example of using document templates with > zope/python. I have this external method, wich return several variables from > object class. I want to embed to results in DTML page. > > The method is called from Zope by HTML form with 3 input attributes. Right > now i have only managed to get obj.member in return plain screen. I can't > use tag, because i need to send those input values to the > external method. ( i must be sound like real newbie, in fact i'm :) ) > > How i get those results in DTML page? Is the templates the answer or this > there better way to this. This question really belongs at on the [EMAIL PROTECTED] mailing list, as it is to do with using Zope in a standard way, rather than developing Zope. Sounds to me like you're not really sure where to start. Try going through the Job board tutorial, as it will give you an idea of how things work together. http://www.zope.org/Members/mukhsein/job_board_howto If you want something that is easier to follow, with screenshots and fuller explanations, and you don't mind paying for it, you might want to look at Beehive's ZClass Tutorial. http://hive.beehive.de/Beehive/www.beehive.de/Zope/ZClassTutorialEnglish_html Also, take a look at the Zope documentation project. http://zdp.zope.org Furthermore, there's a tutorial that comes packaged with the latest 2.2 beta versions of Zope. You might like to try that, too. -- 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] More comments on ZPatterns
Steve Spicklemire wrote: > > I just want to make sure I understand... is the intention that property management > needs to be done on each instance separately? So if I add a new property to one > of my property sheets, I need to somehow update the propertysheets of each of the > instances? Also if I need to create propertysheets for each instance... where > should that be done? I suppose it makes sense to put that in the Specialist that > handles the object that gets the properties?...no? No need for all that. Your instances are DataSkins, and they get their PropertySheets via an InjectionFolder. All you need to do is tell a DataManager that is in an appropriate InjectionFolder that it should handle DataSkins of whatever meta_type your instances have. Furthermore, configure this DataManager to provide the PropertySheets you want, with sensible default values, and suddenly, all your instances suport this propertysheet. An "appropriate InjectionFolder" is one that lies in the acquisition path of your instances. [postscript: I only realized this stuff a couple of days ago, when I started using ZPatterns on a project :-) ] -- 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] NASTY error. Why?
Chris Withers wrote: > > Chris Withers wrote: > > Can someone please tell me why folder.id is a method and > > everything-else.id is a string? > > Sorry, that should be folder.id is a string and everything-else.id is a > method. Interesting commentary from the Interfaces Wiki: http://www.zope.org/Members/michel/Projects/Interfaces/ObjectManagerItem """Some old objects provide id methods that return ids. This practice should be avoided for new objects. We can't change the old objects for backward compatability reasons. Maybe we should fix this in Zope 3.0.""" -- 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 )
[Zope-dev] error adding specialist
I've come across an error on trying to add a Specialist. Zope 2.2b4, ZPatterns latest release (ZPatterns-0-4-0a1). Go to the zope management pages, as a Manager. Choose to add a Specialist. Leave the "Create Default Rack of type" drop-down set to "Rack". Put in an appropiate id, such as "test". Press "Add". We get a Zope error: Error Type: TypeError Error Value: keyword parameter redefined Traceback (innermost last): File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/zope/SiteBox/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/zope/SiteBox/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_addSpecialist) File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: manage_addSpecialist) File /usr/local/zope/SiteBox/lib/python/Products/ZPatterns/Specialists.py, line 71, in manage_addSpecialist File /usr/local/zope/SiteBox/lib/python/Products/ZPatterns/PlugIns.py, line 436, in _constructPlugIn TypeError: (see above) The error occurs because the _constructPlugIn() method of PlugIns.py attempts to give "id" to manage_addRack as a keyword argument, whereas it has already been given the id as a positional argument. Actually, I think what it is being given as an id is wrong too :-) The offending line is 436: return apply(getattr(product, method), (product,)+args, kwargs) The rest of this is mainly for my benefit, and will be obvious to anyone familiar with the code :-) "getattr(product, method)" evaluates to the python method manage_addRack, and it appears to be a bound method. "product" is a __FactoryDispatcher__ instance. "args" is None, or (). "kwargs" is {'id': 'defaultRack'}. The signature of manage_addRack() is: def manage_addRack(self, id, title='', REQUEST=None): and is effectively getting called as: instance.manage_addRack(some __FactoryDispatcher__, id='defaultRack') I'm not sure whether the method intended to get an unbound method rather than a bound one, or whether "id" needs special handling here. -- 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 )
[Zope-dev] Re: error adding specialist
"Phillip J. Eby" wrote: > > I found this one on Saturday. The problem is that Zope recently changed > the way constructors bind to their factory objects, and the "self" that > ZPatterns is providing to the constructors is no longer needed. I've > changed ZPatterns to fix this (still maintaining 2.1.x compatibility in the > process) and a few other reported and unreported bugs, but haven't had time > to issue a new release just yet. I'm up to my neck in "regular job" work > for the next few days. My quick "2.2 only" fix is to change line 436 of PlugIns.py to this: return apply(getattr(product, method), args, kwargs) > Hopefully I'll have a release out before the ZPatterns chat Friday, though. Great. -- 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 )
[Zope-dev] Designing with ZPatterns
Quick question on designing with ZPatterns: Is a developer meant to specialise Specialist by defining a subclass, as is the case in LoginManager? Or, given how many plugpoints Specialist has, is it best to instantiate Specialists as-is, and fill them with DTML methods, External methods and triggers and so forth. Then, when you want a new one, it gets constructed by some sort of wizard. Or, is the answer "whichever seems most appropriate" ? Thanks. -- 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 )
[Zope-dev] ZPatterns -- trigger add events not working
I have a GenericTrigger in a Folder with Customizer support. When I set it to trigger upon Add, my method doesn't get triggered when I add a new DataSkin-derived-ZClass instance. However, when I set it to trigger on Change, my method gets called on adding a new DataSkin. I can't see anything obviously amiss in the ZPatterns code. I've inserted print statements into the _objectChanging() and _objectAdding() methods of DataManagers.DataManager. It seems that when I add a DataSkin-derived-ZClass, it gets added and also changed set in a single transaction, and only one of them gets reported to the trigger. Strangely, the call to _objectChanging() comes before the call to _objectAdding(). Is this a bug, or is it the expected behaviour? Thanks. -- 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] ZPatterns -- trigger add events not working
"Phillip J. Eby" wrote: > > This would explain why you only get a change event, since if add happens > after change, it is ignored. I'm curious how the change event is getting > called first, since... Oh. I'll bet I know what it is. It's probably > that manage_afterAdd is being called later in the ObjectManager code than > it used to be, and/or Zope is trying to set an _owner attribute on the > newly added object. Crap. This is going to take some rethinking to find > another way to trap the Zope "add" event. :( If it saves you any time, here's part of a traceback from an exception raised in _objectChanging(): File /lib/python/ZClasses/ZClass.py, line 466, in createInObjectManager File /lib/python/OFS/ObjectManager.py, line 258, in _setObject File /lib/python/AccessControl/Role.py, line 393, in manage_setLocalRoles Looks like you're right -- manage_setLocalRoles. -- 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] ZPatterns -- trigger add events not working
"Phillip J. Eby" wrote: > > This would explain why you only get a change event, since if add happens > after change, it is ignored. I'm curious how the change event is getting > called first, since... Oh. I'll bet I know what it is. It's probably > that manage_afterAdd is being called later in the ObjectManager code than > it used to be, and/or Zope is trying to set an _owner attribute on the > newly added object. Crap. This is going to take some rethinking to find > another way to trap the Zope "add" event. :( Is this a way around the problem, or am I only seeing half the picture :-) ? You could have a flag in DataSkin instances called _has_been_added. It is initially cleared. It gets set when manage_afterAdd is called on it. The DataSkin sends an _objectChanging event only if the _has_been_added flag is set. -- 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] ZPatterns -- trigger add events not working
Steve Alexander wrote: > > You could have a flag in DataSkin instances called _has_been_added. It > is initially cleared. It gets set when manage_afterAdd is called on it. > > The DataSkin sends an _objectChanging event only if the _has_been_added > flag is set. Of course, the name of the attribute should be more like _v_has_been_added :-) -- 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] External Method Missery
Chris Withers wrote: > > I think this is a bgu so I'll chuck it into the collector unless someone > tells me otherwise... > > I have an external method called navTree (dtml-tree was too broken to > fix in the time frame :( ) with a spec as follows: > > def navTree(self,start): > > It's called in some DTML as: > > > > which is fine, unless I call it with the following: > > > > in which case I get: > TypeError: not enough arguments; expected 2, got 0 > > which is not very helpful :( > > Any ideas? Ok. I debugged this by creating an external method to see what it is actually receiving: def navtree(*arg, **kw): print 'navtree' print 'arg= ', arg print 'kw= ', kw print For we get: navtree arg= (,) kw= {} For we get: navtree arg= () kw= {'start': } That is, no "self" argument is getting passed. Now, I change the external method to have a "self" argument first: def navtree(self, *arg, **kw): print 'navtree' print 'self=', self print 'arg= ', arg print 'kw= ', kw print For we get: navtree self= arg= () kw= {} For we get: navtree self= arg= () kw= {'start': } So, in the first case, you're not getting the current context passed in, but you are getting it in the second case. One more try: def navtree(self, **kw): print 'navtree' print 'self=', self print 'kw= ', kw print For we get: navtree self= kw= {} For we get: navtree self= kw= {'start': } Looks like it is assumed that the first non-keyword argument should be passed as the client (ie "self"). So, you can fix your exception by giving "start" a default value: def navTree(self,start=''): However, you'll have to always use the keyword form of calling it: Or otherwise, provide a client for it: As for why this is the case... I have other things to do this morning, so I won't go rooting around in the DTML source just now. [ Although, it sure is tempting :-) ] -- 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] Zope 2.1.6 packages
"Alexandre A. Drummond Barroso" wrote: > > It would be a good idea to change the user/group that > owns any file in the Zope tree to nobody.nobody before > packaging the product (src and linux packages) instead > of delivering with user 509. When this user number is > already used, and someone is testing Zope as a simple > user (not root) the user can loose the control of the > files when unpack the package. Anyway, it's a simple > task and will take almost no time from you. > > Thanks in advance, Is nobody always user/group 99 on unix systems in general? -- 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 )
[Zope-dev] Re: Another mystery for you ;-)
Chris Withers wrote: > > I was trying to use 'if o in REQUEST.PARENTS' to expand branches on the > way to the currently displayed object and was running into trouble which > lead me to try out the following code: > > `REQUEST.PARENTS[0]`+`o`+`o==REQUEST.PARENTS[0]`+`o is > REQUEST.PARENTS[0]` > > Now, this renders the following in the case where the branch _should_ > expand: > 00 > > What I don't understand is how two objects, apparently at the same > memory location, return false from both 'object1==object2' and 'object1 > is object2'. Smells like an Acquisition Wrapper misunderstanding :-) http://www.zope.org/Members/michel/Projects/Interfaces/AcquisitionWrappedObject Use the aq_self or aq_parent attribute to do your comparisons to get your object out of its magic acquisition wrapper. -- 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] Re: Another mystery for you ;-)
Chris Withers wrote: > > ...or have you been bitten by this before? Nope -- I just like reading impenetrable documentation :-) > Do you know if objects in PARENTS are acquisition wrapped? I'm pretty sure that they are. Anyway, I was wrong in my last email -- you should be comparing using the aq_base attribute, not the aq_self attribute, as the aq_self attribute could itself be wrapped. -- 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] Re: Another mystery for you ;-)
Chris Withers wrote: > > > Two questions: > > 1. Is there a better way of doing the above? Does the method aq_inContextOf() do what you want? http://www.zope.org/Members/michel/Projects/Interfaces/AcquisitionWrappedObject aq_inContextOf(other [, inner]) Check whether the object is in the context of another object, other, meaning that the other object is in the acquisition hierarchy abovethe object. An optional argument, inner, can be provided to indicate wither the innermost wrapped object should be checked. > 2. Is there any case where a Zope object isn't going to have a .aq_base >attribute? I don't think there is any such case generally, as all Zope objects support acquisition, and therefore inherit from Acquisition.Implicit or Acquisition.Explicit. However, someone could write a Product with a class that doesn't support Acquisition. I think I'd consider that a bug in their Product, though. -- 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] External Method Missery
Chris Withers wrote: > > Shane Hathaway wrote: > > that last algorithm falls to pieces. The solution is to always provide > > the "self" argument. > > When calling or in the signature of your external method? Both. Declare it like this: def external_method(self, ...other args...): Use it like this: > ? -- 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] ZPatterns -- trigger add events not working
Steve Alexander wrote: > > "Phillip J. Eby" wrote: > > > > This would explain why you only get a change event, since if add happens > > after change, it is ignored. I'm curious how the change event is getting > > called first, since... Oh. I'll bet I know what it is. It's probably > > that manage_afterAdd is being called later in the ObjectManager code than > > it used to be, and/or Zope is trying to set an _owner attribute on the > > newly added object. Crap. This is going to take some rethinking to find > > another way to trap the Zope "add" event. :( > > If it saves you any time, here's part of a traceback from an exception > raised in _objectChanging(): > > File /lib/python/ZClasses/ZClass.py, line 466, in createInObjectManager > File /lib/python/OFS/ObjectManager.py, line 258, in _setObject > File /lib/python/AccessControl/Role.py, line 393, in > manage_setLocalRoles > > Looks like you're right -- manage_setLocalRoles. I have patched the _objectAdding method of class Agent in Agents.py: def _objectAdding(self,client, _id=_id): print "_objectAdding" i = _id(client) l = self._v_tranlog c = l.get(i) if c is None: l[i] = AddedStatus, client, None return s,c,m = c # XXX Hack to make "add" triggers work if s is ChangedStatus: l[i] = AddedStatus, client, m # XXX if s is DeletedStatus: l[i] = ChangedStatus, client, m return I'm not sure whether this will have any nasty side-effects though. -- 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 )
[Zope-dev] ZPatterns: Errors in triggered methods + patch
Latest ZPatterns release. Zope 2.2b4. If I raise an error in an external method that is called by a GenericTrigger, I sometimes get a strange log message: 2000-07-12T15:20:07 ERROR(200) ZODB Couldn't load state for '\000\000\000\000\000\000\021=' Traceback (innermost last): File .../lib/python/ZODB/Connection.py, line 441, in setstate File .../lib/python/ZODB/FileStorage.py, line 584, in load (Object: .../var/Data.fs) File .../lib/python/ZODB/FileStorage.py, line 560, in _load (Object: .../var/Data.fs) KeyError: p= (Repeated four further times.) (I replaced the path to my zope installation with "...".) Sometimes, the characters after the "KeyError:" will be control characters, and will cause further log output to look like gibberish, until I suspend the Zope process and type "reset" at the xterm console. I'm not sure why this happens. I've had another similar log message from the same sort of cause: 2000-07-12T14:44:01 PANIC(300) ZODB A storage error occurred in the last phase of a two-phase commit. This shouldn't happen. The application may be in a hosed state, so we will not allow transactions to commit from here on Traceback (innermost last): File .../lib/python/ZODB/Transaction.py, line 296, in commit File .../lib/python/Products/ZPatterns/Transactions.py, line 108, in tpc_finish File .../lib/python/Products/ZPatterns/Transactions.py, line 135, in end_tran File .../lib/python/Products/ZPatterns/DataManagers.py, line 118, in _cleanup (Object: Transactional) File .../lib/python/ZODB/Connection.py, line 441, in setstate File .../lib/python/ZODB/FileStorage.py, line 584, in load (Object: .../var/Data.fs) File .../lib/python/ZODB/FileStorage.py, line 560, in _load (Object: .../var/Data.fs) KeyError: p I guess the methods that GenericTriggers call aren't supposed to throw exceptions. However, as a safeguard, how about changing the _checkpoint() method of Agents.Agent to this: def _checkpoint(self): # Send 'final' versions of events try: for s,c,m in self._v_tranlog.values(): try: if s is ChangedStatus: self._objectChanged(c,m) elif s is AddedStatus: self._objectAdded(c) else: self._objectDeleted(c,m) except: import sys, traceback, string type, val, tb = sys.exc_info() sys.stderr.write(string.join( \ traceback.format_exception(type, val, tb),'')) del type, val, tb finally: self._v_tranlog.clear() I've put the call to each Agent's "change observed" event in a try-except block. This makes my Zope instance happier when I do stupid things in external methods, and has the additional advantage of insulating other Agents from one particular Agent's problems. -- 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 )
[Zope-dev] Re: ZPatterns: Errors in triggered methods + patch
Steve Alexander wrote: > > Latest ZPatterns release. Zope 2.2b4. > > If I raise an error in an external method that is called by a > GenericTrigger, I sometimes get a strange log message: > I've put the call to each Agent's "change observed" event in a > try-except block. This makes my Zope instance happier when I do stupid > things in external methods, and has the additional advantage of > insulating other Agents from one particular Agent's problems. Of course, a patch that made a suitable log entry would be better than what I just posted to the list, which just writes the execption and traceback to stderr. -- 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] ZPatterns -- trigger add events not working
"Phillip J. Eby" wrote: > > It could cause a problem if the object is added after any other sort of > change from the point of view of the Agent. The Agent would view it as > having been added, when in fact it is actually merely changed. I have not, > however, been able to think of any scenario where this condition could > occur unless the DataManager containing the Agent was itself being > reconfigured during the same transaction as the other events, which is an > "all bets are off, hold onto your butts" type proposition anyhow. > > My guess is that your patch will probably work fine. I've checked it in > locally and will incorporate it into a release soon. The other approach would be to hold a list of the events that have happened during a transaction, and have a simple set of rules (regular grammar, implemented as a state machine, or regular expression) for condensing a list of events into the overall description of the event. I just made this regular grammar up without thinking particularly hard about them. The letters D, C, A stand for Delete, Change and Add respectively. "C*" means zero or more repeated "C". C*: C CA: A DA: C AC: A C*D : D AD: D Then again, if you can't think of any but the most unlikely exceptions to the current simple algorithm, I'll go with that :-) -- 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 )
[Zope-dev] ZPatterns: missing docstring in getItem()
ZPatterns 0.4.0a4 The file "version" reports it to be "ZPatterns-0-4-0a1". That gave me a shock! I thought for a moment that I'd been working on an obsolete edition :-) Specialists.py, line 28, method getItem() needs a docstring. -- 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] Beginning Zope User
Hi John, John Gunnar Carlsson wrote: > > Help! I downloaded a product and uploaded it to my directory, but I don't > know how to unzip it. I'm using NT. Whenever I load WinZip it will only > let me unzip it to local places on the hard disk but nowhere on the Zope > directory itself. > > ___ > Zope-Dev maillist - [EMAIL PROTECTED] I'd really like to help you with this, but there's two reasons that I can't right now. 1: You've posted this message to the [EMAIL PROTECTED] mailing list. This list is for discussion about developing the innards of Zope and really technical stuff like that. The correct mailing list for your question is the more general [EMAIL PROTECTED] 2: I'm not sure what you're asking. When you ask again in [EMAIL PROTECTED], be sure to say all of the following: * Exactly which version of Zope you have installed * Where on your harddisk you have installed it * What the product is you have downloaded * Exactly the steps you have tried to follow to install the software * What documentation you are getting your steps from, and where you got that documentation from This might all sound like a lot, but it really is the minimum I'd need in order to be able to answer your question correctly. Also, if you ask on [EMAIL PROTECTED], others who might have a similar problem will benefit from any answer. -- 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] ZPatterns: missing docstring in getItem()
"Phillip J. Eby" wrote: > > Changes checked in. I should be releasing an alpha5 tomorrow. That's great. Did you get my message about errors in triggered methods? I realised that I only sent it to the zope-dev list, and not cc-ed to you. > I had hoped to finish my work on proxy roles, ZClass plugins, Does that increase the number of "Waaa!" comments in the code? > and maybe even my local-roles stuff first and make it a "beta" release, *If* you get time, can you put a note on the ZPatterns Wiki, or to the zope-dev mailing list briefly describing what proxy roles, and local roles mean in the context of ZPatterns? Thanks. (Of course, if any other ZPatterns gurus can answer that...) -- 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] External Method Missery
Chris Withers wrote: > > Shane Hathaway wrote: > > Here's the logic: ExternalMethod sets up func_* attributes so it can > > masquerade as a function. The trick works well enough to convince > > ZPublisher's mapply() to pass in a "self" argument as the first > > argument when needed. > > What 'self' does mapply pass? I always though it would be the object > being rendered (the one that would appear before PARENTS[0] in PARENTS > if such a thing were possible ;-) but it appears to in fact be > PARENTS[0]. > > ...which seems silly Ah... but are you calling the external method from a DTML method? These are all methods, and therefore you'd expect the "self" object to be the object the methods are subobjects of. -- 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 )
[Zope-dev] ZPatterns: BTree folder w/ customizer support
I want to combine Shane Hathaway's BTreeFolder product with ZPatterns to create a "BTree folder w/ Customizer support". This has obvious advantages over the current "Folder w/ Customizer support" when you have a large number of DataSkin subobjects, both in terms of performance, and in terms of user-interface. The easiest way for me to do this would be to ask Phillip to make such a thing a standard part of ZPatterns :-) This is a little more difficult to do as a separate product, without lots of cut-and-paste reuse. (At least, it seems that way at first site.) the problem is that the inheritance heirarchy for CustomizerFolder (meta_type is "folder w/ customizer support") is like this: PlugInBaseFolder ^ ^ |___| | PlugInContainer ^ | CustomizerFolder Without seriously delving into the code, I think I'd have to reimplement PlugInContainer. Instead, why not make PlugInContainer a mix-in class, and have concrete classes for PlugInFolder and PlugInBTreeFolder ? Then, it is easy to have a CustomizerFolder and a CustomizerBTreeFolder. Then again, I wouldn't mind if things stay as they are, except that PlugInContainer is made to derive from BTreeFolder rather than Folder. Of course, that creates a dependency that you need the BTreeFolder product in order to use ZPatterns. -- 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] ZPatterns: BTree folder w/ customizer support
Steve Alexander wrote: > > I want to combine Shane Hathaway's BTreeFolder product with ZPatterns to > create a "BTree folder w/ Customizer support". > Instead, why not make PlugInContainer a mix-in class, and have concrete > classes for PlugInFolder and PlugInBTreeFolder ? > > Then, it is easy to have a CustomizerFolder and a CustomizerBTreeFolder. > > Then again, I wouldn't mind if things stay as they are, except that > PlugInContainer is made to derive from BTreeFolder rather than Folder. > Of course, that creates a dependency that you need the BTreeFolder > product in order to use ZPatterns. Or... I could alter Shane's BTree Folder product to split it into a mix-in class and a usable folder class. Would that work, I wonder? -- 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] Uploading a ImageFile
Andre Schubert wrote: > > Hi, > > i have a question on uploading an image from my Product. > I have a Product in http://server:8080/somewhere/Product. > In my Product i call: > self._setObject(id, File(id,title,'',content_type, > precondition)) > self._getOb(id).manage_upload(file) > Now the image is on http://server:8080/somewhere/Product/image right? > > But i want the following: > > The Product at http://server:8080/somewhere/Product at the uploaded > Image should be stored at > http://server:8080/anotherplace/images/ . Let's look at what these two lines mean. self._setObject(id, File(id,title,'',content_type, precondition)) This line adds a new object to the "self" object. Instead, you should replace "self" with a reference to the object that you want to put the image in. self._getOb(id).manage_upload(file) This line gets the newly-created image object from "self", and fills it with image data. You'll want to replace "self" with that same reference you replaced it with in the last line. -- 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] ZPatterns: missing docstring in getItem()
"Phillip J. Eby" wrote: > > >That's great. Did you get my message about errors in triggered methods? > > Yes, I did, but the solution requires some more thought. I had thought I > had the "Transactional" machinery set up so that stuff was only called > during transaction phases where it was safe to throw errors. So I'm going > to have to go back and review that. However, I also think that errors in > triggers should result in a rollback-and-abort, rather than silently > failing, which could cause many other problems. Right. So the application designer has the choice of whether to put their methods that are called by GenericTriggers in try-except blocks, if it doesn't matter if the trigger fails. But it is generally assumed that triggers need to run without exceptions for the application to work consistently. -- 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 )
[Zope-dev] Making Folders callable
Is there any reason that Folders aren't callable? That is, you can't directly render a folder with . You have to do something like . But, that's not quite the same because if the folder lacks an index_html, it gets acquired. Here's an extra method that can be added to lib/python/OFS/Folder.py, or to ObjectManager.py, to make Folders render nicely. # XXX hack to make folders render # retains compatibility with current behaviour # if the folder doesn't contain index_html def __call__(self, *args, **kw): """ mandatory docstring """ index = self._getOb('index_html', default=None) if index is not None: args = (self,) + tuple(args[1:]) return apply(index, args, kw) return '' Is this a good idea? Should this go into the Collector as an RFE with patch? Actually, I'm not sure why it should be tuple(args[1:]) -- I just copied that out of ZCallable in the latest PTK CVS. I'd guess you'd want to check the first argument (client) for whether it is None before replacing it with self. Perhaps something like this: args = (len(args)>0 and args[0] or self,) + tuple(args[1:]) Discussion welcomed. -- 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 )
[Zope-dev] Re: ZCallable
Chris Withers wrote: > > Yup, > > This looks good, as did your earlier post. However, it raises a question > :( > > Something like a ZCatalog or a Squishdot Site (which I have a passing > interest in ;-) are both folderish. However, their __call__ method does > something quite different: it returns the results of searching the catalog > (I think this is the ZSearchable Interface, correct me if I'm wrong ;-) > > I guess what's bothering me is why __call__ has this dual role and how the > rendering process manages to correctly render index_html even on a > Squishdot object which is actually callable? I just looked over the source to ZCatalog. I'm pretty sure that __call__ has nothing to do with any index_html you might add to a catalog. The __call__ method is what gets invoked when you call the method, either through the magic of or with . If Catalog has an index_html, or acquires one, then that is what gets rendered when you go to the URL http://mysite.tld/foo/Catalog -- actually, it seems that the effective URL is http://mysite.tld/foo/Catalog/index_html. Therefore, if you don't have an index_html, it gets acquired. This behaviour is set in lib/python/ZPublisher/BaseRequest.py, method traverse(), line 257. (I'm using 2.2 final). # Set the default method if method=='GET' or method=='POST': method='index_html' else: baseflag=1 and later on, at line 300. elif (method and hasattr(object,method) and entry_name != method and getattr(object, method) is not None): request._hacked_path=1 entry_name = method So, if you're getting or posting, you effectively get "index_html" appended to your URL. This way of doing things allows individual classes to define protocol handlers for other protocols they wish to support -- such as the PUT() method in DTMLMethod.py. Thus, index_html() is the protocol handler for GET and POST. This mechanism is pretty much separate from the __call__ mechanism. In conclusion, I can't see any disadvantage to making Folder callable as I suggested in a previous message. It doesn't appear to break anything :-) > Hmm... I guess the implication of this is that a normal folder will never > render itself to avoid confusion over the ZSearch interface and so if I > want this behaviour I'll have to roll-my-own folder which inherits from > ZCallable. I'm not sure your paragraph above makes sense in light of what I've said above. > PS: Shane: what's the difference between ZCallable and the ZRenderable > base class that Maik Roeder mentioned on [EMAIL PROTECTED] a few days back? IIRC, ZRenderable lets you choose what method you want __call__ to forward to, whereas ZCallable always chooses the method index_html, if it exists. -- 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] Optimization and speed
Stephan Richter wrote: > > I have a pretty big site with quiet a big database (PostGreSQL) in the > background. When a site loads I can tell that after about 5 seconds the > site is ready to download. The site downloads quickly thereafter if I am on > a T1, DSL or Cable Modem connection. But since most of our users have 28.8k > and 56k modem connection, we have to optimize for them too. > When accessing the site over a modem, it takes a long time to load the site > and then it pops up all at once (in IE (AOL) and Netscape). Is there a way > that I can send parts of the HTML as it is generated, so that the customer > starts seeing information before the entire site is loaded. At the HTML level, are your pages in one big table? If so, Netscape will often need to wait until the whole contents of the table is downloaded before attempting to render it. To get around this, you need to specify the size of just about **everything** in the table. I think it is the same with IE too. Mozilla doesn't have that problem, with its incremental layout. Can you see the stream of data coming if you telnet to your server and type GET / HTTP/1.0 or whatever? Is it just that the rendering is slow because some part of the page is slow to load? -- 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] Optimization and speed
Stephan Richter wrote: > > >Can you see the stream of data coming if you telnet to your server and > >type GET / HTTP/1.0 or whatever? Is it just that the rendering is slow > >because some part of the page is slow to load? > > You got the hit. It does not stream the page out. It sits there and then > suddenly pushes the entire site out. Do you know what settings I would need > to tweak to fix that? lib/python/ZPublisher/BaseResponse.py def write(self,data): """\ Return data as a stream HTML data may be returned using a stream-oriented interface. This allows the browser to display partial results while computation of a response to proceed. The published object should first set any output headers or cookies on the response object. Note that published objects must not generate any errors after beginning stream-oriented output. """ Looks like it's more that just a tweak, though :-( -- 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] Optimization and speed
Stephan Richter wrote: > > > > > >Looks like it's more that just a tweak, though :-( > > So, how can I use this method? I do not understand the internals of the > ZServer completely. You've got a RESPONSE object. For HTTP stuff, it will be a HTTPResponse as defined in lib/python/ZPublisher/HTTPResponse.py. You can use the write(self, data) method of this response object to stream data directly to your client, independent (to a degree) of Zope's transaction processing. This is the method from HTTPResponse. def write(self,data): """\ Return data as a stream HTML data may be returned using a stream-oriented interface. This allows the browser to display partial results while computation of a response to proceed. The published object should first set any output headers or cookies on the response object. Note that published objects must not generate any errors after beginning stream-oriented output. """ if not self._wrote: self.outputBody() self._wrote=1 self.stdout.flush() self.stdout.write(data) So, you could set output headers and cookies as needed, then, before the rest of the processing on your page, have a . Then again, I've never tried this. YMMV and all that. (*off to help cook... won't be reading email for a while*) -- 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 )
[Zope-dev] ZPatterns: Coad "Object Models"
Hi Folks, After the ZPatterns chat on Friday, it looked like a few people were thinking of getting into Peter Coad's book "Object Models: Strategies, patterns and applications". I've just received my copy, and I'll be starting it later today. I intend to use a Wiki to record my observations and thoughts about the book, as I read it. I'd like this to be a collaborative learning thing, so anyone else who is reading the book, or who as read it, is most welcome to join in. http://www.zope.org/Members/stevea/CoadObjectModels There's not much up there right now, as I've only read the Acknowledgements at the front :-) -- 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] Multi-homed objects?
Oleg Broytmann wrote: > > On Mon, 17 Jul 2000, Chris Withers wrote: > > How does it work in Unix? (that seems to be a good baseline :-) > >On UNIX symlink is not a link - it is a text file, that contains a name > of resource. The name could points to nowhere, or to resource, even to > other symlink... So, it is up to the operating system to interpret the soft link and redirect accordingly. Shane's soft-link code looks like the object-oriented equivalent; a bit of text that knows where to redirect callers to. -- 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 )
[Zope-dev] Zope crashing on
Zope 2.1.6 I'm using a "walk the tree" method of updating instances of a Python class, using an external method. Is there any reason that the following excerpt from an external method would cause Zope to crash shortly after it's been run on all suitable objects? The crash happens when I try to see one of the converted objects in my browser. def update_state(self): item = getattr(self, 'aq_base', self) item.content_state=PersistentMapping({'review':'public'}) item.review_state=ComputedAttribute(\ lambda self: self.content_state['review']) It seems to do something nasty to ZODB. I need to truncate Data.fs to get Zope working again. Perhaps I'm misunderstanding something about ComputedAttributes... -- 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] Redirecting from the manage interfaces.
Chris Withers wrote: > > Why I'm asking is 'cos it'd be really nice not to have to keep > re-writing UI when there's perfectly good stuff available in the > management interface, things like add forms, edit forms, etc... > > However, if you call these from anywhere else, they dump you in the > management interface when you're finished rather than going to where you > want them to. > > Any ideas or am I missing the point? Silly idea: Write a wrapper that you put around the RESPONSE object that does its own thing when it is told to redirect. You might have to wrap the REQUEST object too, so that it returns a wrapped RESPONSE object. -- 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] getting request variables values
Leonardo Kenji Shikida wrote: > > here it is. Try using instead. > Kenji > > >>>>>>>>>>> > SSL_CLIENT_IEMAIL [EMAIL PROTECTED] -- 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] getting request variables values
Chris Withers wrote: > > Evan Simpson wrote: > > The value you're after is stored in the 'environ' section of the request. > > Unlike 'other' and 'cookies' keys, 'environ' keys can't generally be fetched > > as attributes or keys of REQUEST. You need to access them as > > REQUEST.environ['keyname']. > > Heh, I thought so, I presume REQUEST.get won't get out of environ > either? > > I posted this in the collector and was told it behaved as expected (and > would suck the key out of any of the sub-dictionaries) > > What's the real story? ;-) I'm looking at 2.2.0final. >From the comments in the code, it *ought* to look in the environment first. def __getitem__/__getattr__ from HTTPRequest.py: """Get a variable value Return a value for the required variable name. The value will be looked up from one of the request data categories. The search order is environment variables, other variables, form data, and then cookies. """ However, looking in the code, it starts off by looking in "other", and doesn't look in "environ" at all. I suggest a patch to go right after the method's docstring: def __getitem__(self,key, default=_marker, # Any special internal marker will do URLmatch=regex.compile('URL[0-9]+$').match, BASEmatch=regex.compile('BASE[0-9]+$').match, ): """Get a variable value Return a value for the required variable name. The value will be looked up from one of the request data categories. The search order is environment variables, other variables, form data, and then cookies. """ #" + environ=self.environ + if environ.has_key(key): + return environ[key] other=self.other if other.has_key(key): if key=='REQUEST': return self return other[key] -- 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] getting request variables values
Steve Alexander wrote: > > However, looking in the code, it starts off by looking in "other", and > doesn't look in "environ" at all. > > I suggest a patch to go right after the method's docstring: > > def __getitem__(self,key, > default=_marker, # Any special internal marker will > do > URLmatch=regex.compile('URL[0-9]+$').match, > BASEmatch=regex.compile('BASE[0-9]+$').match, > ): > """Get a variable value > > Return a value for the required variable name. > The value will be looked up from one of the request data > categories. The search order is environment variables, > other variables, form data, and then cookies. > > """ #" > + environ=self.environ > + if environ.has_key(key): > + return environ[key] > other=self.other > if other.has_key(key): > if key=='REQUEST': return self > return other[key] Ok... I was wrong :-/ A bit later we have: if isCGI_NAME(key) or key[:5] == 'HTTP_': environ=self.environ if environ.has_key(key) and (not hide_key(key)): return environ[key] return '' I was only sort-of wrong though :-) The code certainly doesn't stick exactly to its docstring. The "other" dictionary is seached first, then URLx where x is a number. Then "environ" is searched, but *only* if the key begins with 'HTTP_' or is in the following list: SERVER_SOFTWARE, SERVER_NAME, GATEWAY_INTERFACE, SERVER_PROTOCOL, SERVER_PORT, REQUEST_METHOD, PATH_INFO, PATH_TRANSLATED, SCRIPT_NAME, QUERY_STRING, REMOTE_HOST, REMOTE_ADDR, AUTH_TYPE, REMOTE_USER, REMOTE_IDENT, CONTENT_TYPE, CONTENT_LENGTH, SERVER_URL Looking in Leonardo's sample environment, a posted to this list, there's a lot of keys that won't get matched: SSL_* HTTPS_* REMOTE_PORT SERVER_ROOT SERVER_SIGNATURE My question is "why was __getitem__ of HTTPRequest.py designed this way?". Is there a good reason that it filters the keys according to membership of a standard-cgi-keys list, or whether they start with 'HTTP_' ? Would there be any disadvantage to altering __getitem__ so that it behaves according to its docstring? If so, the patch would probably be something like: line 753. """ #" + environ=self.environ + if environ.has_key(key) and (not hide_key(key)): + return environ[key] other=self.other if other.has_key(key): if key=='REQUEST': return self return other[key] if key[:1]=='U' and URLmatch(key) >= 0: path = self._script + self._steps n = len(path) - atoi(key[3:]) if n < 0: raise KeyError, key URL=join([other['SERVER_URL']] + path[:n], '/') other[key]=URL self._urls = self._urls + (key,) return URL - if isCGI_NAME(key) or key[:5] == 'HTTP_': - environ=self.environ - if environ.has_key(key) and (not hide_key(key)): - return environ[key] - return '' Comments? -- 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] getting request variables values
Steve Alexander wrote: > > My question is "why was __getitem__ of HTTPRequest.py designed this > way?". > > Is there a good reason that it filters the keys according to membership > of a standard-cgi-keys list, or whether they start with 'HTTP_' ? > Would there be any disadvantage to altering __getitem__ so that it > behaves according to its docstring? ...although the class docstring says that the environment variable names are as in the CGI specification (http://hoohoo.ncsa.uiuc.edu/cgi/env.html). It doesn't say that they should **only** be from the CGI specification, though. -- 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] Problem acquiring via a newly created object
Steve Alexander wrote: > > Richard Barrett wrote: > > > > My classes (and some others yet to be written) are intended for use > > when requirements stipulate that published material must be > > held/protected in RCS as well as being served via Zope. I've elected > > to put an attribute called 'web_RCS_root' at the top of the Zope > > object hierarchy which contains the server local file system path > > under which files to be held by RCS. > > http://www.zope.org/Members/sspickle/ZCVSMixin Screenshots linked from here: http://www.zope.org/Members/sspickle -- 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] Problem acquiring via a newly created object
Richard Barrett wrote: > > My classes (and some others yet to be written) are intended for use > when requirements stipulate that published material must be > held/protected in RCS as well as being served via Zope. I've elected > to put an attribute called 'web_RCS_root' at the top of the Zope > object hierarchy which contains the server local file system path > under which files to be held by RCS. http://www.zope.org/Members/sspickle/ZCVSMixin Perhaps this product will help. You might be able to use CVS instead of RCS, or you may find that Steve Spicklemire has solved some of the problems already. -- 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 )
[Zope-dev] DateTime.py
There's a problem with strftime() in DateTime.py. Try this DTML method to see: Time: Time: Time: Bad Time: Time: Time: Time: Time: Time: Time: Note that the time given in the line "Bad Time:" above is actually wrong -- it reports itself to be in GMT, but gives the time as one hour behind. If you specify a date as /MM/DD, then the date that is stored is (quite reasonably) midnight on that day, in your timezone. This gets rendered back into days correctly for methods such as DateTime.day(), as these methods directly ask the DateTime instance for what it thinks the day is. The instance replies in the context of its own timezone (as given in the constructor, or the local timezone if none was given), and so it returns the expected result. If you use the strftime() method, by using fmt="%d %H %Z" or whatever, instead of asking the DateTime instance to do the formatting, the formatting is delegated to the Python time module. Unfortunately, at any particular time, the Python "time" module only knows about two timezones: Your local one (with and without daylight savings) and GMT. Therefore, in any other timezones, Pythons time.strftime() cannot correctly render the time. This is particularly apparent in the current DateTime.py, because its strftime method just interprets the internal representation of the time as GMT, whatever. We can fix this easily: *** lib/python/DateTime/DateTime.py Sun Jul 23 20:03:05 2000 --- lib/python/DateTime/DateTime.old.py Sun Jul 23 20:03:04 2000 *** *** 1376,1382 return millis def strftime(self, format): ! return strftime(format, gmtime(self.toZone('GMT').timeTime())) # General formats from previous DateTime def Date(self): --- 1376,1382 return millis def strftime(self, format): ! return strftime(format, gmtime(self.timeTime())) # General formats from previous DateTime def Date(self): Now, at least, the time will be reported correctly, although not really usefully if you want to have the time formatted in the timezone given to the DateTime instance. Also, this patch will cause formatting calls to create a new DateTime instance if the instance you want to format is not in timezone GMT+0. The only general solution that I can see is to replicate the formatting algorithms of the time module in DateTime.py, but written so that they take account of timezones. There is another issue: When I call _.DateTime('2000-07-23'), what do I mean? The current implementation of DateTime interprets that as "midnight (the earliest possible time) on 2000-07-23, interpreted in the local timezone". However, if I'm being naive, I might think that I'm refering to a Day, and that the Day should be the same day no matter what timezone I put it into. In that case, the DateTime module needs rewriting to have a sense of precision built into it: If I specify a time to the day, I get the latter behaviour. If I specify the time more precisely, I get the current behaviour. Another approach would be to make _.DateTime('2000-07-23') mean Midday, GMT rather than Midnight, local time. That would give the latter behaviour for most timezones at most times; the exceptions being places near the international date line that are in daylight savings time. -- 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] DateTime.py -- ignore the patch
Steve Alexander wrote: > > This is particularly apparent in the current DateTime.py, because its > strftime method just interprets the internal representation of the time > as GMT, whatever. > > We can fix this easily: > > *** lib/python/DateTime/DateTime.py Sun Jul 23 20:03:05 2000 > --- lib/python/DateTime/DateTime.old.py Sun Jul 23 20:03:04 2000 > *** > *** 1376,1382 > return millis > > def strftime(self, format): > ! return strftime(format, gmtime(self.toZone('GMT').timeTime())) > > # General formats from previous DateTime > def Date(self): > --- 1376,1382 > return millis > > def strftime(self, format): > ! return strftime(format, gmtime(self.timeTime())) > > # General formats from previous DateTime > def Date(self): > > Now, at least, the time will be reported correctly, although not really > usefully if you want to have the time formatted in the timezone given to > the DateTime instance. No, no, no! Ignore the patch, it is a placebo :-/ I should read these things back more carefully... The bit about reimplementing time.strftime() in DateTime.py still holds though. -- 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] DateTime.py -- ignore the patch
Steve Alexander wrote: > > No, no, no! > > Ignore the patch, it is a placebo :-/ > I should read these things back more carefully... > > The bit about reimplementing time.strftime() in DateTime.py still holds > though. In brief, though -- and hopefuly clearer this time: If you format DateTimes using strftime (that is, fmt="%d %m" and so forth), you can only have the time rendered in GMT. This is confising the counter-intuitive, as the internal timezone of the DateTime instance is not preserved. The only reasonable way around this is to reimplement the strftime function of Python's time module in DateTime.py, but have it take account of timezones. As another issue, when you create a new DateTime instance with _.DateTime('-MM-DD'), the actual time stored is midnight in your local timezone. A more useful default time would be midday, GMT. This shouldn't break much code, as the current behaviour isn't well documented and is arguably broken anyway. -- 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 )
[Zope-dev] DateTime formatting with strftime: patch
Here's a working patch to make formatting of a DateTime instance work as generally expected, when you use or whatever. It could be made more efficient by compiling the two regex (regexes? regexen? regular expressions :-) ) into class attributes. Here's the method I changed: def strftime(self, format): diff=_tzoffset(self._tz, self._t) format = ts_regex.gsub('\(^\|[^%]\)%Z', '\\1'+self._tz, format) format = ts_regex.gsub('\(^\|[^%]\)%z', '\\1%+05d' % (diff/36), format) return strftime(format, gmtime(self.timeTime()+diff)) Instead of just calling gmtime with the time as held in the DateTime instace, it subverts time.strftime into formatting the time shifted according to the instance's timezone. Because time.strftime won't format the timezone information correctly, this is done using regular expressions before the format specification string is passed to time.strftime. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net *** lib/python/DateTime/DateTime.old.py Sun Jul 23 20:03:04 2000 --- lib/python/DateTime/DateTime.py Mon Jul 24 14:01:37 2000 *** *** 1376,1382 return millis def strftime(self, format): ! return strftime(format, gmtime(self.timeTime())) # General formats from previous DateTime def Date(self): --- 1376,1385 return millis def strftime(self, format): ! diff=_tzoffset(self._tz, self._t) ! format = ts_regex.gsub('\(^\|[^%]\)%Z', '\\1'+self._tz, format) ! format = ts_regex.gsub('\(^\|[^%]\)%z', '\\1%+05d' % (diff/36), format) ! return strftime(format, gmtime(self.timeTime()+diff)) # General formats from previous DateTime def Date(self):
Re: [Zope-dev] Incorrect Padding?
Chris Withers wrote: > > Does anyone know what this means? > > The page views fine for me and this is the first error of this type I've > seen since we launched the archives. I wonder what WebWhacker is doing > to cause this? Well... you can get an incorect padding error like this: >>> import binascii >>> binascii.a2b_base64('a ') Traceback (innermost last): File "", line 1, in ? binascii.Error: Incorrect padding You can also get by adding arbitrary non-space characters to the end of a basic authentication string. Here's the line that'll be causing the problem. (Zope 2.2final, lib/python/AccessControl/User.py line 441) name,password=tuple(split(decodestring(split(auth)[-1]), ':', 1)) My guess is that the argument "auth" passed to validate() has some trailing characters. Either that, or WebWhacker passed just "Basic " as an auth string. Maybe log the auth argument and re-whack your site. (Warning... this is certainly a nasty security hole. Be sure to get rid of the logging afterwards.) -- 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] Incorrect Padding?
Chris Withers wrote: > > Steve Alexander wrote: > > My guess is that the argument "auth" passed to validate() has some > > trailing characters. Either that, or WebWhacker passed just "Basic " as > > an auth string. > > Yuk, that sounds like a Zope bug. Collector time with patch? A judicious > string.strip should solve the problem, surely? >>> from base64 import decodestring >>> from string import * >>> auth="Basic" >>> tuple(split(decodestring(split(auth)[-1]), ':', 1)) Traceback (innermost last): File "", line 1, in ? File "/usr//lib/python1.5/base64.py", line 46, in decodestring decode(f, g) File "/usr//lib/python1.5/base64.py", line 32, in decode s = binascii.a2b_base64(line) binascii.Error: Incorrect padding The problem is in the expression "split(auth)[-1]". If the auth string contains no space but at least one character, then split(auth)[-1] == split(auth)[0]. Perhaps what we should do is change this (lib/python/AccessControl/User.py, line 438) # Only do basic authentication if lower(auth[:6])!='basic ': return None name,password=tuple(split(decodestring(split(auth)[-1]), ':', 1)) to this: # Only do basic authentication if lower(auth[:6])!='basic ' and len(auth)>6: return None name,password=tuple(split(decodestring(split(auth)[-1]), ':', 1)) or even: # Only do basic authentication if lower(auth[:6])!='basic ': return None name,password=tuple(split(decodestring(auth[6:]), ':', 1)) (Need to check the last one with the RFC -- are you allowed anything else other than "basic blarglebase64usernamepassword" ? ) > > Maybe log the auth argument and re-whack your site. (Warning... this is > > certainly a nasty security hole. Be sure to get rid of the logging > > afterwards.) > > I didn't whack my site, I just got mailed the error... Well... try whacking yourself and see what the whacker actually sends -- we're just guessing until then. -- 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 )
[Zope-dev] ts_regex.gsub() doesn't work with compiled expressions
I'm trying to do the following: >>> import ts_regex >>> Z=ts_regex.compile('\(^\|[^%]\)%Z') >>> ts_regex.gsub(Z, '\\1BAR', '%Z foo %Z') Traceback (innermost last): File "", line 1, in ? File "/usr/local/zope/SiteBox/lib/python/ts_regex.py", line 109, in __call__ try: return apply(self._f, args, kw) File "/usr//lib/python1.5/regsub.py", line 38, in gsub regs = prog.regs AttributeError: regs This works just fine if you don't compile the regex first: >>> import ts_regex >>> ts_regex.gsub('\(^\|[^%]\)%Z', '\\1BAR', '%Z foo %Z') 'BAR foo BAR' The problem is that a ts_regex.compile instances do not expose the attribute "regs" that the method gsub of lib/python1.5/regsub.py requires. I don't know the details of what is thread-safe and what is not in the regsub module, so I won't hazard a patch here. Perhaps overriding __getattr__ to return "regs" safely would help? I don't know. I can also get it to work if I pass in the unwrapped compiled regular expression: >>> ts_regex.gsub(Z._r, '\\1BAR', '%Z foo %Z') 'BAR foo BAR' Is doing this in Zope threadsafe? -- 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] DateTime formatting with strftime: patch
This is now in the Collector, as bug number 1457. http://classic.zope.org:8080/Collector/1457/view Incidentally, http://classic.zope.org:8080/Collector/1409/view is another patch to the same problem. However, that patch doesn't address the root of the problem, which is that DateTime instances are associated with a particular timezone, and users expect all formatting to occur with respect to that particular timezone. The fix in collector #1409 makes all strftime formatting happen in the local timezone of the Zope installation, not the timezone given in the particular DateTime instance being formatted. Steve Alexander wrote: > > Here's a working patch to make formatting of a DateTime instance work as > generally expected, when you use > > > > or whatever. > > It could be made more efficient by compiling the two regex (regexes? > regexen? regular expressions :-) ) into class attributes. There's a problem with this optimisation -- see my other posting to zope-dev today. -- 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] Incorrect Padding?
Chris Withers wrote: > > Chris Withers wrote: > > > > Steve Alexander wrote: > > > My guess is that the argument "auth" passed to validate() has some > > > trailing characters. Either that, or WebWhacker passed just "Basic " as > > > an auth string. > > > > Yuk, that sounds like a Zope bug. Collector time with patch? A judicious > > string.strip should solve the problem, surely? > > PS: > > A string.upper wouldn't go amiss either, then earlier versions of > Mozilla that send an incorrectly capitalised 'Basic' might also be > allowed to authenticate with Zope :-) It is already there in 2.2final: if lower(auth[:6])!='basic ': ^ RFC 1945 has it as "Basic". http://www.freesoft.org/CIE/RFC/1945/67.htm I also checked, and this version of the patch *should* work: # Only do basic authentication if lower(auth[:6])!='basic ': return None name,password=tuple(split(decodestring(strip(auth[6:])), ':', 1)) The "strip" is in there just in case a client responds with "basic base64blah" instead of "basic base64blah". However, it still doesn't work if the client sends something bogus -- the tuple will only be one item long, rather than two. If you want to be protected against bogosity in basic authentication, you can stick with the original line, and put it inside a try-except block: # Only do basic authentication if lower(auth[:6])!='basic ': return None try: name,password=\ tuple(split(decodestring(split(auth)[-1]), ':', 1)) except: # Bogus basic authentication. Perhaps log something? return None -- 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] Incorrect Padding?
Martijn Pieters wrote: > > RFC 1945 says one paragraph before that that the header should be matched > case-insensitively. That was what the Moz bug was all about. Thanks for the clarification. > > # Only do basic authentication > > if lower(auth[:6])!='basic ': > > return None > > name,password=tuple(split(decodestring(strip(auth[6:])), ':', > > 1)) > > > > > > The "strip" is in there just in case a client responds with > > > > "basic base64blah" instead of > > "basic base64blah". > > The split already takes out the whitespace. No need to strip. There's a base64.decodestring() between the strip and the split. Leading and/or trailing spaces make base64 strings invalid. -- 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] Incorrect Padding?
Martijn Pieters wrote: > > Oops. You took out the strip. But IIRC, base64 does a strip as well. So it does! >>> from base64 import * >>> s = encodestring('foo') >>> decodestring(s) 'foo' >>> decodestring(s+' ') 'foo' >>> decodestring(' '+s) 'foo' -- 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] Incorrect Padding?
Chris Withers wrote: > > So what was causing the original error then? string.split('basic')[-1] was returning 'basic'. base64.decodestring('basic') causes an "Incorrect padding" error. base64.decodestring('basic ') causes an "Incorrect padding" error too. Martijn Pieters wrote: > We partly agree, and this is tricky. Unauthorised is wrong, it should return a > Bad Request (or whatever the correct HTTP error is in this case). File a > patch! =) I've attached a patch to lib/python/AccessControl/User.py. If there are no suggestions of improvements, or complaints :-) I'll stick it into the Collector. I looked over the RFC, and Bad Request seems to be the best response code. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net *** lib/python/AccessControl/User.py.original Mon Jul 24 20:31:40 2000 --- lib/python/AccessControl/User.pyMon Jul 24 20:51:33 2000 *** *** 438,444 # Only do basic authentication if lower(auth[:6])!='basic ': return None ! name,password=tuple(split(decodestring(split(auth)[-1]), ':', 1)) # Check for superuser super=self._super --- 438,451 # Only do basic authentication if lower(auth[:6])!='basic ': return None ! try: ! name,password=\ ! tuple(split(decodestring(split(auth)[-1]), ':', 1)) ! except: # not a proper basic auth string ! request.response.setStatus(400) ! raise 'InternalError', request.response._error_html( ! "Internal Error", ! "Zope could not understand the Basic Authentication supplied.") # Check for superuser super=self._super
Re: [Zope-dev] Incorrect Padding?
Martijn Pieters wrote: > > On Mon, Jul 24, 2000 at 08:56:54PM +0100, Steve Alexander wrote: > > I've attached a patch to lib/python/AccessControl/User.py. If there are > > no suggestions of improvements, or complaints :-) I'll stick it into > > the Collector. > > > > I looked over the RFC, and Bad Request seems to be the best response > > code. > > Agreed. > > > *** lib/python/AccessControl/User.py.original Mon Jul 24 20:31:40 2000 > > --- lib/python/AccessControl/User.py Mon Jul 24 20:51:33 2000 > > *** > > *** 438,444 > > # Only do basic authentication > > if lower(auth[:6])!='basic ': > > return None > > ! name,password=tuple(split(decodestring(split(auth)[-1]), ':', 1)) > > > > # Check for superuser > > super=self._super > > --- 438,451 > > # Only do basic authentication > > if lower(auth[:6])!='basic ': > > return None > > ! try: > > ! name,password=\ > > ! tuple(split(decodestring(split(auth)[-1]), ':', 1)) > > ! except: # not a proper basic auth string > > ! request.response.setStatus(400) > > ! raise 'InternalError', request.response._error_html( > > ! "Internal Error", > > ! "Zope could not understand the Basic Authentication supplied.") > > > > # Check for superuser > > super=self._super > > Would it be a good idea to add the header? I don't quite follow. > And let's make that a less generic > except clause, we don't want to mask Zope bugs =) Ok. I was thinking of just using HTTPResponse.badRequestError(). However, it has a "name" argument, and I don't quite understand how it is meant to be used. def badRequestError(self,name): self.setStatus(400) if regex.match('^[A-Z_0-9]+$',name) >= 0: raise 'InternalError', self._error_html( "Internal Error", "Sorry, an internal error occurred in this Zope resource.") raise 'BadRequest',self._error_html( "Invalid request", "The parameter, %s, " % name + "was omitted from the request." + "Make sure to specify all required parameters, " + "and try the request again." ) So, any of name="FOO", name="123", name="FOO123", name="" produces an internal error; name="foo", name="Foo", name="foo123" produces a bad request. What's the rationale? Should I just use this, then? request.response.badRequestError(name="0") # internal error -- 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] ZPatterns
[EMAIL PROTECTED] wrote: > > Hi, > I wonder where I can find lots of information about the Zpatterns. > It seems wonderfull but a little hard to understand. > I want to know exactly how it works and what it does. Use the http://www.zope.org search box to look for "ZPatterns". Unfortunately, there is a problem with that particular search right now. (I've already passed the details on to the zope webmaster.) Also, look here: http://www.zope.org/Members/pje/ZPatterns -- 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] Quickie on ZPatterns ... I promise :)
Bill Anderson wrote: > > Let's say I have an object I will store in a rack. Let us say I want this object to >be > cataloged in a ZCatalog. Any caveats I need to know about > ..such as "Don't do that!" ? > ?;^)= Make one of the object's base-classes DataSkin. Don't make it CatalogAware. Use triggers to index and unindex the object from a catalog. You'll probably want to store the catalog in Specialist. By the way, Phillip Eby has released a new development snapshot: http://www.zope.org/Members/pje/ZPatterns/ZPatterns-0-4-1snap1.tgz/view I'll be trying it later today. -- 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] Re: [Zope] Bi-directional update of Data.fs
chrisw wrote: > > Bill Anderson wrote: > > Since the Data.fs is appended to, and that your disconnected version is > > canonical, why couldn't you basically look for the last common > > transaction, and append all transactions in the canonocial to the main > > one? > > Hwo would that handle the situation where an object has been modified in > data.fs? > Not too well I'd guess... :( Don't see why not. When an object is changed, the new object is just appended to the end of Data.fs. Unless you use undo, or you pack the Data.fs. -- 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] Re: [Zope] Bi-directional update of Data.fs
Chris Withers wrote: > > Steve Alexander wrote: > > Don't see why not. When an object is changed, the new object is just > > appended to the end of Data.fs. Unless you use undo, or you pack the > > Data.fs. > > You missed the problem ;-) > > Technically, there is no problem... > > Logically, what happens if one user updates and object on one machien > and another user on another machines, after which you merge the > data.fs's? > > I'm thinkthing of the things which result in Notes Replication/Save > conflicts... What does Lotus Notes offer to do if you get such a conflict? I'm probably talking rubbish in what follows, because I don't have much of an idea how these things really work... The server has a data.original. You take a copy of this, called data.chris. You use this for a while, and data gets appended to data.chris. Someone else is using the server, and data.original gets appended to. Later, you want to recombine the changes, so you do as follows: Create a data.original.before_fork that is the data.original just before you took the copy data.chris. (You can work this out by looking at the modified data.original and data.chris). Create a list of the combined transactions (in order of time, I guess) that happened on the server, and to data.chris. Within one monsterous transaction, apply the list of combined transactions using the usual under-the-hood ZODB machinery. Use Jim's new conflict resolution algorithm to try to settle conflicts. If a conflict can't be settled, ask interactively, or apply some sort of policy (like "chris always wins" for example) and log the lost changes. -- 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] Bi-directional update of Data.fs
Chris Withers wrote: > > > Use Jim's new conflict resolution > > algorithm to try to settle conflicts. > > Urm? First I heard of this and it sounds like just the right sort of > thing... > > Where can I find out more? http://www.zope.org/Members/jim/ZODB/ApplicationLevelConflictResolution See also: http://www.zope.org/Members/jim/ZODB/ReverseDiffVersioning -- 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 )
[Zope-dev] Re: [Zope-PTK] ZPatterns Documentation
"Phillip J. Eby" wrote: > > Just comment, please, preferably in e-mail via Zope-dev. > Thanks. Generally very clear and helpful. Tomorrow, I'll try it out on someone who hasn't been looking at ZPatterns a great deal, and see what she gets from it. A few suggestions. I feel sad that these seem to come across as criticisms. Really, I'm very glad that you've found some time to work on more accessible documentation. You don't seem to say anything like "You make your own domain-specific classes derive from DataSkin. These can be ZClasses or Python classes". This may be obvious, but I think it is an important part of how data skins are intended to be used. """A data manager helps data skins by: Providing them access to their Data Plug-ins, including propagating transaction events and DataManagementEvents to the Data Plug-ins""" Still very jagon-filled. That's ok, if it is accompanied by some real-world explanation. Perhaps add something like "You can use Data plug-ins for indexing Dataskins in a catalog, or in many catalogs, or [another different familiar example]". """Keeping track of their canonical or "normalized" forms for acquisition management""" You almost lost me there :-) """Or, if a data skin is retrieved from any other Zope object, its __of__ method will try to find a Customizer or "Folder With Customization Support" in the acquisition path, then ask it for a data manager to bind with. Once this is done, the skin remains bound to that manager until the next such occurrence.""" Pretty clear, except the end -- next what occurrence? The next time the data skin is retrieved from a Zope object? So, every time a dataskin is retrieved from a zope object (that isn't a Rack), it uses acquisition to look for a customizer. -- 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] Need for "aq_base" in DTML(was: Re: [Zope] Dumb DTML question - existance check of an object)(was: Re: [Zope] Dumb DTML question - existance check of an object)
Dieter Maurer wrote: > > * Access to "/": "PARENTS[-1]" > * Existence check: "_.hasattr(object,what)" > NOTE, that this is the sloppy part. > > - "_.hasattr" will return true, if "object" has > attribute "what" (that is what we want) > *OR* when it has acquired such an attribute > (we do *NOT* want that here). > > What we would need is a DTML accessible version > of "aq_base". This is trivially handled by > an external method. Can you do this with the following in DTML? ...stuff... Not tested, but it looks right to me. -- 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 )
[Zope-dev] Re: [Zope-PTK] PROPOSAL: Splitting ZPatterns into two products
"Phillip J. Eby" wrote: > > Many people have suggested splitting out the PlugIns part of ZPatterns as a > seperate product for general Zope use. In addition to this, it is becoming > clearer to me as I work on docs, etc., that there really is only one thing > left in ZPatterns after you take out PlugIns, and that is DataSkins. > (Pretty much everything else in ZPatterns only has meaning in relation to > DataSkins.) > > So, I am thinking perhaps I should split ZPatterns into two products: > PlugIns and DataSkins. The DataSkins product would require the PlugIns > product. LoginManager would require both. For backward compatibility, > there would need to be a "final release" of ZPatterns which contained stubs > to load in classes from their new locations, so that existing objects > stored in ZODB's would not be "broken". Newly created objects, of course, > would refer to the new products automatically. > > The term "ZPatterns" would then go away, which is just as well because it > doesn't really mean anything, anyway. :) > > Please let me know if you have any comments or questions on this. I'm all for this proposal. The only problem I see is that the work of updating the developer documentation on the Wikis, and putting "historical documents", like the IRC chat transcript, in a context where they make sense. I'm willing to spend some time on the documentation work. -- 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] Re: [Zope-PTK] PROPOSAL: Splitting ZPatterns into two products
Chris Withers wrote: > > 'DataSkins' doesn't mean a lot to me as a name :S > What components would go into this product? An object that has DataSkin as a base class allows a DataManager to look after its data storage requirements. The DataManager stores all the propertysheets and attributes, and works out what to do and who to notify when things change. There are various types of DataManager in ZPatterns, and the important ones take plug-ins so that you can greatly modify their behaviour. Specialists and Customizers (aka Folders w/ customizer support) are the main DataManagers you build an application out of. Specialists may have Racks inside them to actually do the work of storing the data, so you can think about your application's architecture at many different levels of abstraction. You can say "The AddressBook specialist manages Address DataSkins" but you can also say "The Addresses rack in the AddessBook specialist stores the Address DataSkins". When Objects get created or deleted or changed, a DataManager will tell any Agents it knows about that this has happened, in case they are interested. An Agent is anything that monitors the events produced when things happen to DataSkins. A Trigger is a kind of Agent that does something concrete, like calling a method, in response to a change in a DataSkin. You can use a Trigger to update a ZCatalog when a DataSkin gets added or deleted or changes. This is good because catalog-awareness gets to move out of the domain objects (business objects, or whatever) and into the parts of your system that are concerned with the management of those objects. You can even use two Triggers to update two different Catalogs when a DataSkin changes -- for example, the AddressBook catalog, and also a SiteIndex catalog for searching all the data in your system. Perhaps the SiteIndex holds just minimal indexes and meta-data, whereas the AddressBook catalog holds meta-data and indexes more specialised to an address book. Two other important aspects of the DataSkins part of ZPatterns are SheetProviders and AttributeProviders. These plug into Racks (and anything else that takes "Data Plugins") and do the work of getting propertysheets and calculating or importing attributes. These attributes and propertysheets generally end up as the data belonging to the DataSkins. > Yup, sounds like a great idea. Hopefulyl Pluggins could get into the > Zope core ASAP. I reckon they might be quite useful to ZMI mark II :-) What is ZMI? -- 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] Re: [Zope-PTK] PROPOSAL: Splitting ZPatternsinto two products
Chris Withers wrote: > > "Phillip J. Eby" wrote: > > DataSkins themselves, > > Okay, I'm being dumb again, but could someone explain to me how the name > DataSkin came about Suggestion on zope-dev from Jason Spisak Fri, 19 May 2000 17:28:19 GMT, in response to Phillip looking for a better name than "Dynamic Data Object". Phillip: > > I'm not actually real fond of the DDO term, because "Dynamic Data Object" > > doesn't quite do justice to what these things actually are. I am > > definitely open to suggestions for a better name. (Facade? PlaceHolder? > > InsideOutObject? ExternalDataObject? BrainInjectedObject?) Jason: > ZopeTupperware, AloofAttributeObjects, DataSkins :) > and how it relates to what these objects do? Well, you can look at a normal object as having a interface "skin" through which you interact with the "flesh and bone" of its data. A Data Skin object is a bit like a clever virtual-reality glove, where its "flesh and bone" is actually somewhere else -- or perhaps nowhere at all, and is just generated from some algorithms. However, in both cases, the "skin" looks and feels exactly the same. Keywords: Encapsulation Delegation Transparency -- 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 )
[Zope-dev] Renaming ZClass instances in 2.2.0
In Zope 2.2.0, I can't rename ZClass instances. When you rename something, lib/python/OFS/CopySupport.py's _verifyObjectPaste() method gets called with the object you're renaming as an argument. The method checks that the current user is authorized to create objects of that kind, and that the current user is authorized to create that object in the current context. The problem seems to be that, in the case of renmaing a ZClass instance, when the ZopeSecurityPolicy tries to get a __roles__ attribute for the instance you're renaming, it can't find one. I'm way out of my depth here, but I can get it to work again by adding to the function PersistentClassDict() in lib/python/ZClasses/ZClass.py (line 195 or so): dict['__roles__']=('Manager',) so that it looks like this: def PersistentClassDict(doc=None, meta_type=None): # Build new class dict dict={} dict.update(Template.__dict__) if meta_type is not None: dict['meta_type']=dict['__doc__']=meta_type if doc is not None: dict['__doc__']=doc dict['__roles__']=('Manager',) return dict This only works for ZClasses defined after the change, though. I have absolutely no idea what the side-effects of this change are, and I'm not even entirely sure what it does :-) It seems to fix the problems of renaming DataSkin-derived ZClasses too. I've looked though the recent CVS checkins, and I can't see a fix for this yet. I've also looked through the Collector, and I can't see this problem reported. -- 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 )
[Zope-dev] ZPatterns: bug in DataSkins.py
I'm using ZPatterns 0.4.1snap1. DataSkins.py line 377 method _v_currentSheets(self,_v_dm_=_v_dm_) l.extend(list(sp._PropertySheetsFor(client))) However, the variable "client" isn't declared elsewhere. -- 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] ZPatterns: bug in DataSkins.py
Steve Alexander wrote: > > I'm using ZPatterns 0.4.1snap1. > > DataSkins.py line 377 > method _v_currentSheets(self,_v_dm_=_v_dm_) > > l.extend(list(sp._PropertySheetsFor(client))) > > However, the variable "client" isn't declared elsewhere. ...and when I replace it with "self", I get this error when I try to iterate through a dataskin's propertysheets: AttributeError: _v_currentSheets Traceback (innermost last): File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/zope/SiteBox/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: address-964970042) File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/zope/SiteBox/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: content_html) File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: content_html) File /usr/local/zope/SiteBox/lib/python/OFS/DTMLMethod.py, line 167, in __call__ (Object: content_html) File /usr/local/zope/SiteBox/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: content_html) File /usr/local/zope/SiteBox/lib/python/DocumentTemplate/DT_In.py, line 636, in renderwob (Object: propertysheets) File /usr/local/zope/SiteBox/lib/python/OFS/PropertySheets.py, line 654, in __len__ (Object: Traversable) File /usr/local/zope/SiteBox/lib/python/Products/ZPatterns/PropertySheets.py, line 11, in __propsets__ (Object: Traversable) AttributeError: (see above) -- 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] ZPatterns: bug in DataSkins.py
"Phillip J. Eby" wrote: > > At 08:07 PM 7/30/00 +0100, Steve Alexander wrote: > >Steve Alexander wrote: > >> > >> I'm using ZPatterns 0.4.1snap1. > >> > >> DataSkins.py line 377 > >> method _v_currentSheets(self,_v_dm_=_v_dm_) > >> > >> l.extend(list(sp._PropertySheetsFor(client))) > >> > >> However, the variable "client" isn't declared elsewhere. > > > >..and when I replace it with "self", I get this error when I try to > >iterate through a dataskin's propertysheets: > > > > Would you try something for me? Stick a routine in that class, call it > getCurrentSheets(), with exactly the same code as the _v_currentSheets > method, then call it from your code in place of iterating through > propertysheets? I have a feeling it'll provide a clearer error message. > (That's the only problem with ComputedAttributes - errors that break them > manifest as AttributeErrors, hiding the true error.) Thanks. ok. I think I've found the problem... I removed my own custom SheetProvider from the Specialist, and it works as expected. Here's the traceback with the new method, and my broken sheetprovider still in place: AttributeError: _PropertySheetsFor Traceback (innermost last): File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/zope/SiteBox/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: address-964970042) File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/zope/SiteBox/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: content_html) File /usr/local/zope/SiteBox/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: content_html) File /usr/local/zope/SiteBox/lib/python/OFS/DTMLMethod.py, line 167, in __call__ (Object: content_html) File /usr/local/zope/SiteBox/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: content_html) File /usr/local/zope/SiteBox/lib/python/DocumentTemplate/DT_In.py, line 633, in renderwob (Object: getCurrentSheets()) File /usr/local/zope/SiteBox/lib/python/DocumentTemplate/DT_Util.py, line 337, in eval (Object: getCurrentSheets()) (Info: getCurrentSheets) File , line 0, in ? File /usr/local/zope/SiteBox/lib/python/Products/ZPatterns/DataSkins.py, line 376, in getCurrentSheets (Object: address-964970042) File /usr/local/zope/SiteBox/lib/python/Products/ZPatterns/Providers.py, line 268, in _PropertySheetsFor (Object: PlugInBase) AttributeError: (see above) -- 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 )
[Zope-dev] ZPatterns design question
Let's say I have an AddressBook specialist. It stores Address records as DataSkin-derived ZClass instances (meta_type Address). The AddressBook has various methods to list the addresses, search the addresses, enter new addresses. The Address ZClass has a single propertysheet: address. When I add a new Address, a Trigger causes the AddressBook's catalog to catalog the new address. When I delete an address, it gets removed from the catalog. Let's say I want to combine my AddressBook with a Suppliers specialist. The Suppliers specialist knows about DataSkin-ZClasses called Supplier. A Supplier has its own propertysheet "supplies" that has information about the kind of goods and services supplied. A Supplier also has an address. Suppliers appear in the AddressBook. When I get a Supplier from the Suppliers specialist, I want it to have two propertysheets: supplies and address. Implementation: When I create a new Supplier, I also create a new Address in the AddressBook that has the same key (read "id") as the new Supplier. The Suppliers specialist has some sort of SheetProvider that either asks the AddressBook for the "address" sheet for a particular key, or (not so good) delegates directly to the Rack where the Address objects are stored. Bunch of questions: Is this the ZPatterns ideomatic way to do this? Can I use SkinScript to get propertysheets from another specialist? Is the SheetProvider that gets the address for the Supplier objects also responsible for adding and deleting Address objects? Do I need an Address object for each Supplier object? What kind of propertysheet should I be using? Should the method in the AddressBook specialist be returning an Address object, or just an address propertysheet? Or, more generally: Adding sheets to a "party" seems to be one of the important ZPatterns ideas. What is the best way of implementing it, using the simple case of two specialists as an example? Thanks. -- 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] ZPatterns design question
"Phillip J. Eby" wrote: > > At 11:09 PM 7/30/00 +0100, Steve Alexander wrote: > >Let's say I have an AddressBook specialist. > > Why? :) > > Seriously, what is the function of "address book" in your application? Is > it to find people in general? Or...? As in your example later, the Addresses specialist is at a different level of abstraction than other specialists. The domain expert tells me that he want to keep particular information about Suppliers: what they supply, and their address details. However, he also wants to store the address details of any other contacts he wishes. He'll sometimes need to search through all of the contacts and suppliers (and in future, anyone that has an address) by phone number or name or address. The domain expert calls the thing that allows him to do the searching (and also browsing) of addresses his "address book", and it reflects a real paper-based artifact. I'm sure I could rename it "Contacts" or "Addresses" without causing too much confusion, though. >From the way I just described it, there is no requirement for the addresses to be stored all in one place. There is a requirement that you can search and browse through all addresses, and return the appropriate object. So, I guess a good way to go is to add an "address" propertysheet to Contact and Supplier, and have triggers that add the address details of both to an Address catalogue. > > > >Bunch of questions: > > > >Is this the ZPatterns ideomatic way to do this? > > Dunno. Explain the problem you're trying to solve, and I'll > tell you the simplest way I know to do it. Aha... the missing link :-) > >What kind of propertysheet should I be using? > > Depends on what your application needs. I can see circumstances where the > best place for that sheet could be LDAP, SQL, or the ZODB. I wasn't being very clear there. What kind of propertysheet should I be adding to my DataSkin-derived ZClasses? There are two kinds: "Common instance" and "DataSkin attribute". It looks to me like at present the "DataSkin attribute" flavour will work better with SkinScript. > In which case, I think your > confusion comes from terminology. I would expect to store "Contacts" or > "Entries" in an addressbook, and these would have address sheets, as would > "Suppliers" or whatever else. That makes sense. Suppliers are sored in the Suppliers specialist, and general Contacts are stored in the Contacts specialist. The contacts specialist provides searching appropriate to the domain of addresses and contacts. > Anyway, to answer your question - I think that your getItem() for an > address specialist wants to return some object with an address sheet. But > not an address object. Contact, Entry, Supplier, TennisBuddy... whatever > the heck kind of object it is. This is starting to make much more sense. Many thanks. -- 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 )
[Zope-dev] Re: Collector #1457: DateTime strftime() -- still broken
[EMAIL PROTECTED] wrote: > > Steve Alexander reported: > > > This is a patch to address collector item 1455. > > > > Here's a working patch to make formatting of a DateTime instance work as generally >expected, when you use > > > > > > > > or whatever. > > > > It could be made more efficient by compiling the two regular expressions into >class attributes. However, a bug in ts_regex stops it using compiled regular >expressions in gsub. > > > > See the following URL for a description of the regex bug. > > > > http://lists.zope.org/pipermail/zope-dev/2000-July/006105.html > > > > > > with patch: > > > *** lib/python/DateTime/DateTime.old.py Sun Jul 23 20:03:04 2000 > > --- lib/python/DateTime/DateTime.py Mon Jul 24 14:01:37 2000 > > *** > > *** 1376,1382 > > return millis > > > > def strftime(self, format): > > ! return strftime(format, gmtime(self.timeTime())) > > > > # General formats from previous DateTime > > def Date(self): > > --- 1376,1385 > > return millis > > > > def strftime(self, format): > > ! diff=_tzoffset(self._tz, self._t) > > ! format = ts_regex.gsub('\(^\|[^%]\)%Z', '\\1'+self._tz, format) > > ! format = ts_regex.gsub('\(^\|[^%]\)%z', '\\1%+05d' % (diff/36), format) > > ! return strftime(format, gmtime(self.timeTime()+diff)) > > > > # General formats from previous DateTime > > def Date(self): > > > > Thanks for the report. Per popular demand based on list > feedback, strftime() now formats using the current timezone > representation of the DateTime object (consistent with all > of the other DT formatting methods). > > For those who really needed it to format based on GMT, you > can use the toZone() method to get a copy of the DateTime > object represented in GMT and call the formatting methods > on that object: > > > > or > > > > -Brian I just looked at the fix in CVS. I'm sad to report that it is still broken. Here's the patched method from CVS: def strftime(self, format): # Format the date/time using the *current timezone representation*. jfirst = _julianday(self._year, 1, 1) - 1 jtoday = _julianday(self._year, self._month, self._day) julian = jtoday - jfirst time_info=(self._year, self._month, self._day, self._hour, self._minute, self._nearsec, (self._dayoffset + 6) % 7, julian, 0) return strftime(format, time_info) This gets time.strftime to format the time in the DateTime instance, shifted by an appropriate amount. However, if you try and format with %z or %Z to display the timezone information, it always comes out as GMT. So, the implementation has gone from correct but not useful, to generally useful but technically incorrect. To see the problem, apply the patch and try this DTML snippet: Time: Time: This prints out the following: Time: July 23, 2000 14:03 GMT Time: July 23, 2000 2:03 pm GMT+1 They are being presented as different times. The first one should read "Time: July 23, 2000 14:03 GMT+1". A solution is to replace the %Z and %z format substrings with correctly calculated values, as in my original patch, included towards the start of this message. -- 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] Calling parent class method when method is overridden in current class?
Phil Harris wrote: > > Hi all, > > I'm in the process of creating a Python based product, and have a need to > call the base classes index_html method. > > My problem is that I need to call it from my classes index_html. > > My class has DTMLDocument as the base class so I want to call something like > DTMLDocument.index_html(). Perhaps DTMLDocument.index_html(self) ? The only problem is if you need to call a base-class method from a derived ZClass. -- 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] Server Side Trojan Issue really dead?
Chris Withers wrote: > > Hi, > > This comes from a chat on #zope and some worries I've had since the > server side issue was raised. > > Unless I'm mistaken, the new security model doesn't solve the issue > because ownership isn't changed by editing. > > Lets take the example of a ZWiki page which executes any DTML in its > contents when it is rendered. > Jim in a Manager > Paul is a Manager > DrEvil has the ability to edit ZWiki Pages, but not call the DEE (Delete > Everything, Everywhere ;-) Method > > So, Jim comes along an creates a ZWiki Page describing the new security > model. > > DrEvil comes along, edits the page and plants a "DEE(backup='no')"> in the page. > He can't view this page since, as I understand it, code is executed with > the lower of the owner and the viewer's permissions. > > Paul comes along to read the new ZWiki page, and IIUC, inadvertently > executes DEE and deletes everything, everywhere, because he is a > manager, and Jim (still the owner) is a manager and so DEE executes. > > Have I missed something? When I write a product that allows users to edit executable content, I have an extra responsibility to collaborate with the new security model. I reckon that it is up to the ZWiki product to change ownership appropriately if the page is edited. The zope security system can't possibly know about what constitutes editing executable content and what does not. Only a product author can know that. As a general princliple, executable content should never be editable by users with lower permissions than the owner of the content. This is the same principle system administrators use on a Unix system to know never to have a root-owned file that is executable by root, and also writable by others. The problem with applying this principle in Zope is that the roles and permissions system is very expressive, and it is complex to know when one user has lower permissions than another. -- 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] Server Side Trojan Issue really dead?
Steve Alexander wrote: > > When I write a product that allows users to edit executable content, I > have an extra responsibility to collaborate with the new security model. > > I reckon that it is up to the ZWiki product to change ownership > appropriately if the page is edited. The zope security system can't > possibly know about what constitutes editing executable content and what > does not. Only a product author can know that. > > As a general princliple, executable content should never be editable by > users with lower permissions than the owner of the content. This is the > same principle system administrators use on a Unix system to know never > to have a root-owned file that is executable by root, and also writable > by others. > > The problem with applying this principle in Zope is that the roles and > permissions system is very expressive, and it is complex to know when > one user has lower permissions than another. However... the zope security system could help with this. Here's an ill thought out idea for your consideration :-) Have a function that takes two sets of permissions, and returns the intersection of these sets. Then, use some sort of local permissions combination to make the wiki page that's been edited have the resultant lowest-common-denominator permissions, even for the owner. Make this kind of thing a standard feature of the security system, and write some guidelines to help out authors of products that allow editing content that is also executable. -- 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] Server Side Trojan Issue really dead?
KevinL wrote: > > > Steve Alexander wrote: > > However... the zope security system could help with this. Here's an ill > > thought out idea for your consideration :-) > > > > Have a function that takes two sets of permissions, and returns the > > intersection of these sets. Then, use some sort of local permissions > > combination to make the wiki page that's been edited have the resultant > > lowest-common-denominator permissions, even for the owner. > > Correct me if I'm wrong, but wouldn't this have the same problem? Person of > high access makes zwiki, person of low access adds evil function to it, person > of high access views it - unless you're tracking "smallest set of privileges > held by anyone editing this page" at all times, you're going to intersect > owner with creator and still allow editor to trojan. Yes, the idea would be to track the smallest set of privileges held by anyone editing this page. You take the intersection of the page's current permissions and the currently-editing user's permissions. Another simpler solution is to make all the pages unowned, make new pages unowned, and make them remain unowned even when edited. However, that may not be a general solution as it is more restrictive that it may need to be. -- 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 )
[Zope-dev] Re: [Zope] ZPatterns Question
I've moved your question to zope-dev, as that's where ZPatterns questions probably belong. Roche wrote: > I created a ZClass called "Product" with Dataskin as baseclass. > > I also added a specialist called ProductManager containing a default rack. > Under storage for the rack I selected the newly created Product ZClass. > > My product ZClass needs to query both a RDBMS and the ZODB for > attributevalues. At this point I get lost. > I guess i should add an attributeprovider plug-in??? The easiest way is to use a couple of SheetProviders. Use a PersistentSheetProvider for your ZODB values. You'll have to write your own one for SQL values. You will need to create the appropriate propertysheets in your ZClass class definition in your product. > What should go into the fromexpr and attrsexprs properties of the > attributeprovider? Should one add an attributeprovider for each attribute > of the product? See the IRC chat log: http://www.zope.org/Documentation/Chats/zpatt_chat_log An attribute provider can provide multiple attributes. You can have multiple attribute providers if you like. -- 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] Re: Replaceable Property question
Brian Lloyd wrote: > > > > > So, how long before this becomes a project and gets finished? > > > > 2.2.1 would be great :-)) > > > > thanke for the great work, > > > > Chris > > Note that third-dot releases are bug-fix only. New features > go into second-dot releases. I agree with this policy in principle. However, because various nice things in PTK and projects using ZPatterns depend on the replaceable property, I can see quite a lots of patched 2.2.x installations until the 2.3.x series is released :-/ I wonder what other features are planned for 2.3... -- 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] Acquisition Confusion :S
Chris Withers wrote: > > Steve Alexander said he was going to have a think, but I haven't heard > anything since he mentioned it... I'll have to start running a Kibo-bot soon :-) I've got as far as defining the difference between the two acquisition behaviours. Warning: The following goes into some detail about acquisition algebras. There are lots of nested parentheses with letters in them. Let's say we have the following object tree. The upper-case letters represent names, not identity. The lower-case letters represent identity. / |-Aa | |-B b | |-Xx | |-P p1 | |-Y y | |-Pp0 Let's consider the path X.Y.A.B.P in both types of acquisition. Containment first: Start at the root. Look for X. Find X at x. Look for Y in x. Find Y at y. Look for A in y. Not found, so look for A in x. Not found, so look for A in /. Found as a. Look for B in a. Found as b. Look for P in b. Not found, so look for P in a. Not found, so look for P in /. Found as p0. Context first Start at the root. Look for X. Find X at x. Look for Y in x. Find Y at y. Look for A in y. Not found, so look for A in x. Not found, so look for A in /. Found as a. Look for B in a. Found as b. Look for P in b. Not found, so look for P in a. Not found, so look for P in y. Not found, so look for P in x. Found as p1. The acquisition algebra is based on the "of" operator: (object of context). The difference in algebra is that with containment-first, as you build up the expression, you add to it using the last object you searched as the context part of the expression. With conext-first, you need to add the whole expression so far as the context part of the expression. Containment first: Start at the root. (X of /) Look for X. Find X at x. (Y of X) of (X of /) Look for Y in x. Find Y at y. (A of /) of ((Y of X) of (X of /)) Look for A in y. Not found, so look for A in x. Not found, so look for A in /. Found as a. (B of A) of ((A of /) of ((Y of X) of (X of /))) Look for B in a. Found as b. (P of /) of ((B of A) of ((A of /) of ((Y of X) of (X of / Look for P in b. Not found, so look for P in a. Not found, so look for P in /. Found as p0. Context first Start at the root. (X of /) Look for X. Find X at x. (Y of (X of /)) of (X of /) Look for Y in x. Find Y at y. (A of (Y of (X of /))) of ((Y of (X of /)) of (X of /)) Look for A in y. Not found, so look for A in x. Not found, so look for A in /. Found as a. (B of (A of (Y of (X of /))) of ((Y of (X of /)) of (X of /))) of ((A of (Y of (X of /))) of ((Y of (X of /)) of (X of /))) Look for B in a. Found as b. (P of (B of (A of (Y of (X of /))) of ((Y of (X of /)) of (X of /))) of ((A of (Y of (X of /))) of ((Y of (X of /)) of (X of / of (B of (A of (Y of (X of /))) of ((Y of (X of /)) of (X of /))) of ((A of (Y of (X of /))) of ((Y of (X of /)) of (X of /))) Look for P in b. Not found, so look for P in a. Not found, so look for P in y. Not found, so look for P in x. Found as p1. I just put that in to give Chris a fright :-) You can see from this that the algorithm is more complex. Acrually, it can be rather simplified, because what I've written out in full above contains many internal repetitions. In C terms, these become pointers to the same acquisition wrapper. So the following... (P of (B of (A of (Y of (X of /))) of ((Y of (X of /)) of (X of /))) of ((A of (Y of (X of /))) of ((Y of (X of /)) of (X of / of (B of (A of (Y of (X of /))) of ((Y of (X of /)) of (X of /))) of ((A of (Y of (X of /))) of ((Y of (X of /)) of (X of /))) ...is really this: ((P of q) of q) where q is ((B of r) of r) where r is ((A of s) of s) where s is ((Y of t) of t) where t is (X of /) I also wonder whether we need the second part of all the context-first expansions above. That is, whether (P of q) will do, instead of ((P of q) of q). To see if the simplification works, let's take the example of acquiring X.Y in the tree: / |-X |-Y Containment first: (X of /) (Y of X) of (X of /) Simplified Context first: (X of /) (Y of (X of /)) Applying this simplification to my larger example above, we get for the following: Simplified Context first Start at the root. (X of /) Look for X. Find X at x. (Y of (X of /)) Look for Y in x. Find Y at y. (A of (Y of (X of /))) Look for A in y. Not found, so look for A in x. Not found, so look for A in /. Found as a. (B of (A of (Y of (X of /))) Look for B in a. Found as b. (P of (B of (A of (Y of (X of /))) Look for P in b. Not found, so look for P in a. Not found, so look for P in y. Not found, so look for P in x. Found as p1. The search j
Re: [Zope-dev] Bug in DateTime.py
Karsten Petersen wrote: > > Hi, > > today I had *very* strange effects with the following code: > > > > > > > on my system it gave me: > 2000/08/08 > (2000, 8, 8, 0, 0, 0, 'GMT+2') > 2000/08/07 > > Well - this was not quite what I expected. :) > > I tracked the problem down to the timezone: When no time is given, the > time is initialized with 00:00. So after applying gmtime in the strftime > function (DateTime.py line 1379) it got shifted out and - hoppla - we > have gone one day back in time. :) Use the patch here: http://classic.zope.org:8080/Collector/1457/view -- 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] Acquisition Confusion :S
Michel Pelletier has reminded me that we need a security check by containment at each point in the search through context. So, in my example, the search will look like this: / |-Aa | |-B b | |-Xx | |-P p1 | |-Y y | |-Pp0 Context-first Acquisition (P of (B of (A of (Y of (X of /))) Security p0 / b a / a b y x / x / / Checks That makes for a lot of security checks. There are possible optimisations, though. But this starts to get even more complicated. -- 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] ZPatterns Question
"Phillip J. Eby" wrote: > > Actually, neither relates. Property sheets created on ZClasses always have > their data stored in attributes of the object itself, so if you want to > control those property sheets you would not use a sheet provider at all. > Sheet providers are only used to provide property sheets whose data is > stored external to the object. I'm confused here. Please excuse me if these questions seem silly. What does "Property sheets created on ZClasses" mean, exactly? If I use some DataSkin-derived ZClass instances inside a Customizer folder, and if I want to store the data in the ZODB, do the propertysheets for one of these ZClass instances come from PersistentAttributeProviders or PersistentSheetProviders? What is the difference between a Common Instance Propertysheet and a Dataskin Attribute Propertysheet when added to a Dataskin-derived ZClass? Is the following true, part true, false, or irrelevant? If I want to add a propertysheet that contains information from an SQL database query to a ZClass-dataskin instance, I have to : * Declare in my Product that the ZClass has that propertysheet (unless I do clever stuff with triggers to add the sheet if it isn't there already) * Use a custom SQL SheetProvider? Or an AttributeProvider? Or some skinscript that calls various methods in my specialist? Thanks. -- 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 )
[Zope-dev] ZCatalog brains
Is there any good reason that the "brains" returned by ZCatalog searches don't have a standard property that reflects the URL of the object they have meta-data from? This would seem to me to be more object-oriented, and would save calls to someCatalog.getpath(data_record_id_) in loops. Am I missing something? -- 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] ZPatterns Question
Thanks for your answers, Phillip. Here's what I've learned. I still need to try these out on a test system, to prove to myself that they work the way I think they do. 1: ZClass instances can have PropertySheets added to them, independently of any sheets declared in the ZClass class definition. I've been working with Zope for a while, but this had never occurred to me. I guess this is just another one of those hangovers from writing in Java for so long. 2: If, in a dataskin-derived ZClass class definition, I define a "common instance" propertysheet, values in that propertysheet for instances get stored in the ZODB just like any other ZClass instances' propertysheets. However, if I define a "dataskin" propertysheet for my ZClass, I can provide the content of these sheets to my ZClass instances using AttributeProviders. (Are the above two paragraphs correct? Or can I use AttributeProviders to supply data for common instance propertysheets also, but I can't use default values for such sheets?) However, because of the way Attributes work, I cannot supply data for a dataskin-propertysheet as a separate independent sheet object. The sheet comes from the ZClass, the data comes from an Attribute Provider. 3: If I want to use a SheetProvider, and thus use some of the important features of ZPatterns, I need to use object.propertysheets.manage_addPropertySheet() on each ZClass instance that should have a sheet from a SheetProvider. One way of doing this is with a Trigger. 4: > If you needed to add this atop a class which needed to > be "final" (in the Java sense, i.e. no modifications allowed), then the > best route would be a custom SQL sheet provider. ...because the SQL sheet provider can provide sheets to ZClass-dataskin instances, even though the original ZClass was not defined to have this propertysheet. But I'd also have to add sheets to each applicablt instance, as in learning point 3 above. -- 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] RE: Request for Comment: Zope API naming convention
Chris McDonough wrote: > > > Please make comments by Wednesday April 16. > > > > Jim > > Plenty of time... :-) Especially considering that the next Wednesday April 16 is in 2003. -- 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] ZCatalog brains
Chris Withers wrote: > > Steve Alexander wrote: > > Is there any good reason that the "brains" returned by ZCatalog searches > > don't have a standard property that reflects the URL of the object they > > have meta-data from? > > That sounds like a good idea :-) > > > This would seem to me to be more object-oriented, and would save calls > > to someCatalog.getpath(data_record_id_) in loops. > > All you'd need to do is find some way of returning this from a method of > your object-being-catalogued that takes no arguments and then you could > add it as normal meta-data column. > > I wonder if that's possible? Yes. The url method of CatalogAwareness does this. So you could just add "url" to the metadata of your catalog. > cheers, > > Chris > > PS: You could always just make your own brains that returned the results > of this call, but that doesn't make it any more efficient :( It makes it less efficient, as the object would have to be obtained when you made the brain.url call. Not much point using brains at all then. Although there are ways to do this now, I guess I was wondering about making it a standard part of catalogs. Thinking further though, if it is as easy as adding "url" to the catalog's metadata, why bother? -- 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] Acquisition Confusion :S
Chris Withers wrote: > > Steve Alexander wrote: > > That makes for a lot of security checks. > > There are possible optimisations, though. But this starts to get even > > more complicated. > > Does that mean it won't work, would be very slow, or both? ;-) It will work. It will be slower. I think Evan Simpson's suggestion of adding two new methods to the acquisition wrapper is a good idea. That way, Zope remains backward-compatible, and you get to make an explicit choice of how you want acquisition to work, if you wish. Perhaps there's a Collector entry on this? quoted from Evan's email. Untested. def aq_context(ob): context = [] while ob is not None: context.append(ob.aq_base) ob = ob.aq_parent ob = context.pop() while context: ob = context.pop().__of__(ob) return ob def aq_containment(ob): context = [] while ob is not None: context.append(ob.aq_base) ob = ob.aq_inner.aq_parent ob = context.pop() while context: ob = context.pop().__of__(ob) return ob As he pointed out, they'd make useful external methods too. Perhaps these will find their way into Zope 2.3? -- 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 )