CBV contrib.sitemaps

99 views
Skip to first unread message

Carl Johnson

unread,
Dec 15, 2015, 11:18:31 AM12/15/15
to Django developers (Contributions to Django itself)
I was adding a sitemap to a project, and I more or less had to rewrite the views from scratch because sitemap expects to receive a dictionary of all possible pages at start up time, which for various reasons I didn't want to have to provide. In general extending sitemaps is pretty difficult because (like contrib.admin, but that's another can of worms) it was made before class-based views, so it doesn't have the notion of creating a new instance for each request.

So my question is this, if I created a class-based version of sitemaps (django.contrib.sitemaps_cbv or whatever), would that pull request be something you would have interest in merging? Or do you consider the existing sitemaps are good enough, and you don't want to have support something new (for example, rewriting all the docs)?

Thanks,

— Carl Johnson 

Shai Berger

unread,
Dec 15, 2015, 6:35:06 PM12/15/15
to django-d...@googlegroups.com
Hi Carl,

On Tuesday 15 December 2015 18:17:36 Carl Johnson wrote:
> I was adding a sitemap to a project, and I more or less had to rewrite the
> views from scratch because sitemap expects to receive a dictionary of all
> possible pages at start up time, [...]

This seems to be a misrepresentation; it takes a dictionary of all site
sections, but each section may well change. E.g. the documentation[1] mentions
a BlogSitemap class -- but surely, new blog posts may be added without
requiring system restart to update the site map...
>
> So my question is this, if I created a class-based version of sitemaps
> (django.contrib.sitemaps_cbv or whatever), would that pull request be
> something you would have interest in merging? Or do you consider the
> existing sitemaps are good enough, and you don't want to have support
> something new (for example, rewriting all the docs)?
>
The above notwithstanding, you may have some real improvements to suggest, in
which case we may be interested. However, we would probably like to see the
prospective new sitemaps used before we'd accept it, so your best path towards
that is to develop your version as a 3rd-party app. We'd probably not like to
keep both versions, though, so if you're trying to write a replacement, you
need to consider issues of backwards compatibility and upgrade path.

HTH,
Shai.

Shai Berger

unread,
Dec 15, 2015, 6:43:37 PM12/15/15
to django-d...@googlegroups.com

Carl Johnson

unread,
Dec 21, 2015, 10:59:19 AM12/21/15
to Django developers (Contributions to Django itself)


On Tuesday, December 15, 2015 at 6:35:06 PM UTC-5, Shai Berger wrote:
Hi Carl,

On Tuesday 15 December 2015 18:17:36 Carl Johnson wrote:
> I was adding a sitemap to a project, and I more or less had to rewrite the
> views from scratch because sitemap expects to receive a dictionary of all
> possible pages at start up time, [...]

This seems to be a misrepresentation; it takes a dictionary of all site
sections, but each section may well change. E.g. the documentation[1] mentions
a BlogSitemap class -- but surely, new blog posts may be added without
requiring system restart to update the site map...

Right, but if you want to add a new section, that would require it to be baked in. My issue was I was skirting the 50,000 page per sitemap limit, so I needed to break my site map up, and the logical way to do that was to add one section for each show on our site, but the number of shows can change dynamically.
 
>
> So my question is this, if I created a class-based version of sitemaps
> (django.contrib.sitemaps_cbv or whatever), would that pull request be
> something you would have interest in merging? Or do you consider the
> existing sitemaps are good enough, and you don't want to have support
> something new (for example, rewriting all the docs)?
>
The above notwithstanding, you may have some real improvements to suggest, in
which case we may be interested. However, we would probably like to see the
prospective new sitemaps used before we'd accept it, so your best path towards
that is to develop your version as a 3rd-party app. We'd probably not like to
keep both versions, though, so if you're trying to write a replacement, you
need to consider issues of backwards compatibility and upgrade path. 

Yeah, that's really the sticking point. From my point of view, rewriting sitemaps for one use case isn't so complicated. Rewriting it from scratch as a CBV is also not so complicated. The complicated part would be to rewrite it as a CBV but keep backwards compatibility, especially because to me the point of the rewrite would be to create a new (hopefully easier to use!) interface for sitemaps. 

I'll think some more about it.

— Carl Johnson 
Reply all
Reply to author
Forward
0 new messages