On 10/06/2014 04:16 AM, Emmanuel Cazenave wrote:
> Hi there,
>
> I'm trying to use substanced to build a simple cms like application.
> I'm having a hard time to figure out how to define my data model, I'll give
> an example regrading the homepage of my app.
>
> Among other things I want to display a title and a text on the homepage.
>
> Options 1:
>
> As the homepage data is kind of a root in the resources hierarchies I can
> define a 'DisplayableFolder' content type which inherit from
> 'substanced.folder.Folder' plus a 'title' and 'text' field. Then my
> 'home_view' callable will get call with an instance of 'DisplayableFolder'
> as context when a user hit
http://myapp.com
> Is it ok to do it that way because it seems wrong to add 'text' and 'title'
> data to a mapping type like 'substanced.folder.Folder' ?
If you define your own type for the root, deriving from
substanced.folder.Folder, it is perfectly normal to give it extra schema.
E.g., see the demo app's BlogSchema:
https://github.com/Pylons/substanced/blob/master/demos/blog/blog/resources.py#L159
used by the custom Blog (derived from Root) content type:
https://github.com/Pylons/substanced/blob/master/demos/blog/blog/resources.py#L189
> Options 2:
>
> My 'home_view' callable gets called with a 'substanced.folder.Folder'
> instance as context and I manually iterate on its children to get for
> example a Document instance (Document would inherit from Persistent as you
> do in substanced documentation) and will get a titlte and a text from that
> Document instance.
If you think a given document (e.g., 'index.html') as the "default page"
for a folder, then I would have the homepage_view() function just redirect
to the document.
Tres.
--
===================================================================
Tres Seaver
+1 540-429-0999 tse...@palladion.com
Palladion Software "Excellence by Design"
http://palladion.com