[Product-Developers] Extracting internal references from a page

Maurits van Rees m.van.rees at zestsoftware.nl
Wed May 28 08:39:40 UTC 2008


Hi,

When you add a page to your Plone Site and add an internal link in
there this gets added to the reference_catalog.  'yourpage.getRefs()'
will list that content object your point to as a reference, next to
any related items you may have added.  At least that is what happens
in Plone 3.0.

But which part of Plone is doing that?  And specifically: how do I
trigger the references extraction in a test?

Yesterday I started this package:

https://svn.plone.org/svn/collective/collective.portlet.references/

Not fit for use yet, but that will change rapidly.

In the tests I try to add a link in a page like this:

    front = self.portal['front-page']
    front_path = '/'.join(self.folder.getPhysicalPath())
    text_template = u'<a class="link-internal" href="%s">A link.</a>'
    self.folder.invokeFactory('Document', 'page',
                              text=text_template % front_path)
    page = self.folder.page
    self.assertEqual(len(page.getRefs()), 1)

That last assertion fails.  Adding a reindex or a specific recatalog
of the reference_catalog does not help.  I tried a link with
resolveuid too; no luck.

So: any idea how to trigger this?

I could of course also add a testbrowser test to do this.

-- 
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]





More information about the Product-Developers mailing list