Question

I have created two content types in Plone 4.3 via Dexterity and created a Plone Product on the file system.

The types are

  • Supplier
  • item

Items can only exist in inside Supplier, and I can manually create new items without

I'd like to be able to create a bunch of items if I upload a CSV file while creating a supplier. Any way dexterity supports this (trigger, custom view...)?

Was it helpful?

Solution

You'd have to handle that in a custom view. There is no pre-existing code to handle that.

For simple cases, just read the uploaded file with the csv module and use the rows to create items in the Supplier container:

from plone.dexterity.utils import createContentInContainer
import csv

reader = csv.reader(uploadedfile)

for row in reader:
    createContentInContainer(supplier, 'your.package.item', title=row[0], ...)

For more complex operations, you could build a transmogrifier pipeline with the transmogrify.dexterity to convert CSV-data to dexterity objects, but that is probably overkill here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top