[Product-Developers] need help with creating content using generic setup
Hilbert Markus
hilbert.markus at gmail.com
Wed Dec 10 14:39:05 UTC 2008
again, thank you andrew!
after struggling around with generic setup and portal catalog, i think
i got it.
so here is what i did:
first i've added a method to setuphandlers.py:
from Products.CMFCore.utils import getToolByName
def updateCatalog(context):
"""update catalog for displaying profile structure correct"""
catalog = getToolByName(context.getSite(), 'portal_catalog')
query = {}
# add any type you need
query["Type"] = ("Large Folder", "Page")
res = catalog.searchResults(**query)
for r in res:
r.getObject().update()
the next step was to register this method in import_steps.xml
<import-step id="<project>.theme.catalogUpdate"
version="20081209-01"
handler="<project>.theme.setuphandlers.updateCatalog"
title="<project> Theme: final import steps">
<dependency step="plone-final" />
This step will update the gs structure in the catalog
</import-step>
final step:
uninstalled the theme (to get rid of the generated folders) and
installed it again.
now i have the title from .properties inside the listings, sections
and everything else.
but i think there is a drawback:
on a larger plone site, having lots of folders, pages, etc the catalog-
query and update on the objects might take some time.
iham
On Dec 2, 2008, at 11:43 PM, Andrew Burkhalter wrote:
> Oops. Meant to reply all. I'll send the same message to the list.
>
> On Tue, Dec 2, 2008 at 2:43 PM, Andrew Burkhalter <andrewburkhalter at gmail.com
> > wrote:
> I was a bit hasty on the details in my initial response. The reason
> you're only getting ids within listing views (i.e. navigation,
> folder listings, etc) is because these are entirely driven from
> catalog queries. Roughly what's happening when your desired
> GenericSetup site structure is created is the following:
>
> - Create an instance of some type with an id of foo
> - The creation of this instance is done by the portal_types tool and
> the particular method leads to a catalog entry with the id, path,
> and type
> - From this point forward catalog listings will begin to return the
> item in question based on what it has available in an item's catalog
> brains
> - Next it parses your .properties file setting things like the title
> and description. It does not however, reindex the item in the
> catalog.
>
> Thus, when you go to an item's full detail page the object has been
> "woken up" and the presentation is happening entirely based on the
> values of the content object, not what was in the brain. This also
> explains why editing and saving an item causes things to work as
> expected in listing views. That triggers a recatologing.
>
> You'll just need to provide the recataloging of each item yourself
> for consistent behavior across listing and detail pages.
>
> Andrew
>
>
>
> On Tue, Dec 2, 2008 at 12:05 PM, Hilbert Markus <hilbert.markus at gmail.com
> > wrote:
> hi andrew,
>
> i'll check that.
>
> thanks for your help
>
>
> there is another point i forgot to mention:
>
> when calling the folder 'foo' on the portal like localhost:8080/
> myportal/foo
> the title displayed in the standard folder view
> (documentfirstheading) is 'FooBar', which is the title i set inside
> foo/.properties
>
> iham
>
>
> On Dec 2, 2008, at 8:58 AM, Andrew Burkhalter wrote:
>
>> The last I checked, there was no way to trigger a portal_catalog
>> rebuild/update upon content creation. You'll need to either
>> rebuild the catalog or reindex your created objects after the
>> structure step has run within a custom import step.
>>
>> See for example all of the 'reindexObject' method calls here:
>> http://svn.plone.org/svn/plone/Plone/tags/3.1.7/Products/CMFPlone/setuphandlers.py
>>
>> Hope that helps.
>>
>> Andrew
>>
>>
>> On Thu, Nov 27, 2008 at 6:38 AM, Hilbert Markus <hilbert.markus at gmail.com
>> > wrote:
>> hi list,
>>
>> i'm interested in creating some folders by using generic setup.
>> i did that following this instruction:
>> http://plone.org/documentation/how-to/add-a-folder-structure-to-your-product
>>
>> my profile looks like that:
>> profile/
>> default/
>> structure/
>> .objects # containing foo,Large Plone
>> Folder
>> foo/
>> .objects # file is empty
>> .properties
>>
>> .properties contains
>> [DEFAULT]
>> description = This is a foobar folder
>> title = FooBar
>>
>> after installing the product a 'foo (FooBar)'-folder has been
>> created in portal-root.
>> but on the plone site (not zmi) the folders displayed title (in
>> portal-section and contents-list) is 'foo' like the name of the
>> folder on the filesystem.
>>
>> after clicking edit and save without any changes the correct title
>> FooBar is displayed.
>> i think thats not the way it should be...
>>
>> any ideas/help?
>>
>> ah, my setup (buildout-based)
>> * Plone 3.1.7
>> * CMF 2.1.1
>> * Zope (Zope 2.10.6-final, python 2.4.4, darwin)
>> * Python 2.4.4 (#1, Nov 17 2008, 15:59:05) [GCC 4.0.1 (Apple
>> Inc. build 5465)]
>> * PIL 1.1.6
>>
>>
>> iham
>>
>>
>> _______________________________________________
>> Product-Developers mailing list
>> Product-Developers at lists.plone.org
>> http://lists.plone.org/mailman/listinfo/product-developers
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20081210/bb13157d/attachment.html>
More information about the Product-Developers
mailing list