On Sun, Nov 23, 2014 at 5:28 AM, martin f krafft <madd...@madduck.net>
wrote:

> Hello,
>
> we have a Django project with a few pages that come from Git.
> Currently, Apache rewrite rules serve those files statically (and
> they make use of the same template/CSS as Django does, so the user
> does not actually notice), and it's a massive hack and pain to keep
> up-to-date.
>
> Hence I was thinking: how much trouble would it be to have Django
> reach into Git rather than its database and obtain data there to be
> filled into template slots? Ideally, there'd be the possibility of
> running a filter (e.g. reStructuredText) between Git and the
> template rendering.
>
> I've seen http://luispedro.org/software/git-cms, but that does way
> more than just sourcing from Git. And it's not immediately obvious
> to me how it even does the Git interaction.
>
> What I envision is a storage layer (with optional caching) that
> either fetches from the filesystem (with a Git checkout, using mtime
> for cache expiration), or directly from a local Git repo (using
> either commit or blob hash for cache expiration).
>
> Does anyone know of such a module? Would it be hard to write? Where
> would one start?
>

The problem is that there isn't one. There's several :-)

I'm aware of at least 3:

https://pypi.python.org/pypi/GitPython/0.3.2.1
https://pypi.python.org/pypi/pygit2
https://pypi.python.org/pypi/dulwich

These are all Python wrappers around the Git API - and, in the case of
dulwich, a full re-implementation of git in Python. Using these APIs, you
should be able to retrieve an file with an arbitrary hash, the same as you
would at the command line.

I haven't used any of them myself, so I can't comment on which one is
best/most stable/most reliable/fastest, but:

 * Yes, they exist

 * Yes, you could use these modules to retrieve information from the git
checkout as part of a view

 * Yes, that data could then be passed to a template, either directly, or
after post-processing with a filter of some kind.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq849yt%2BU99gWy66uGD_%2BC2%2BuKZoQ2OTAop8UWuLGa9BvOkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to