Re: [Zope] Re: passing a parameter - namespace and dtml-with

2005-08-30 Thread John Eikenberry
Alexander Limi wrote:

> 
> Wow, I had forgotten how incredibly ugly DTML can be. That just looks  
> wrong, like you stumbled on your keyboard. Maybe I should go hang out on  
> the perl lists and build up some tolerance for "interesting" syntax. :^)
> 
 
Yes. DTML is ugly, which is why its bee superseded by page templates. ZPTs
are much nicer and just about the best way to do html-embedded display
code that I've seen. At least compared to the alternatives.

-- 

John Eikenberry [EMAIL PROTECTED]
__
"A society that will trade a little liberty for a little order
 will deserve neither and lose both."
  --B. Franklin
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] passing a parameter - namespace and dtml-with

2005-08-30 Thread John Eikenberry
Peter Bengtsson wrote:

> Better
> 
> 
> 
> 
> 
> 
> 
> Use dtml-let and notice the extra _ in the parameters. I doubt that
> DTML methods accept plain arguments except self, REQUEST and RESPONSE.
> All other things must be passed with keyword arguments.
 
Opps. Yes. dtml-let is what you should use. Been awhile since I've done to
much with dtml.

-- 

John Eikenberry [EMAIL PROTECTED]
__
"A society that will trade a little liberty for a little order
 will deserve neither and lose both."
  --B. Franklin
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] passing a parameter - namespace and dtml-with

2005-08-29 Thread John Eikenberry
Sean Kelley wrote:

> I am trying to pass the title of a page to a dtml method which is in another 
> folder named links. If I pass the actual title like below everything works. 
> However, when I try to pass the value of the current title to 
> category_results using various other methods it does not.
> What is the syntax so that I can pass the current value of  
> to the method? Would the dtml-with block change the namespace it pulls the 
> title variable from to the context of the method category_results in the 
> links folder?

Yes.

Here's a quick hack that will work.






>  
> This line works
> 
> 

> ___
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )


-- 

John Eikenberry [EMAIL PROTECTED]
__
"A society that will trade a little liberty for a little order
 will deserve neither and lose both."
  --B. Franklin
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] manage_afterAdd quirks

2005-08-24 Thread John Eikenberry
Philip J?genstedt wrote:

> It seems I need one of three things:
> 
> 1. A better way to add images and a template altogether.
> 2. A hook which is only called once, when the object is first created.
> 3. A method to check if the objects exist in the newly added item
> directly, not aquired.

As Peter mentioned, use aq_base. There are 2 ways to use it. One as an
object attribute (self.aq_base) or using the aq_base() function as imported
from Acquisition. The latter method won't cause an attribute error if you
already are working with the non-acquisition object (in that case it will
simply return the object. For what you are doing I recommend one of these
methods.

To get more control over when manage_afterAdd runs some code, you can set
some flags using the copy hooks. Before running manage_afterAdd when
copying/moving/renaming ObjectManager calls the method _notifyOfCopyTo() on
the object being copied/moved/renamed. It passes one argument (op) giving
some context to the call. It is set to 1 for moves and renames, and set to
0 for copies. 

So you can use this to set a flag on your object to modify
manage_afterAdd's behaviour in these circumstances. Eg.

class Container(ObjectManager):

def _notifyOfCopyTo(self,op):
# use a _v_ volitile attribute here to avoid persistence
self._v_copy_flag = op

def manage_afterAdd(self, item, container):
if hasattr(self,'_v_copy_flag'):
if self._v_copy_flag == 0:
# stuff you want done when copying
...
if self._v_copy_flag == 1:
# stuff you want done when moving/renaming
...
# clear the flag
delattr(self,'_v_copy_flag')
else:
# stuff you want done only on initial install
...
# stuff you want done no matter what.
.,.

Of course you can simplify this if you don't care if its been moved,
renamed or copied. Just wanted to show the different possibilities.

-- 

John Eikenberry [EMAIL PROTECTED]
__
"A society that will trade a little liberty for a little order
 will deserve neither and lose both."
  --B. Franklin
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: FIXED: Re: [Zope] URL0 returns index_html not index.html

2005-08-24 Thread John Eikenberry
Mark Barratt wrote:

> Well, no, because some of the objects I want to append /source.html to 
> are not called index.html (but that *is* how we did it for another site 
> and it works as you say).
> 
> A text substitution covers both cases:
> 
> tal:attributes="href 
> python:context.REQUEST['URL0'].replace('index_html','index.html')+'/source.html'"

Wouldn't this just result in "[path]/index.html/source.html"? Do you want
the index.html in the URL to source.html. This will work with Zope but
looks strange. Using URL1 instead of URL0 would leave the index[._]html
off the generated URL. 
 
> >If you were working with zope projects there are other tricks you could
> >pull, but it doesn't sound like you are doing this.
> 
> I don't understand this: is a 'zope project' different from my project 
> using zope?

Opps. I meant a 'zope product', ie. a python based product.
 

-- 

John Eikenberry [EMAIL PROTECTED]
__
"A society that will trade a little liberty for a little order
 will deserve neither and lose both."
  --B. Franklin
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] URL0 returns index_html not index.html

2005-08-18 Thread John Eikenberry
Mark Barratt wrote:

> Zope 2.7.4 on Debian
> 
> DTML method index_html in the root says 
> 
> A link in a page template to
> 
> tal:attributes="href string:${context/REQUEST/URL0}/source.html

URL0 always(?) includes the ending published object (eg. index_html).
Normally if you don't want this you just use URL1.

> where the page is addressed by [path]/ and is actually at [path]/index.html
> 
> returns [path]/index_html/source.html

Using URL1 you should get [path]/source.html which would seem to me to be
what you want.
 
> I can vaguely see why this is happening. My question: is there a 
> straightforward way of making the links (and error reports) return the 
> actual page address?

By actual page address you want the URL with index.html instead of
index_html? Given your current setup as described, redirecting would work.



Though this would cause every hit on a page's index to tranverse twice. If
the site isn't super high traffic it wouldn't be noticable.

If you were working with zope projects there are other tricks you could
pull, but it doesn't sound like you are doing this.

> (I think I understand that 'actual' 'page' and 'address' are all 
> metaphors which may be leading me into error... )

In zope there is the URL which represents the object traversal and there is
the returned content (html, images, etc). The returned content (maybe what
you mean by actual page) can feasibly come from some other part of the
site, a database, or just about anything else. The URL or address is just
what method/object gets run to get said content.

> Thanks for any help/enlightenment.
 
Not sure if I'm making this much clearer. But there it is anyways.
 

-- 

John Eikenberry [EMAIL PROTECTED]
__
"A society that will trade a little liberty for a little order
 will deserve neither and lose both."
  --B. Franklin
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )