1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-27 20:43:56 +00:00
Matias Aguirre 7b0877c50e Changes:
* Simplify article app, it isn't necessary to save them
      in db, instead this tool should render static templates
      directly based in the url.
      Example: if the url is "/article/today" it will look for
      the template "articles/today.html" in articles templates
      directory. This app is configured to handle any url, so
      it will render an url like "/about" (if there isn't other
      url defined to handle "about" before article definition),
      and in this case will try to render the template
      "article.html" in articles templates dir

    * Removed models, not necessary now

    * Removed templatetags, not necessary now

    * Removed flatpages middleware ??

    * Added url to articles app, this will used as a last case
      to handle undefined urls.

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40136
2008-07-29 13:54:20 +00:00

22 lines
584 B
Python

from os.path import join
from django.template import TemplateDoesNotExist
from django.template.context import RequestContext
from django.shortcuts import render_to_response
from django.http import Http404
ARTICLES_TEMPLATES_DIR = "articles"
def render_template(request, path):
if not path.endswith(".html"):
path = path + ".html"
path = join(ARTICLES_TEMPLATES_DIR, path)
try:
c = RequestContext(request)
return render_to_response(path, context_instance=c)
except TemplateDoesNotExist, e:
raise Http404("Article does not exists")