Posts tagged 'product'

Plone, Dexterity, and Incorrect Widgets

A nice ‘gotcha’ is the distinction between Zope’s schema.Date and schema.Datetime. The difference is obvious and straightforward when the two terms are laid out side-by-side: one is for dates only and the other adds a time component. Where things fell down for me in my usage of these fields with a Dexterity-based content type in Plone is the human component. When these fields are mashed in together within a lot of other text/Python/names, it’s easy to miss those 4 little letters of ‘time’. This lead me trying to use a DatetimeFieldWidget when I really …

Plone and Dexterity: Working with computed fields

Today, we’re looking at how to utilise computed fields within a Dexterity-based content type. The specific use-case is that of having two separate fields (first name and surname, for a Person type, for example) generate the complete object title. The first part of this — having the title of the content displayed correctly — is pretty straight forward once you know what documentation to read and understand how things happen. The second part — having the ID of the content correctly generated to be first name/surname is slightly more complicated.

Title computation and display

Let’s look at the first part …

Plone/Zope: Utilising zope.testrecorder for unit testing

Writing unit tests (especial doctests) for your Plone product is reasonably time consuming. For us developers, having tested code is absolutely essential. This is especially true when clients are beating down your door looking for a fully functional product and you need to know what you’ve written works and isn’t going to fall over (just yet, anyway). Web apps are able to be tested using a multitude of frameworks, and whilst not the most fully featured (eg lacking Javascript support), Zope’s doctest machinery is right there within your Plone product. In order to write these, enter zope …

PloneFormGen (Plone) & Google Calendar Integration

It’s a little bit of a different mash-up, but it’s still nonetheless useful to have, given types of booking forms and so forth that could utilise it.  The easiest way I found (to avoid security issues with Python scripts in Plone) was to create an external method and just import it within a PFG Custom Adapter.

Parts

  • My GoogleCalendar.py external method.  I’ve had to add this into a policy product I have.  The function should be generalised enough to work with any Google account, hosted or not.  In short:

    • It takes in a variety of arguments …

Plone: Re-ordering Viewlets

Just responded to a post on the Plone Nabble forums (here) about how to re-order viewlets.  In particular, this one is little different (but not terribly so) because the original poster wanted to put the breadcrumbs above the global sections (global tabs in Plone).  Normally, this is straight forward because you just use a Generic Setup profile (viewlets.xml) and use an order manager to move your viewlet.  This, however, is a teeny bit more complicated because you’ve got one viewlet that’s outside of another viewlet manager.

Without further ado, my post from the forums:

Check out http …

Creating & distributing a new Plone/PyPI product

It’s amazing to see how technologies can be so smoothly integrated these days.  I’m talking, at least in this instance, about how setuptools works with PyPI (and then Plone.org’s Products section) and allows you to distribute your product(s) to the world.  So far, I’ve just got the one — collective.portlet.googleapps — but I’m sure time will pass and I’ll have some more useful things to contribute. Here’s a summary of what I did:

  1. Create the product.  ZopeSkel is a wonderful help here for Plone products. [I lie a little bit in …

Plone: Relative ‘Recent Changes’ Portlets

The problem I’ve been faced with today on our Plone systems is that I need to created a ‘Recent Changes’ portlet that’s relative to where the user is on the site.

Now, the standard portlet doesn’t do anything for me, so that’s pretty useless. I had a look at the standard code for the portlet too and it’s not really feasible to try and mess with:

<tal:recentlist define="view here/@@recent_view; results here/results;">

However, using a (nasty?) workaround, if we put the classic Recent Changes portlet into play, we can change that above …