[albatross-users] Equivalent of PHP include
Michael C. Neel
neel at mediapulse.com
Wed Feb 18 00:47:17 EST 2004
I've grabbed XML documents before with albatross. Not sure a tag would
help, since it would be rare to include a document un-parsed inside of a
page, but it would be a simple tag. The method I used was:
# page module
from urllib import urlopen
def page_process(ctx):
...
pagedata = urlopen("http://www.somesite.com/xml/news.rss")
... doing stuff to pagedata ...
ctx.locals._pageresult = pagedata
(Actually I parse pagedata inro a list of ocjects to al-for over). I
suppose you could do:
<al-value expr='urlopen("http://www.somesite.com/xml/news.rss")'
noescape> and get output very similar to PHP.
remember, python is batteries included =p
Mike
> -----Original Message-----
> From: Tim Churches [mailto:tchur at optushome.com.au]
> Sent: Monday, February 16, 2004 10:45 PM
> To: Andrew McNamara
> Cc: Sean Holdsworth; albatross-users @ object-craft . com . au
> Subject: Re: Re: [albatross-users] Equivalent of PHP include
>
>
> Andrew McNamara <andrewm at object-craft.com.au> wrote:
> >
> > >First question to the list, and probably a really dumb one to
> > boot...
> > >
> > >I can't seem to find a simple equivalent to the PHP include
> > directive.
> > >I want to be able to insert the contents of a specified
> URL at some
> > >point in a template, rather like a server side include.
> This is easy
> > to
> > >do using 'al-include' for a file but doesn't seem to work
> for a URL.
> > I
> > >kludged things by making a copy of the remote data in a local file
> > and
> > >using 'al-include'. I've also toyed with writing a macro to do this
> > for
> > >a general URL but it's such a simple thing to want to do I
> think I'm
> >
> > >missing something. Any clues appreciated.
> >
> > You're not missing something - Albatross doesn't do this.
> >
> > I wonder what PHP is doing? It's not a trivial exercise to include
> > the
> > content of another page without breaking the rules of HTML
> - strictly
> > speaking, it should be stripping off the enclosing <HTML>, <BODY>,
> > etc elements (and even this might not be enough).
>
> You're assuming that the referenced URL points to a complete
> HTML page. The
> URL may point to just a snippet of dynamically generated
> HTML, or to a GIF or
> PNG graphic, also possibly dynamically generated by a Web
> service elsewhere.
>
> Tim C
> _______________________________________________
> Albatross-users mailing list
> Albatross-users at object-craft.com.au
> https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albat
ross-users
More information about the Albatross-users
mailing list