pombreda / django-page-cms

Automatically exported from code.google.com/p/django-page-cms
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Please detach Content from Page #136

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm suggesting that we allow Content to be attached to any model.

This gives the benefit that people can use the existing content framework
against their own models (eg a product model) without having to create
pages specifically for those products.

Naturally admins would only be able to edit the content through the page,
but I believe this is what we're striving towards anyway.

Executing this in code *should* be easy because lookups are one-way (we
never need to create a Page object given a block of content, so just
swapping the FK link to the Page model with a string representation should
do it.

A string representation: "%s.%s" % (ob.__class__.__name__, ob.pk)

However, I've tried this and it's not going entirely to plan (getting
infinite recursion issues).

If this seems like even a mildly good idea, I'd really appreciate a hand.

Original issue reported on code.google.com by oli-...@thepcspy.com on 4 Aug 2009 at 12:21

GoogleCodeExporter commented 9 years ago
That seems like a good idea for me. But I can't really give you that much help 
for
the moment.

If you can provide a patch that doesn't break any tests and cause big 
performance
issues I will definitely include it in the code base.

Original comment by batiste....@gmail.com on 13 Aug 2009 at 5:00

GoogleCodeExporter commented 9 years ago
Hi,

Here is a patch I put together and that almost pass with all the tests. The 
only big
problem is that it's quite difficult to make the site framework with a generic 
key:

{{{
    def get_content_slug_by_slug(self, slug):
        """Returns the latest :class:`Content <pages.models.Content>`
        slug object that match the given
        slug for the current site domain."""
        content = self.filter(
            type='slug',
            content_type=PAGE_CTYPE,
            body=slug
        )
        # this will not work with related object
        if settings.PAGE_USE_SITE_ID:
            content = content.filter(related_object__sites__id=settings.SITE_ID)
}}}

But it could be easily re factored to avoid this complicated SQL request.

What do you think? Is this detached really a useful feature? I am not 100% 
convinced
myself about this.

Original comment by batiste....@gmail.com on 29 Aug 2009 at 11:31

Attachments: