[Grok-dev] Re: A Django-like admin in Grok
Robert Gravina
rg at digitaleskimo.net
Thu Apr 24 03:22:31 EDT 2008
On 23/04/2008, at 9:52 PM, Martijn Faassen wrote:
> Hi there,
>
> On Wed, Apr 23, 2008 at 1:23 AM, Robert Gravina
> <rg at digitaleskimo.net> wrote:
> [snip]
>> I wrote a Django template tag to allow you to adapt an object from
>> within
>> a Django template. Most of the time this happen in python code, but
>> occasionally I need to adapt an object from a template to access an
>> attribute/method. From Django templates, you can call object
>> methods but can
>> run arbitrary code e.g. adapt an object to an interface.
>>
>> So, I have something like this to adapt object instance "article"
>> to an
>> zopeify.interfaces.IArchived:
>>
>> {% adapt article to zopeify.interfaces.IArchived as archived %}
>>
>> Then I can call it like {{archived.getAbsoluteURL}} which returns a
>> URL
>> based on a date attribute.
>
> On a slightly unrelated topic:
>
> How hard is it to use Django templating outside of Django? Is it a
> seperate library?
While I'm new to Django, it seems apparently, it can be done. If you
look at the last section of this page it describes what you need to do
to use it outside of Django:
http://www.djangoproject.com/documentation/templates_python/
> If so, it wouldn't be too hard to integrate this
> into a Grok extension, as we have a pluggable templating language
> system. We could throw in this adaptation bit too. :)
:)... Django tempalates differ from ZPT in that they are not XML-
based... so your output may not be valid, or even XHTML at all (can be
used as a general text processor). Not sure how this effects Grok...
They have some interestesting features... like defining your own tags
(as I did with the adapt tag) and filers (which you can string
together like unix pipes). They also contain branching and looping.
They allow following attribute/method chains, but disallow arbitrary
python code.
> I think having this would be great, as I've heard people say good
> things about the Django templating language. Having this would also
> make it easier for people familiar with Django to learn Grok.
Yes they have been easier to work with than XML-based templates in my
experience... according to the Django people, designers have been able
to use them effectively.
Well, it seems that I've missed my chance with Grok on this project,
and was entirely my fault because I didn't check it out or consult
here properly before diving into working on the site in Django..
Django *does* have a nice admin, and application-level plugins, which
I would happily trade for a unit-tested, interface-adapting framework
but didn't think I could replicate all that in the time we have :(.
Martjin's megrok:bread or Sebastions ProtonCMS could be a really good
base to get Grok into the mainstream web development world... if
frustrates me that Django is so popular despite it's (IMNSHO) very bad
design. Python needs a well designed, flexible web framework with
basic content management! I can see basically two frameworks that
could actually do this if they have the content editing sorted - Grok,
and Nevow... Nevow doesn't have workflow and a few other features ,but
the Twisted guys sure know how to code too :)
I might have to pass on Grok for this project but I'd like to
contribute in some way to this effort if I can...
Robert
More information about the Grok-dev
mailing list