Little bits of info about CMFFormController

One thing the documentation doesn't clearly state: you can set the status to a value and have that value defined as an action in the metadata file, basically redirecting the flow of the controller sequence to that action. To make things clear, I'll paste some code. In the login_initial.cpy.metadata file from CMFPlone we have this bit of code: [actions] action.success=traverse_to:string:login_next action.login_change_password=traverse_to:string:login_passwordSo basically we have two actions defined, depending on the type of status returned. [...]

Hacking at Plone membership's core: different content types for member folders

I'm using this technique for a site created with Plone 2.1, but it I think it can work on Plone 2.5 as well. Basically, I need a site with different membership types, and each membership type has a "personal area" (different member folder) where the user can add different object types and generally have a completely different browsing experience. I haven't implemented anything exotic such as CMFMember (not future proof) or membrane (not compatible, don't want to mess around yet) so I'm sticking with plain Plone users. [...]

Creating zope content

I had a need to create new external methods on install of a product. So, even if technique is old and well know to any Zope 2 old-timer, I'm placing this here for my own reference. def install(portal): portal.manage_addProduct['ExternalMethod'].manage_addExternalMethod( id = 'emailMe', title='emailMe', module='MyProduct.emailMe', function='emailMe')The code needs to interact with a legacy module (renamed here emailMe). The idea is that manage_addProduct returns a dictionary of factories and manage_addExternalMethod is the factory method defined in the ExternalMethod module. [...]

Get a translated object in a particular language

Sometimes there is a need to get a translated piece of content in a particular language. Some examples include messing around with ATVM or stitching together a front page for a multilanguage website from editable content (site editors love pretty interfaces where they can tweak and edit every piece of a website). This piece of code is a bit older, but still does the job well. The boundLanguages/getLanguageBindings thing could be replaced with getPreferredLanguage() and I'm pretty sure LinguaPlone got a prettier API than this, but it's a starting point in the right direction. [...]

Internationalization with Plone

To generate automatically a .pot file necessary for translating msgids inside template files you need to get i18ndude (really easy since it was placed in cheeseshop): sudo easy_install i18ndudeSince I'm using ArchGenXML, I already have a generated.pot file created. I've renamed this file to old.pot and ran this (in the i18n folder): i18ndude rebuild-pot --pot ./generated.pot --merge old.pot --create MyProduct ./../skins/MyProduct/ This command builds a pot file by looking at files in the skins folder and merging the extracted msgids with the ones in old. [...]

Dynamic vocabulary for an Archetypes field

I keep forgetting how to do dynamic vocabularies for an AT field. As explained in the Vocabulary() method in Field.py, this method will return either the list defined in the vocabulary parameter of the field, or, among others, the list resulting from calling the method defined in the string given as value to the vocabulary parameter. The code below will make the explanation easier to understand: ... LinesField( name='domains', vocabulary='getVocabularyForDomains' ) [...]

Easy install of actions with CMFQuickInstaller

Although superseded by GenericSetup, this method is still useful and quick to setup. Basically, CMFQI will install actions defined in an xml file called "actions" located in the Extension folder. This behavior is documented in the CMFQI documentation files. An example follows below: <portal_actions> name=Manage group users id=userconfig action=string:manage_project_users condition=member permission=View category=folder visible=1 </portal_actions> [...]

Start Plone (or Zope) in debug mode under Windows

Lifted from #plone: bin/runzope.bat -X "debug-mode=on" [...]

Fixing a zope database with fsrecover.py

Due to hardware corruption I have a broken Data.fs that won't pack. To fix it the fsrecover.py script from the ZODB module can be used. For example, this is how to run the script to repair the broken database (I have zope installed in /opt/Zope2.8): cd /opt/Zope2.8/lib/python/ python ZODB/fsrecover.py -v 1 /mnt/raid/Data.fs /mnt/raid/Data.fs.fixed The reason to run the fsrecover script with ZODB in front is that it imports from the ZODB module. [...]

Moving a Zope instance

To move a zope instance location 3 files need to be edited in order to update the software home location: runzopezopectletc/zope.conf (change the software home location, right at the top of the file) [...]