Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Do's and Dont's for Application Writers
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  15 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sune Kirkeby  
View profile  
 More options Oct 20 2005, 5:23 am
From: Sune Kirkeby <sune.kirk...@gmail.com>
Date: Thu, 20 Oct 2005 11:23:47 +0200
Local: Thurs, Oct 20 2005 5:23 am
Subject: Do's and Dont's for Application Writers
Hullo.

Here is a rough draft of "Do's and Dont's for Application Writers":
http://code.djangoproject.com/wiki/DosAndDontsForApplicationWriters

I'd be much interested in comments, suggestions and
anything people disagree with, but can we keep feedback
on the list? Wikis have horrible threading ;)

/s


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kmh  
View profile  
 More options Oct 20 2005, 5:56 am
From: "kmh" <kieran.holl...@gmail.com>
Date: Thu, 20 Oct 2005 09:56:17 -0000
Local: Thurs, Oct 20 2005 5:56 am
Subject: Re: Do's and Dont's for Application Writers
Hi Sune,

Thanks for getting this thread going.  Your outline is pretty close to
the way I've been doing things too.

Seeing it in writing got me wondering though if the whole idea of
application templates "extending" the base site is wrong-headed.
Because the application knows nothing about the site it is to be
embedded in, the application writer is second-guessing what base
template it is supposed to extend.  Say the 'blog' and 'gallery'
applications need to appear on the same page in different
columns...what then?

Shouldn't we encourage a model where site templates are able to
explicitly "include" application templates, rather than the other way
around?  Though I haven't used it, the 'ssi' tag looks like the kind of
thing I have in mind.

Kieran


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
john.dagostino@gmail.com  
View profile  
 More options Oct 20 2005, 6:03 am
From: "john.dagost...@gmail.com" <john.dagost...@gmail.com>
Date: Thu, 20 Oct 2005 10:03:38 -0000
Local: Thurs, Oct 20 2005 6:03 am
Subject: Re: Do's and Dont's for Application Writers
Hey,
great start. just two comments. why use mnemosyne as the example? why
not something more generic like "myapp" ?

for the media directory, mnemosyne/media/ should be sufficient.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sune Kirkeby  
View profile  
 More options Oct 20 2005, 6:38 am
From: Sune Kirkeby <sune.kirk...@gmail.com>
Date: Thu, 20 Oct 2005 12:38:03 +0200
Local: Thurs, Oct 20 2005 6:38 am
Subject: Re: Do's and Dont's for Application Writers
On 10/20/05, kmh <kieran.holl...@gmail.com> wrote:

> Shouldn't we encourage a model where site templates are able to
> explicitly "include" application templates, rather than the other way
> around?

That's not how applications and templates work. You can't just
include a template from another application, you would be missing
the context that the application views provide.

> Say the 'blog' and 'gallery'
> applications need to appear on the same page in different
> columns...what then?

Then you would have to write a site-specific view and template,
because neither the blog or gallery application can have a view
for that (since they don't know of the other.)

/s


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kmh  
View profile  
 More options Oct 20 2005, 7:39 am
From: "kmh" <kieran.holl...@gmail.com>
Date: Thu, 20 Oct 2005 11:39:19 -0000
Local: Thurs, Oct 20 2005 7:39 am
Subject: Re: Do's and Dont's for Application Writers

>On 10/20/05, kmh <kieran.holl...@gmail.com> wrote:
>> Shouldn't we encourage a model where site templates are able to
>> explicitly "include" application templates, rather than the other way
>> around?
>On 10/20/05, Sune Kirkeby <....@gmail.com> wrote:
>That's not how applications and templates work. You can't just
>include a template from another application, you would be missing
>the context that the application views provide.

A more "include" oriented solution would be to let sites rather than
applications determine which site base template is being extended by an
application template.  I have just discovered the {% extends variable
%} tag, which seems to fit this bill.  It should also be encouraged
that application features that don't depend on the request be made
templates tags rather than views.

Kieran


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sune Kirkeby  
View profile  
 More options Oct 20 2005, 7:59 am
From: Sune Kirkeby <sune.kirk...@gmail.com>
Date: Thu, 20 Oct 2005 13:59:07 +0200
Local: Thurs, Oct 20 2005 7:59 am
Subject: Re: Do's and Dont's for Application Writers
On 10/20/05, kmh <kieran.holl...@gmail.com> wrote:

> >On 10/20/05, kmh <kieran.holl...@gmail.com> wrote:
> >> Shouldn't we encourage a model where site templates are able to
> >> explicitly "include" application templates, rather than the other way
> >> around?

> >On 10/20/05, Sune Kirkeby <....@gmail.com> wrote:
> >That's not how applications and templates work. You can't just
> >include a template from another application, you would be missing
> >the context that the application views provide.

> A more "include" oriented solution would be to let sites rather than
> applications determine which site base template is being extended by an
> application template.

If a site wants different application-templates to extend different
base-templates, they should override the application-templates.
Most sites won't need that kind of over engineering mojo, so we
should not burden sites or applications with it.

And, for some applications it's even downright troublesome.
For example, ibofobi.apps.blog has a blog/base template, which
all the other templates extends. The blog/base template makes
sure all the blog pages contain a common footer and have
the blog-name in the title. Duplicating the title and footer in
all the other templates would be silly.

> It should also be encouraged
> that application features that don't depend on the request be made
> templates tags rather than views.

Yes, definetly. I've put that in.

/s


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Wittams  
View profile  
 More options Oct 20 2005, 8:21 am
From: Robert Wittams <rob...@wittams.com>
Date: Thu, 20 Oct 2005 13:21:16 +0100
Local: Thurs, Oct 20 2005 8:21 am
Subject: Re: Do's and Dont's for Application Writers

I think what you actually want is for applications to provide you with
template tags that encapsulate most of the functionality of thier views.

Then in your site template, you can compose these template tags to your
hearts content.

Maybe this should be a best practice too?

This is very easy with the @inclusion_tag decorator in #625.
(Predicated on 625 being applied (cough...Adrian...cough) , or using
new-admin branch.)

Should I add this to the wiki page?
-------------------------
Parts of your application that may be useful embedded in site views
should be structured as template tags.

Create a template of just the portion of your view that is reusable:

poll/results_panel.html:

<div class="poll-panel" >
   <h3> {{poll.name}} </h3>
   <ul>
   {%for choice in poll%}
      {{ choice}} : {{choice.votes}}
   {%end for%}
   </ul>
</div>

create a template tag using this template,
polls/templatetags/polls.py

@inclusion_tag('poll/results_panel.html')
def results_panel(poll):
    return {'poll': poll}

In your views and site views, use the template tag:
{% load polls %}
{% results_panel poll %}

Sites can override the poll/results_panel.html template to customise
this. It will apply sitewide, including within the app within which the
template tag resides.

(It is of course possible to do this without using @inclusion_tag, but
it is a pain.)

-------------------------------

This seems like a pretty good pattern to me, especially for apps to
provide little summary views for aggregation by sites.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adrian Holovaty  
View profile  
 More options Oct 20 2005, 9:31 am
From: Adrian Holovaty <holov...@gmail.com>
Date: Thu, 20 Oct 2005 08:31:38 -0500
Local: Thurs, Oct 20 2005 9:31 am
Subject: Re: Do's and Dont's for Application Writers
On 10/20/05, john.dagost...@gmail.com <john.dagost...@gmail.com> wrote:

> great start. just two comments. why use mnemosyne as the example? why
> not something more generic like "myapp" ?

I had this same question: What's a mnemosyne? We should change it to "myapp".

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adrian Holovaty  
View profile  
 More options Oct 20 2005, 9:43 am
From: Adrian Holovaty <holov...@gmail.com>
Date: Thu, 20 Oct 2005 08:43:12 -0500
Local: Thurs, Oct 20 2005 9:43 am
Subject: Re: Do's and Dont's for Application Writers
On 10/20/05, kmh <kieran.holl...@gmail.com> wrote:

> Seeing it in writing got me wondering though if the whole idea of
> application templates "extending" the base site is wrong-headed.
> Because the application knows nothing about the site it is to be
> embedded in, the application writer is second-guessing what base
> template it is supposed to extend.  Say the 'blog' and 'gallery'
> applications need to appear on the same page in different
> columns...what then?

The way we've done things for the past 2 years at World Online, with
dozens of decoupled Django apps, is to have a standard convention for
templates. Here's a short explanation of the convention, which I think
we should promote:

* All app templates assume there's a "base_generic" template and {%
extend %} it.
* All app templates assume the <title> is in {% title %}.
* All app templates assume there's a {% block extrahead %} within the
<head>. This is a hook for putting arbitrary things in <head>.
* All app templates assume the parent templates have defined {% block
content %}, for the main content area of the page.

Essentially, the convention is to assume these base templates:

base.html:

"""
<html>
<head>
<title>{% block title %}{% endblock %}</title>
{% block extrahead %}{% endblock %}
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
"""

base_generic.html

"""
{% extends "base" %}
<!--Provides a hook for customizing the look and feel on a
"section"-specific basis. For example, this can customize subnavs.
Make a base_* template for each section of the site, e.g. base_sports,
base_news, base_about. -->
"""

Solidifying a convention like this would go a long way in making
Django apps easily pluggable (via their default templates). Of course,
it shouldn't (and won't) be required that app users *use* the default
templates that come with an app -- they're just a quick starting point
and serve as documentation.

I'd even go so far as to say we could include the above base.html and
base_generic.html in the Django distribution proper, to give people a
starting point when creating their templates.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sune Kirkeby  
View profile  
 More options Oct 20 2005, 10:39 am
From: Sune Kirkeby <sune.kirk...@gmail.com>
Date: Thu, 20 Oct 2005 16:39:14 +0200
Local: Thurs, Oct 20 2005 10:39 am
Subject: Re: Do's and Dont's for Application Writers
On 10/20/05, Adrian Holovaty <holov...@gmail.com> wrote:

> I had this same question: What's a mnemosyne? We should change it to "myapp".

Mnemosyne is the greek goddess of memory, I pulled it out of
the hat, because I think myapp is so boring and impersonal.

But, feel free to change it.

/s


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sune Kirkeby  
View profile  
 More options Oct 20 2005, 10:46 am
From: Sune Kirkeby <sune.kirk...@gmail.com>
Date: Thu, 20 Oct 2005 16:46:25 +0200
Local: Thurs, Oct 20 2005 10:46 am
Subject: Re: Do's and Dont's for Application Writers
On 10/20/05, Adrian Holovaty <holov...@gmail.com> wrote:

> * All app templates assume there's a "base_generic" template and {%
> extend %} it.
> * All app templates assume the <title> is in {% title %}.
> * All app templates assume there's a {% block extrahead %} within the
> <head>. This is a hook for putting arbitrary things in <head>.
> * All app templates assume the parent templates have defined {% block
> content %}, for the main content area of the page.

I like that very much, except for one little nitpick. Is there any reason
for using underscores instead of dashes? A dash is so much is easier
to type.

I'll fold it into Do's and Dont's.

> I'd even go so far as to say we could include the above base.html and
> base_generic.html in the Django distribution proper, to give people a
> starting point when creating their templates.

In project_template/templates/?
And maybe app_template/templates/base.html which just extends
base_generic?

/s


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sune Kirkeby  
View profile  
 More options Oct 20 2005, 10:59 am
From: Sune Kirkeby <sune.kirk...@gmail.com>
Date: Thu, 20 Oct 2005 16:59:40 +0200
Local: Thurs, Oct 20 2005 10:59 am
Subject: Re: Do's and Dont's for Application Writers
On 10/20/05, Robert Wittams <rob...@wittams.com> wrote:

> Should I add this to the wiki page?

Feel free. But, please don't use @decorator syntax, it's not 2.3-safe.

/s


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kmh  
View profile  
 More options Oct 20 2005, 4:13 pm
From: "kmh" <kieran.holl...@gmail.com>
Date: Thu, 20 Oct 2005 20:13:12 -0000
Local: Thurs, Oct 20 2005 4:13 pm
Subject: Re: Do's and Dont's for Application Writers

> >On 10/20/05, Sune Kirkeby <....@gmail.com> wrote:
> If a site wants different application-templates to extend different
> base-templates, they should override the application-templates.
> Most sites won't need that kind of over engineering mojo, so we
> should not burden sites or applications with it.

Ok, charge of "overengineering mojo" accepted: I missed that your
proposed set up made it very easy just to override the "base"
application template to achieve the same end.

Kieran


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Willison  
View profile  
 More options Oct 21 2005, 11:03 am
From: Simon Willison <swilli...@gmail.com>
Date: Fri, 21 Oct 2005 16:03:50 +0100
Local: Fri, Oct 21 2005 11:03 am
Subject: Re: Do's and Dont's for Application Writers

On 20 Oct 2005, at 14:43, Adrian Holovaty wrote:

> I'd even go so far as to say we could include the above base.html and
> base_generic.html in the Django distribution proper, to give people a
> starting point when creating their templates.

+1 from me. Let's get Wilson to make them pretty but boring, a bit  
like the default WordPress templates. We could even collect  
contributed starting point templates (2 cols, 3 cols etc) on the wiki.

Cheers,

Simon


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Holsman  
View profile  
 More options Oct 21 2005, 4:58 pm
From: Ian Holsman <kry...@gmail.com>
Date: Sat, 22 Oct 2005 06:58:15 +1000
Local: Fri, Oct 21 2005 4:58 pm
Subject: Re: Do's and Dont's for Application Writers
FWIW.. I offered a set of default templates a while back. on
http://zilbo.com/@downloads
I've been playing with them a tiny bit (they need to include the
base.css file) but they work in a VERY similar way to what is proposed
(which is the way the admin templates work)

Feel free to use these as a base.. they aren't boring, the aim behind
them is you can get a smart looking prototype to your
boss/VC/whoever.. and when you get approval you can make your own
base.

regards
Ian
On 10/22/05, Simon Willison <swilli...@gmail.com> wrote:

--
I...@Holsman.net -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google