[Zope3-Users] z3c.sampledata experts please

Darryl Cousins darryl at darrylcousins.net.nz
Sun Nov 12 21:00:36 EST 2006


Hi,

My initial start with z3c.sampledata was enthusiastic but now I don't
know where to go.

The simple scenario is to build sampledata with:

A site
A photo utility in etc
A photo folder

I register the utility::

      <adapter
          name="tfws.gallery.utility"
          factory=".generator.testPhotoUtilityDataFactory"
          for="z3c.sampledata.interfaces.ISampleDataPlugin"
          provides=".generator.IPhotoUtilityDataSource"
          />
      <SampleManager
        name="Sample photo utility"
        >
        <generator
          name="tfws.gallery.utility"
          dataSource="tfws.gallery.utility"
          contextFrom="z3c.sampledata.site" />
        <datasource
          name="tfws.gallery.utility"
          adapterName="tfws.gallery.utility"
          adapterInterface=".generator.IPhotoUtilityDataSource"
          />
      </SampleManager>

This works just fine. I have a print statement in the utility
generator:: print context.__name__ which prints the chosen name for the
sample site.

Now I try to add in the photofolder::

      <utility
          name="tfws.gallery.photofolder"
          factory=".generator.SamplePhotoFolder"
          provides="z3c.sampledata.interfaces.ISampleDataPlugin"
          />

      <adapter
          name="tfws.gallery.photofolder"
          factory=".generator.testPhotoFolderDataFactory"
          for="z3c.sampledata.interfaces.ISampleDataPlugin"
          provides=".generator.IPhotoFolderDataSource"
          />

      <SampleManager
        name="Sample photofolder"
        >
        <generator
          name="tfws.gallery.photofolder"
          dependsOn="z3c.sampledata.site
                     tfws.gallery.utility"
          contextFrom="z3c.sampledata.site"
          dataSource="tfws.gallery.photofolder"
          />
        <datasource
          name="tfws.gallery.photofolder"
          adapterName="tfws.gallery.photofolder"
          adapterInterface=".generator.IPhotoFolderDataSource"
          />
      </SampleManager>

The dependsOn is maybe where I am going wrong though I have tried
numerous approaches.

What happens here is the generator form shows me the 3 samples I want to
generate: site, utility and photofolder but on submit I get 

  File "/opt/zope/sandbox/lib/python/tfws/gallery/utility/generator.py",
line 89, in generate
    sm.registerUtility(util, self.interface)
ForbiddenAttribute: ('registerUtility', <LocalSiteManager ++etc++site>)

The print statement that I mentioned above shows context.__name__ as
None so the utility is not installing to the generated site as I
expected.

I verify this by trying to generate the utility without sample site - ie
with context as the zope app root, and I get the same error.

I need a bit of advice here, because I want to go forward and generate a
large set of sampledata with a site, half a dozen local utilities and
numerous content components. But as you see I can't get a single
component in place with a dependency on a single utility. Some of my
components depend on more than one utility. Help and advice is
definitely required.

Thanks,
Darryl



More information about the Zope3-users mailing list