[Zope] Testing for and/or avoiding acquisition

Dylan Reinhardt zope@dylanreinhardt.com
09 Jul 2003 07:00:19 -0700


Ah... I misread your requirements.

I think that may have been because what you're trying to do is use Zope
like it's some other kind of system... a web server, perhaps.  You're
not working with files here, but methods.

Here's how I'd recommend thinking about this...

You want to have one content *method* and several content sources.  The
content method will be located in the root.  The sources will be located
in each folder you want to have one.

Ex:

/ (root object)
   content.html  (your method)
   /folder1
      content_src
   /folder2
      content_src
      /folder2a
         content_src
   /folder3
   /folder4

A URL of the form:

http://myserver/folder2/folder2a/content.html

will have the effect of calling the content.html *method* in the context
of folder2a.  All you have to do, then, is check if the folder has a
content_src object & if it doesn't, you provide some default value
instead.

Your content.html method could be as simple as:

<dtml-if "'content_src' in objectIds()">
   <dtml-var content_src>
<dtml-else>
   There is no content_src object in this folder
</dtml-if>

This should fit the bill just fine.

HTH,

Dylan


On Wed, 2003-07-09 at 06:03, Phil Bradbury wrote:
> An interesting way of proceeding... however, if a subfolder has no
> content.html file it will call the next one up in the hierachy (the parent
> folder) rather than the one at root level - and as such will negate the
> effect of placing the method at root. It would work for a small site with
> not a deep hierachy I guess, but not for what we need it for.
> 
> The concept is not too radical - all I want to do is to parse a content.html
> file in the local folder (if one exists) and to replace it with the content
> of no_content.html if it doesn't. The no_content.html file will ultimately
> just be a sort of aide-memoire saying 'you have no "content.html" file in
> this folder' rather than just parsing one higher up which will show
> non-relevant information for the folder.
> 
> Hope this makes a bit of sense!
> 
> Phil
> 
> -----Original Message-----
> From: Dylan Reinhardt [mailto:zope@dylanreinhardt.com]
> Sent: 09 July 2003 13:22
> To: phil.bradbury@man.ac.uk
> Cc: zope@zope.org
> Subject: Re: [Zope] Testing for and/or avoiding acquisition
> 
> 
> In the case you've described, I would work *with* acquisition, rather
> than avoid it or thwart it.
> 
> Put a method in your root called 'content.html' and make it do whatever
> you wanted done by your 'no-content.html' object.  Then proceed to place
> other 'content.html' objects where you want them to apply.
> 
> If there is no other content.html available, the one in the root will be
> called... and whatever you want done in that case will be done.
> 
> HTH,
> 
> Dylan
> 
> 
> On Wed, 2003-07-09 at 01:37, Phil Bradbury wrote:
> > Hello.
> >
> > Probably a simple problem but one I can't seem to solve.
> >
> > I have a site with many folders and subfolders, no problem there. What I
> > want to do is to use a file called 'content.html' to be parsed in each
> > folder but that if there is no such file IN THAT FOLDER it uses a
> > no-content.html' file acquired from 'root' level.
> >
> > Is it possible to check ONLY the container folder for the existence of the
> > required 'content.html' file and if it does not exist to use the
> > 'no-content.html' file from above? If so, how is it done?
> >
> > I'm using TAL rather than DTML and my brain is hurting from trying to sort
> > this out!!
> >
> > I have RTFM but still can't seem to figure out the syntax. Help would be
> > much appreciated!
> >
> > Thanks,
> >
> > Phil
> >
> >
> >
> > _______________________________________________
> > 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 )
> 
> 
> 
> 
> _______________________________________________
> 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 )