[Zope-dev] url traversal
I have the classic problem of wanting my method 'foo' to work like: http://localhost/foo/a/b/c where a,b,c are parameters passed to foo. I've found some info in the mailing list archives, namely: http://lists.zope.org/pipermail/zope-dev/2000-May/005197.html Has the 'Traversal' interface been implemented? What are the specifics of implementing something like I describe above? Thanks, -Brett ___ 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] Publishable Objects...
What does it take to make an object publishable from an ExternalMethod? I.E., I have a class (see bottom of message) that does some url traversal trickery, that works from a python product. Shouldn't I be able to just stick it in an External method, and just return it, i.e.: def returnme(self): return MyClass() and it get's published as normal? The problem is, __bobo_traverse__ never gets called on MyClass when it's in the external method. It works fine from a python product though. -Brett ___ 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] dtml-in performance
What can I do to maximize the peformance of a dtml-in statement? When iterating over a 2000 row database query, it takes about 20 seconds - time mostly spent doing security checks, and calling __getitem__ in DT_InSV.py. Is the performance of dtml-in just slow? -Brett ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] dtml-in: next-batches
I tried accessing keys off the 'data' object, and I just get an 'unathorized' error. -Brett "Dieter" == Dieter Maurer [EMAIL PROTECTED] writes: Dieter Brett Carter writes: I'm running Zope 2.2.2, and I'm trying to use the batching stuff for the dtml-in tag, however, I can't seem to access any attributes off the 'next-batches' or 'previous-batches' mapping object that's supposed to be available, with the attributes 'batch-start-index', 'batch-end-index', and 'batch-size'. I wrote an external method to dir the 'next-batches' object, and it seems the only attributes available are: ['data', 'items', 'query_string', 'start_name_re'] Dieter The attributes your are looking for are in fact keys Dieter of the mapping 'data'. Dieter Dieter ___ 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] dtml-in: next-batches
Does anybody have an example of how to use the supposed next-batches mapping returned by dtml-in? I'm trying to build a google-like pageing feature into my application, so we just show the first 5 results, then have a link to each next page, ie "1,2,3,4..." Thanks, -Brett ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] dtml-in: next-batches
I've also discovered that setting overlap = 0 actually causes everything to overlap by 1. I didn't see anything in the collector about this either... -Brett "Brett" == Brett Carter [EMAIL PROTECTED] writes: Brett I'm running Zope 2.2.2, and I'm trying to use the batching stuff for Brett the dtml-in tag, however, I can't seem to access any attributes off Brett the 'next-batches' or 'previous-batches' mapping object that's Brett supposed to be available, with the attributes 'batch-start-index', Brett 'batch-end-index', and 'batch-size'. However, my example code (see Brett below) blows up with a key error when trying to access any of these. Brett Is this a bug, or am I just misunderstanding how to use this thing? Brett I wrote an external method to dir the 'next-batches' object, and it Brett seems the only attributes available are: Brett ['data', 'items', 'query_string', 'start_name_re'] Brett -Brett Brett p Brett dtml-in "mystuff.retseq()" size=5 start=start Brett dtml-var sequence-item Brett /dtml-in /p Brett p Brett dtml-in "mystuff.retseq()" size=5 start=start previous Brett a href="dtml-var absolute_url/batch_me?start=dtml-var previous-sequence-start-index"Previous/a Brett /dtml-in Brett dtml-in "mystuff.retseq()" size=5 start=start next overlap=-1 Brett dtml-try Brett dtml-in next-batches Brett dtml-var batch-start-indexbr Brett /dtml-in Brett dtml-except Brettpre Brettdtml-var error_typebr Brettdtml-var error_valuebr Brettdtml-var error_tbbr Brett/pre Brett /dtml-try Brett a href="dtml-var absolute_url/batch_me?start=dtml-var next-sequence-start-index"Next/a Brett /dtml-in Brett /p Brett ___ Brett Zope-Dev maillist - [EMAIL PROTECTED] Brett http://lists.zope.org/mailman/listinfo/zope-dev Brett ** No cross posts or HTML encoding! ** Brett (Related lists - Brett http://lists.zope.org/mailman/listinfo/zope-announce Brett http://lists.zope.org/mailman/listinfo/zope ) ___ 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] dtml-in: next-batches
I'm running Zope 2.2.2, and I'm trying to use the batching stuff for the dtml-in tag, however, I can't seem to access any attributes off the 'next-batches' or 'previous-batches' mapping object that's supposed to be available, with the attributes 'batch-start-index', 'batch-end-index', and 'batch-size'. However, my example code (see below) blows up with a key error when trying to access any of these. Is this a bug, or am I just misunderstanding how to use this thing? I wrote an external method to dir the 'next-batches' object, and it seems the only attributes available are: ['data', 'items', 'query_string', 'start_name_re'] -Brett p dtml-in "mystuff.retseq()" size=5 start=start dtml-var sequence-item /dtml-in /p p dtml-in "mystuff.retseq()" size=5 start=start previous a href="dtml-var absolute_url/batch_me?start=dtml-var previous-sequence-start-index"Previous/a /dtml-in dtml-in "mystuff.retseq()" size=5 start=start next overlap=-1 dtml-try dtml-in next-batches dtml-var batch-start-indexbr /dtml-in dtml-except pre dtml-var error_typebr dtml-var error_valuebr dtml-var error_tbbr /pre /dtml-try a href="dtml-var absolute_url/batch_me?start=dtml-var next-sequence-start-index"Next/a /dtml-in /p ___ 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] What's 'section' in blocks[0] in block dtml tag?
Lee, I've been diddling around with the same stuff. It took me a lot of introspection with printing of errors via MrCreosote/Spew. To answer your question, 'section' is an object which contains an attribute 'blocks'. If you want to render the dtml in there, you can run the 'render_blocks' method in 'zope-instance/lib/Python/pDocumentTemplate.py' You pass it the section.blocks object and a mapping dictionary which is the current namespace stack that gets passed in as the only argument to the 'render' method in you tag definition. If you just want the raw text, check you the render_blocks method, so you can see how they take apart the 'section.blocks' object. As to the object hiarchy of everything, your guess is as good as mine as to why there's a list of tuples of blocks wrapped in a section object, wrapped in another blocks object, I have know idea. Perhaps the designer of the document templates could answer... -Brett "LEE" == LEE Kwan Soo [EMAIL PROTECTED] writes: LEE Hi. I'm playing/struggling to make a custom block dtml tag. LEE Let me call it, dtml-quote tag. LEE dtml-quote tag is similar to dtml-comment tag except it will emit LEE html_quoted, not rendered version of what lies LEE between dtml-quote ... /dtml-quote. LEE (I feel it will be usefull when I show write some dtml examples on my LEE korean zope site). LEE After seeing around some python sources, LEE I finally got that tname is the name of the tag, args is args, and section LEE is something, in the following code. LEE def __init__(self, blocks): LEE tname, args, section = blocks[0] LEE and section seems to have 6 attributes/methods: LEE '__name__', '_v_blocks', '_v_cooked', '_vars', 'blocks', 'globals', 'raw' LEE But that mistic raw is null string, '' and blocks is no help for me. LEE How can I retrieve the raw source string enclosed in a block tag pair? LEE LEE Kwan Soo. LEE ps. My English is evem more cryptic this morning. Sorry I've sat up alnight play LEE Kingdom Under Fire. LEE ___ LEE Zope-Dev maillist - [EMAIL PROTECTED] LEE http://lists.zope.org/mailman/listinfo/zope-dev LEE ** No cross posts or HTML encoding! ** LEE (Related lists - LEE http://lists.zope.org/mailman/listinfo/zope-announce LEE http://lists.zope.org/mailman/listinfo/zope ) ___ 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] objectValues performance
Ok, I'll bite. Why doesn't the standard folder scale? Seems like a design flaw to me - why doesn't the default folder use catalogs or BTrees? -Brett "Casey" == Casey Duncan [EMAIL PROTECTED] writes: Casey Brett Carter wrote: I have a folder with greater than 5000 ZClass instances in it. It takes 5mins to do an objectValues for every object in the folder - is there a higher perfomance call I could make? -Brett Casey Standard folder performance degrades pretty quickly once you get Casey a lot of objects in it. There are two solutions to this: Casey Subdivide your objects into multiple folders. Casey Use a BTreeFolder which should be much faster. Casey You can download the BTreeFolder product Casey here: http://www.zope.org/Members/hathawsh/BTreeFolder/ Casey hth, Casey Casey Duncan ___ 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] objectValues performance
"Michel" == Michel Pelletier [EMAIL PROTECTED] writes: Michel Because massive scale is not a requirment of folders, they Michel are meant to organize content for humans, not to be Michel large-collection containers. A folder with 5000 elements Michel is not very useful to a human. Michel On a similar note, create 5000 files in a linux directory on a ext2 Michel (standard) filesystem and then type 'ls'. You'll notice they don't Michel scale very well either, which is why there are filesystems like Michel ReiserFS. Michel -Michel Point taken, but in Zope where data and logic reside in the same place (ZODB) shouldn't we have some sort of effcient storage for large amounts of data? What happens when a site gets three or four thousand users? That won't fit well in an UserFolder. -Brett [...] ___ 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] Custom dtml tag
Andy - looking up 'this' in a dtml method or document won't work unless you expose it in your python product/tag definition. I'm talking about getting 'this' inside a dtml tag that I have defined myself (i.e. dtml-foobar/dtml-foobar). If you want 'this' available in dtml, write an external method and just return 'self' def this(self): return self -Brett "Andy" == Andy McKay [EMAIL PROTECTED] writes: Andy Really? Ive looked up this and get nothing (an attribute error actually) and Andy its not in globals. If that would work that would be great - but a it Andy certainly doesnt seem to on a standard DTMLDocument / Method. Andy - Original Message - Andy From: "Brett Carter" [EMAIL PROTECTED] Andy To: "Andy McKay" [EMAIL PROTECTED] Andy Cc: [EMAIL PROTECTED] Andy Sent: Tuesday, September 12, 2000 4:17 PM Andy Subject: Re: [Zope-dev] Custom dtml tag Andy: here's what I've gleaned - in a dtml tag's render() method, you get passed in self and a template dict, in my example let's call it 'md'. md is essentially a stack/dictionaryish object of the *current* namespace - and one of the handy things that's always around in the namespace is the 'this' function, which returns the object on the top of the stack. Just lookup 'this', run it, and there you have a reference to the calling object! Ex: def render(self, md) this = md.getitem('this') callingObj = this() return "Calling object was %s" % (callingObj.id()) Note I haven't tested this code. Good luck! -Brett ___ 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] Custom dtml tag
"Andy" == Andy McKay [EMAIL PROTECTED] writes: Andy - see the thread I started called 'Acqusition in a DTML tag' I have a similar question. -Brett Andy Hmm well ive found i have TemplateDict object and of Andy course my self. Perhaps there is a pythonism I have to Andy research here. Andy - Original Message - From: "Andy McKay" Andy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Andy Monday, September 11, 2000 4:03 PM Subject: [Zope-dev] Andy Custom dtml tag Im playing with a custom dtml-tag along the lines of dtm-query foo constructs a url to a catalog query. It works fine, I would just like to extend it a bit and for this I would need to get to the calling object. For example, there will be a different query depending upon the object the dtml-query tag is contained in. Does this make sense, does anyone know the answer? Thanks in advance. -- Andy McKay, Developer. ActiveState. ___ 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 ) Andy ___ Zope-Dev Andy maillist - [EMAIL PROTECTED] Andy http://lists.zope.org/mailman/listinfo/zope-dev ** No cross Andy posts or HTML encoding! ** (Related lists - Andy http://lists.zope.org/mailman/listinfo/zope-announce Andy http://lists.zope.org/mailman/listinfo/zope ) ___ 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 in a DTML Tag
"Shane" == Shane Hathaway [EMAIL PROTECTED] writes: Shane Brett Carter wrote: "Brett" == Brett Carter [EMAIL PROTECTED] writes: Brett I've defined my own dtml tag (i.e. dtml-foo/dtml-foo) Brett and I am trying to look up an object depending on the Brett arguments passed to my tag. The python class that defines Brett the tag inherits from Acquisition.Implicit, but 'self' Brett doesn't contain any of the Acquisition hiarchy. It seems Brett like this must be possible, since the dtml-var tag must Brett have to do an object lookup somewhere for objects passed to Brett it to render. Can anybody shed some light on this? Is it Brett doable? TIA -Brett Ok, So after some *major* hacking, i've realized that the 'md' passed into the render() method of my dtml tag contains the namespace, and is of type 'TemplateDict' which appears to contain a stack of 'MultiMapping's. Weird. Well, anyways, I just used the 'has_key' and 'getitem' methods to lookup my item. The question now is how do I create a new object in the current namespace? It looks like the TemplateDict is a read-only type of data structure. Anybody? TIA -Brett Shane Look at render() of DT_With.py. It does an Shane md._push(mapping containing new names) then, in a Shane try/finally clause, calls DT_Util.render_blocks(). In the Shane finally clause, it does md._pop(). Shane Shane I'm still confused. Ok, so render gets passed 'md', which is a TemplateDict, which contains a MultiMapping, which looks like a stack of dictionaries, which I am guessing is some sort of namespace stack. So looking at the DT_with.py, it looks like, to create an object in the current namespace, I have to wrap it in an InstanceDict, and push it onto the 'md' using 'md._push'. Does this also cause the new object to be saved in the ZODB? Or do I have to manually add it there too? Also, what does render_blocks do? Why does DT_with.py's render() return it? Do I have to run render_blocks() to insert my new object into the namespace? TIA -Brett ___ 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] Custom dtml tag
Andy: here's what I've gleaned - in a dtml tag's render() method, you get passed in self and a template dict, in my example let's call it 'md'. md is essentially a stack/dictionaryish object of the *current* namespace - and one of the handy things that's always around in the namespace is the 'this' function, which returns the object on the top of the stack. Just lookup 'this', run it, and there you have a reference to the calling object! Ex: def render(self, md) this = md.getitem('this') callingObj = this() return "Calling object was %s" % (callingObj.id()) Note I haven't tested this code. Good luck! -Brett "Andy" == Andy McKay [EMAIL PROTECTED] writes: Andy I can see how this would be useful in a situation where I dont have an Andy instance of self. But in this case I do, so Im not sure how this helps. Andy I guess you're saying once I have self I can find out what called the Andy function. More fiddling I guess. Andy - Original Message - Andy From: "Martijn Pieters" [EMAIL PROTECTED] Andy To: "Andy McKay" [EMAIL PROTECTED] Andy Cc: [EMAIL PROTECTED] Andy Sent: Tuesday, September 12, 2000 11:29 AM Andy Subject: Re: [Zope-dev] Custom dtml tag On Tue, Sep 12, 2000 at 09:26:49AM -0700, Andy McKay wrote: Hmm well ive found i have TemplateDict object and of course my self. Perhaps there is a pythonism I have to research here. - Original Message - From: "Andy McKay" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 11, 2000 4:03 PM Subject: [Zope-dev] Custom dtml tag Im playing with a custom dtml-tag along the lines of dtm-query foo constructs a url to a catalog query. It works fine, I would just like Andy to extend it a bit and for this I would need to get to the calling Andy object. For example, there will be a different query depending upon the object Andy the dtml-query tag is contained in. Does this make sense, does anyone know Andy the answer? Thanks in advance. -- Andy McKay, Developer. ActiveState. The namespace just reflects the attributes of the current object, plus whatever other tags push onto that stack (such as the in tag, which pushes the current element of the list it iterates over on top). If you retrieve the 'this' method from the stack, and call it, it'll return the topmost object on the stack. It is implemented in SimpleItem.Item: def this(self): # Handy way to talk to ourselves in document templates. return self -- Martijn Pieters | Software Engineermailto:[EMAIL PROTECTED] | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ | ZopeStudio: http://www.zope.org/Products/ZopeStudio - Andy ___ Andy Zope-Dev maillist - [EMAIL PROTECTED] Andy http://lists.zope.org/mailman/listinfo/zope-dev Andy ** No cross posts or HTML encoding! ** Andy (Related lists - Andy http://lists.zope.org/mailman/listinfo/zope-announce Andy http://lists.zope.org/mailman/listinfo/zope ) ___ 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 in a DTML Tag
"Brett" == Brett Carter [EMAIL PROTECTED] writes: Brett I've defined my own dtml tag (i.e. dtml-foo/dtml-foo) Brett and I am trying to look up an object depending on the Brett arguments passed to my tag. The python class that defines Brett the tag inherits from Acquisition.Implicit, but 'self' Brett doesn't contain any of the Acquisition hiarchy. It seems Brett like this must be possible, since the dtml-var tag must Brett have to do an object lookup somewhere for objects passed to Brett it to render. Can anybody shed some light on this? Is it Brett doable? TIA -Brett Ok, So after some *major* hacking, i've realized that the 'md' passed into the render() method of my dtml tag contains the namespace, and is of type 'TemplateDict' which appears to contain a stack of 'MultiMapping's. Weird. Well, anyways, I just used the 'has_key' and 'getitem' methods to lookup my item. The question now is how do I create a new object in the current namespace? It looks like the TemplateDict is a read-only type of data structure. Anybody? TIA -Brett ___ 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 )