Package: wm.sampledata
ContentsWhy use this?How to use itInstallationWhy yet another package?TODOContributeChangelog0.7.0 (2021-04-29)0.6.1 (2019-10-29)0.6.0 (2019-10-29)0.5.2 (2016-06-14)0.5.1 (2016-05-03)0.5 (2016-03-31)0.4 (2016-03-08)0.3 (2014-08-25)0.2.2 (2013-05-08)0.2.1 (2012-05-29)0.2 (2011-12-02)0.1 (2011-01-31)Why use this?Standardized sampledata makes it soo much easier to work on a project
(especially when working in teams).This package eases the generation of sampledata for your plone project.How to use itFor developers working on a project there’s a view listing and running
all available sampledata plugins:http://localhost/plone/@@sampledataBy default the view does not list any plugins.
The screen above shows the example plugin activated via<includepackage="wm.sampledata.example"/>.Writing and registering your custom sampledata plugin is very easy:fromwm.sampledataimportutilsclassMyPlugin(object):implements(ISampleDataPlugin)title=u"My Plugin Content"description=u"Creates a portlet and a random image"defgenerate(self,context):portlet=StaticAssignment(u"Sample Portlet","<p>some content</p>")utils.addPortlet(context,'plone.leftcolumn',portlet)utils.createImage(context,'random-nature.jpg',file=utils.getRandomImage(category='nature',gray=False),title=u"Random Image",description=u"Downloaded from lorempixel.com")utils.createImage(context,'random-sportscar.jpg',file=utils.getRandomFlickrImage(keywords=['car','sport'],match_all_keywords=True,gray=False),title=u"Random Flickr Image",description=u"Downloaded from loremflickr.com")myPlugin=MyPlugin()component.provideUtility(myPlugin,ISampleDataPlugin'my.plugin')Seewm.sampledata.examplefor a complete example of a custom plugin.You can also group plugins (and even other plugin-gropus) so users need to run only one plugin to setup their sampledata correctly.fromwm.sampledataimportPluginGroupclassTestPortal(PluginGroup):PLUGINS=[MyPlugin,# also 'my.plugin' could be usedMainMenu,AnotherPluginGroup,]title=u"Complete Test Portal"description=u"Creates Main Menu items, Sampledata Folder and Portlets"Note that you can use the utility names as well inPLUGINSbut using classes directly is more straight forward in most cases.There is a growing set of utility methods inwm.sampledata.utils(eg for
handling portlets and files, or download images fromhttp://lorempixel.com)
which you can use in your plugins.InstallationSimply addwm.sampledatato your buildout’s instance eggs - a zcml slug is not needed
in plone versions that ship with z3c.autoinclude (Plone>=3.3):[buildout]
...
eggs =
    ...
    wm.sampledataWhy yet another package?There are several other packages for generating test/sampledata but none of them
fitted my usecase. (Which is providing a user interface for pluggable sampledata generators
so developers/skinners can use standardized data when developing on a project)A while ago iasked what other people do on plone.usersz3c.sampledataWould do the same and much more (dependencies, groups, configuration ui for each plugin)for me it was too complex to get it running on my zope2 instance and it
seems to be tailored for zope3 anyway.Basically it would be great to make wm.sampledata use z3c.sampledata
and provide plone specific plugins for it.zopyx.ipsumploneSeems to provide very similar utility methods.
No pluggable Generators, No User-Interfaceely.contentgeneratorprovides a xml syntax to create samplecontent,
might be useful to use in custom pluginscollective.contentgeneratorlooks like this is meant for creating (random) sampledata for stresstestscollective.loremcontent action to fill content with lorem-ipsum text and providesutility methodscreateStandardContentto create random content (news, documents, files, image)
andcreateNestedStructureto create arbitrary nested folder structures.collective.loremipsumAllows to create members (names taken from fakenamegenerator.com)zettwerk.setupcontains utility methods for setuphandlers. the one in structure.py offers
a method to create content out of a list of dictionaries.TODOInclude Ipsum Ipsum text obtained via the api fromhttp://www.randomtext.me/(for other interesting/funny generators seehttp://designshack.net/articles/inspiration/30-useful-and-hilarious-lorem-ipsum-generators/)use plone.api in utility methods or replace them with plone.api where
appropriateeventually provide api to use fakenamegenerator.com for names
(collective.loremipsum already uses that)ContributeIf you have any ideas for improvement or know another alternative to this package pleaseFile a ticketordrop me a mailChangelog0.7.0 (2021-04-29)setting env variable CI=true allows to disable image download
(useful for running tests that generate sampledata)0.6.1 (2019-10-29)use pypi compatible email-address in setup.py0.6.0 (2019-10-29)use python-requests for downloading imagesbreaking: return image data as string (no StringIO buffers)utils.get_placeholder_imageallows to obtain images fromhttps://placeholder.com/[fRiSi]0.5.2 (2016-06-14)Fix the user agent switcher to be compatible with Mac/Windows.
[pcdummy]0.5.1 (2016-05-03)Add a user-agent to the image downloader.
[pcdummy]0.5 (2016-03-31)util.getFlickrImageandutils.getRandomFlickrImageallow to obtain images from loremflickr.com.
[pcdummy, fRiSi]0.4 (2016-03-08)Classes can be used to define plugin groups as well as utility names
[pcdummy]0.3 (2014-08-25)utils.doWorkflowTransition uses plone_utils internally since
portal_workflow.doActionFor does not set the effective date when publishingerrors raised in finally clause did not pop up with debug=Trueadded utility functioncreateFileto create file-content the same way
ascreateImagecreates image-content.replace _createObjectByType with invokeFactory since - despite a little better
performance - it has some nasty side-effects. eg the_at_creation_flagis
is not properly handeledadded utility functionraptus_hide_forandraptus_show_forto be able
to hide and show content items in specific raptus.article components.(seehttps://pypi.python.org/pypi/raptus.article.defaultfor more information
on raptus.article)0.2.2 (2013-05-08)add traceback logging on errors [saily]added utility functions (utils.getImageandutils.getRandomImage) to
download images from lorempixel.com (see wm.sampledata.example for usage)
[fRiSi]more intuitive syntax for blockPortlets (change breaks backward
compatibility) [fRiSi]0.2.1 (2012-05-29)fix links for running plugins so they work forhttp://host/plonesite/@@sampledata, too. (not justhttp://host/@@sampledata)
[fRiSi]added utility methodconstrainTypesto set which objects an be added to
folderish objects [fRiSi]0.2 (2011-12-02)SampledataView.runPluginreturns the result ofPlugin.generate. This
makes it easy to check if the plugin was sucessfully run in unittests.0.1 (2011-01-31)Initial release