DevEX - reference for building teams, processes, and platforms
Generic Setup De-Mystified
1. GenericSetup
De-mystified
Clayton Parker
Plone Symposium East 2009
nowhere to go but
open source
s ix fe e tup . co m / i mm e rs e
2. Who am I?
• Lead Developer at Six Feet Up, Inc.
• claytron on IRC
s ixf eet up. c om/ i mme r se
3. What’s in store?
• The what and why of GenericSetup
• Importing and exporting
• Best practices
• portal_setup vs. portal_quickinstaller
s ixf eet up. c om/ i mme r se
4. What?
• portal_quickinstaller replacement
• CustomizationPolicy replacement
• Site configuration
• Upgrades
s ixf eet up. c om/ i mme r se
5. Why?
“Persistence means always having to
say you’re sorry” - Seaver’s Law
s ixf eet up. c om/ i mme r se
8. What’s in a profile?
<genericsetup:registerProfile
name=quot;defaultquot;
title=quot;My Packagequot;
directory=quot;profiles/defaultquot;
description=quot;My Package install profilequot;
provides=quot;Products.GenericSetup.interfaces.EXTENSIONquot;
/>
• profile-<package_name>:<profile_name>
• profile-my.package:default
• my.package:default
s ixf eet up. c om/ i mme r se
9. On the filesystem
my.package/my/package/
|
|- configure.zcml
|- exportimport/
|
|- profiles/
| |
| |- default/
| |
| |- metadata.xml
| |- my.package-default.txt
| |- <other profile files>
|
|- setuphandlers.py
|- upgrades.py
s ixf eet up. c om/ i mme r se
15. metadata.xml
<?xml version=quot;1.0quot;?>
<metadata>
<version>1.0</version>
<dependencies>
<dependency>profile-my.theme:default</dependency>
<dependency>profile-my.other.package:default</dependency>
</dependencies>
</metadata>
s ixf eet up. c om/ i mme r se
19. Tell me more
• Profile for initial site setup
• Upgrade steps
s ixf eet up. c om/ i mme r se
20. Upgrade steps
<genericsetup:upgradeStep
title=quot;Setup calendarquot;
description=quot;Modify the calendar settingsquot;
source=quot;0.9quot;
destination=quot;1.0quot;
handler=quot;.upgrades.setupCalendarquot;
sortkey=quot;10quot;
profile=quot;my.package:defaultquot;
/>
s ixf eet up. c om/ i mme r se
21. Upgrade steps
from Products.CMFCore.utils import getToolByName
def setupCalendar(context):
ctool = getToolByName(context, 'portal_calendar')
cal_types = list(ctool.calendar_types)
if 'MyEventType' not in cal_types:
cal_types.append('MyEventType')
ctool.calendar_types = cal_types
s ixf eet up. c om/ i mme r se
22. Best Practices
• Uninstall profiles
• Trim the export
• Be aware of other profiles
s ixf eet up. c om/ i mme r se
23. <property name=quot;metaTypesNotToListquot; type=quot;linesquot;>
<element value=quot;ATBooleanCriterionquot;/>
<element value=quot;ATDateCriteriaquot;/>
<element value=quot;ATDateRangeCriterionquot;/>
<element value=quot;ATListCriterionquot;/>
...
</property>
<property name=quot;metaTypesNotToListquot; type=quot;linesquot; purge=quot;Falsequot;>
<element value=quot;Imagequot;/>
<element value=quot;Filequot;/>
</property>
s ixf eet up. c om/ i mme r se
25. def install(portal):
quot;quot;quot;Run the GS profile to install this packagequot;quot;quot;
out = StringIO()
runProfile(portal, 'profile-my.package:default')
print >>out, quot;Installed my.packagequot;
return out.getvalue()
def uninstall(portal, reinstall=False):
quot;quot;quot;Run the GS profile to install this packagequot;quot;quot;
out = StringIO()
if not reinstall:
runProfile(portal, 'profile-my.package:uninstall')
print >>out, quot;Uninstalled my.packagequot;
return out.getvalue()
s ixf eet up. c om/ i mme r se
26. Make me a Zope 2 style product
<five:registerPackage package=quot;.quot; initialize=quot;.initializequot;/>
s ixf eet up. c om/ i mme r se
27. What did we learn?
• The what and why of GenericSetup
• Importing and exporting
• Best practices
• portal_setup vs. portal_quickinstaller
s ixf eet up. c om/ i mme r se
28. Links
• http://www.sixfeetup.com/swag/generic-setup-quick-reference-card
• http://plone.org/documentation/manual/generic-setup/
s ixf eet up. c om/ i mme r se
29. Learn Plone by building a website from A to Z
1 non-profit project • 10 workshops • 14 mentors • 3 days
s ixf eetup. com/im merse
Register by June 30th
and save $255!