Scratching my own documentation itch

March 21, 2009

A week ago, I finished updating the Archetypes Developer Manual for Plone 3. In case you have not seen it, the new version is interesting for any developer who has to develop or update an Archetypes-based product ; it tries to present our current coding practices (GenericSetup, ZCA techniques…) The manual is accompanied by a new example package. It is also useful, directly, for the “what does what/how to” when using the ZopeSkel “archetype” template with paster to bootstrap your product package.

What’s next ?

I started another manual to give an overview of the Zope Component Architecture techniques and tools we use for Plone development. Part of the initial work is refactoring/merging existing howtos and tutorials written by the other documentation contributors, and updating them. Hopefully, a first cut of this manual will be reviewed and published in a few weeks.

Sprinting at Pycon

Next week, I am going to Pycon in Chicago and will have 2 days to participate to the post-conference sprints. My current plan is to just dedicate my time to documentation. Topics that I may start contributing on are “Dexterity content types” and “WSGI setup for Plone (3/4) + using middlewares to augment your deployment”. There may be other topics to give priority to, and I will discuss with others to find out. And of course, I will have some time to make progress on the ZCA manual.

Looking forward to meet other “Python Web” community members there!


Updating your form code to latest version of plone.z3cform

July 26, 2008

I am glad to see more work is happening for using z3c.form in CMF and Plone, and Daniel Nouri updated us this week with the latest changes. I just updated my buildout to use the new packages and got plone.z3cform 0.4 and plone.app.z3cform 0.3.2.

With the small API changes that happened, you can see below that there is less to write to expose the form in the Plone site (our ContactForm example from my
previous post):

# my.example/my/example/browser.py import datetime from zope import schema import zope.component import z3c.form import plone.app.z3cform from plone.app.z3cform import layout from plone.i18n.normalizer.interfaces import IIDNormalizer from my.example import interfaces from my.example.contact import MyContact class ContactForm(z3c.form.form.Form): """ Contact Form """ fields = z3c.form.field.Fields(interfaces.IContactData) message_field = z3c.form.field.Fields(schema.TextLine(__name__ = 'message', title=u"Message", required=False) ) fields += message_field ignoreContext = True @z3c.form.button.buttonAndHandler(u'Send', name='send') def handle_send(self, action): data, errors = self.extractData() if errors: self.status = z3c.form.form.EditForm.formErrorsMessage return # Add the contact data, if not in yet id = data['firstname'] + data['lastname'] id = zope.component.queryUtility(IIDNormalizer).normalize(id) if id not in self.context.objectIds(): self._name = id contact = MyContact(self._name, **data) self.context[self._name] = contact # Complete the code so it sends the message to the site admin... message = data['message'] print "Message from %s %s (%s):\n%s" % (data['firstname'], data['lastname'], data['email'], data['message']) self.request.RESPONSE.redirect(self.context.absolute_url()) # New way to provide the wrapping View ContactFormView = layout.wrap_form(ContactForm, label="Contact Form")

The related ZCML code does not change.
By the way, on my TODO list, is moving from ZCML to grokcore.component registration 😉


Updating an old AT-based product for Plone 3 – Step 1: Using GenericSetup

March 3, 2008

I am spending some time to update the Archetypes Developer Manual on plone.org/documentation, so I can move forward in contributing on other stuff in the Doc Team tasks list.

If you are also in the situation of updating some old AT-based product for Plone 3, this might be useful to you.

The current version of our manual, in the part discussing a sample AT product called InstantMessage, is missing:

  • GenericSetup profile for setting types and subskins. This has been missing for a long time, so I decided to update it immediately.
  • ZCML-based registration for things such as FS Directory Views or class permissions and factory, which the current version of CMF permits.

I started updating the “InstantMessage” package’s code in this branch.

What was needed: Mainly replacing the old ‘Extensions/Install.py’ code by the needed GenericSetup profile XML files:

  • for content types:
  • profiles/default/types.xml
  • profiles/default/types/InstantMessage.xml
  • profiles/default/factorytool.xml
  • for the sub-skin: profiles/default/skins.xml

Then, you need a piece of code for loading the GenericSetup profile. You do that, nowadays, by adding a configure.zcml file at the root of the package with the following code:

<configure xmlns="http://namespaces.zope.org/zope"

       xmlns:genericsetup="http://namespaces.zope.org/genericsetup"

       i18n_domain="instantmessage" >

<genericsetup:registerProfile

       name="InstantMessage"

       title="InstantMessage"

       directory="profiles/default"

       description="Extension profile for InstantMessage sample AT content type."

       provides="Products.GenericSetup.interfaces.EXTENSION"

      />

</configure>

I think I can now update the manual to reflect the new setup code – pointing to a couple of GS-related tutorials that already exist on plone.org, and merge the updated branch of the code with the trunk so people can get this new version.

Next step: Introduce other ZCML-based registrations in the CMF/AT context. This update could wait for the “versions” feature support on plone.org so we add these details without loosing the text related to the old way of doing.