[mod_python] Re: Include directive with variable for filename

Graham Dumpleton graham.dumpleton at gmail.com
Wed Dec 12 15:53:39 EST 2007


It cannot be done using 'include' as it expects a literal string. From
the PSP lexer:

  <DIR>"include"[ ]+"file"[ ]?=[ ]?"\""[^ ]+"\"" {

The way you are doing it is from memory more or less how people do it
dynamically.

Graham

On 13/12/2007, Roman Gaufman <hackeron at gmail.com> wrote:
> I'm currently doing:
>
> content_file = PSP(req, filename=myfilename)
> content_file.run()
>
> If there is anyway to do the same with include or a cleaner way to
> achieve the same otherwise, any information would be very appreciated.
>
> Roman
>
> On 12 Dec 2007, at 13:11, Roman Gaufman wrote:
>
> > No one has any ideas/suggestions? :(
> >
> > Roman
> >
> > On 10 Dec 2007, at 04:03, Roman Gaufman wrote:
> >
> >> Dear mod_python mailinglist,
> >>
> >> I'm trying to do:
> >>
> >> <%@ include file=filename %>
> >>
> >> filename being a variable defined earlier as code but it won't work
> >> unless I use a string for file.
> >>
> >> I also tried string formatting:
> >>
> >> <%@ include file="%s" % filename %>
> >>
> >> Which throws an exception :(
> >>
> >> Is there any work around to pass a variable to the include directive?
> >>
> >> Roman
> >
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>


More information about the Mod_python mailing list