[Zope] How to insert a DTML doc given its ID as a string?

Phil Harris phil@harris-family.info
Thu, 14 Mar 2002 09:39:04 -0000


Eeee, you don't wanna do that!

returning document_src will give you the unrendered view of it, something
like this will be better:

#test if thisWeeklyMain exists
doc = getattr(context, 'thisWeeklyMain', None)
if doc:
  # if yes return its content
  return doc(context,context.REQUEST)
else:
  # other document must exist
  return getattr(context, 'otherDoc')(context,context.REQUEST)

this passes the namespace into the document and also uses context as the
container.


----- Original Message -----
From: "Robert Rottermann" <robert@redcor.ch>
To: <bill-bell@bill-bell.hamilton.on.ca>; <zope@zope.org>
Sent: Thursday, March 14, 2002 6:44 AM
Subject: Re: [Zope] How to insert a DTML doc given its ID as a string?


> I would do this in an script.
> Lets call it "insertIf"
>
> #test if thisWeeklyMain exists
> doc = getattr(context, 'thisWeeklyMain', None)
> if doc:
>   # if yes return its content
>   return doc.document_src()
> else:
>   # other document must exist
>   return getattr(context, 'otherDoc').document_src()
>
> now use this script like this
> <dtml-var insertIf>
>
> robert
>
> ----- Original Message -----
> From: "Bill Bell" <bill-bell@bill-bell.hamilton.on.ca>
> To: <zope@zope.org>
> Sent: Thursday, March 14, 2002 2:27 AM
> Subject: [Zope] How to insert a DTML doc given its ID as a string?
>
>
>
> Must be trivial. Can't find answer.
>
> 'thisWeeklyMain' is a Python routine that supplies the name of a DTML doc
> that _might_ exist in the current folder. I'd like to arrange to insert
the
> DTML doc, if it exists, or an alternative doc, if it does not.
>
> Thanks for your help.
>
> Bill
>
> ------------
> "It is the time that you have wasted for your rose that makes your rose so
> important."--St-Exupery
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )