Re: making flavours easier
will guaraldi <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 14 Mar 2005, Russell Nelson wrote:
>
> Well done! May I offer this enhancement? Works a champ with a blogroll
> that looks like this:
>
> http://blog.russnelson.com Russell Nelson
> http://angry-economist.russnelson.com The Angry Economist
>
> and an inclusion that looks like this:
>
> $util::include("blogroll.data",'<li><a href="%s">%s</a>\n')
>
> --- plugins/pyinclude.py Wed Mar 9 15:01:24 2005
> +++ plugins/pyimport.py Mon Mar 14 10:39:35 2005
> @@ -90,7 +75,7 @@
> def verify_installation(request):
> return 1
>
> -def include(req, filename):
> +def include(req, filename, template=None):
> """
> This takes in one argument--a filename. It opens the file, reads
> in the contents, and returns them as the value of this variable.
> @@ -108,7 +93,12 @@
>
> try:
> f = open(filename, "r")
> - lines = "".join(f.readlines())
> + if template:
> + lines = ""
> + for line in f:
> + lines += template % tuple(line.rstrip().split('\t'))
> + else:
> + lines = "".join(f.readlines())
> f.close()
> return eval_python_blocks(req, lines)
> except:
Uh... I don't think that's necessary. You should just Pythonize your
blogroll.data file so it'd be something like this:
%<----------------------------------------
<%
blogroll = [
("http://blog.russnelson.com", "Russell Nelson"),
("http://angry-economist.russnelson.com", "The Angry Economist"),
]
for url, name in blogroll:
print "<li><a href=\"%s\">%s</a>" % (url, name)
%>
%<----------------------------------------
/will
--
whatever it is, you can find it at http://www.bluesock.org/~willg/
except Will--you can only see him in real life.
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click