Friday 28 September 2007

A confession from the boss

We have a system where jobs have a status (active, inactive etc), which is stored in a field. There is also a list for each status containing the IDs of all the jobs matching that status.

When the status of a job is changed, a form-handling script updates the status of that job, and modifies the status lists. IF Andy writes code that does approximately the following things in roughly the following order:

* first check the status field of every job and update the status lists accordingly
* then write the new status of this job into the status field

which ahem, kind of doesn't work. Forget 'kind of', it's just flawed code and flawed thinking that causes other people problems in getting their work done, their timesheets entered, their tea made.

SO now the form handler does this instead:

* first write the status of this job into the status field
* then check the status field of every job and update the status lists accordingly

This is an example where, by trying to write a script that would be more robust (check all kubes and update everything JUST IN CASE), we end up with more errrrors than if I'd just followed the apparently sketchier route of appending the job to one status list and removing it from another. Hey ho.

Miami, er, Bristol Vice

We've been working on the new Vice syndication project, integrating it into our new Viral Content Manager system. Although the system is still pre-alpha it is very impressive! The basic structure of our content types is:

ContentItems are contained in a folderish portal tool, and contain a reference to 0..* ContentChannels which can be anywhere.

We now have working RSS and ATOM feeds for the ContentItems associated with a given ContentChannel, looking like this:

from zope.interface import implements
from zope.component import adapts, queryMultiAdapter, getMultiAdapter
from zope.interface import Interface
from Products.VCNArchetypes.interfaces import IChannel, IViral
from plone.syndication.outbound.interfaces import IFeed, IFeedItem
import logging


from plone.app.syndication.outbound.adapters.atct import ATFeedBase, ATFeedItemBase

class ContentFeed(ATFeedBase):
"""Adapter from IChannel to IFeed.
>>> from zope.interface.verify import verifyClass
>>> verifyClass(IFeed, ContentFeed)
True
"""

implements(IFeed)
adapts(IChannel, str)

def __iter__(self):
items = self.context.getContentItems()
while 1:
yield queryMultiAdapter((items.next(), self), IFeedItem)


class ViralFeedItem(ATFeedItemBase):
"""Adapter from IViral to IFeedItem.
Make sure that ViralFeedItem implements the IFeedItem
interface
>>> from zope.interface.verify import verifyClass
>>> verifyClass(IFeedItem, ViralFeedItem)
True
"""
implements(IFeedItem)
adapts(IViral, IFeed)

@property
def url(self):
return self.context.getViral_url()

@property
def body(self):
return self.context.getViral_description()


and called in with:

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

<class class="Products.VCNArchetypes.ContentChannel.ContentChannel">
<implements interface="plone.syndication.outbound.interfaces.IFeedable" />
</class>

<!-- Adapt IChannel to IFeed -->
<adapter
factory=".contentfeed.ContentFeed"
trusted="true" />
<class class=".contentfeed.ContentFeed">
<require
permission="plone.syndication.ViewFeeds"
interface="plone.syndication.outbound.interfaces.IFeed" />
</class>


<!-- Adapt IViral to IFeedItem -->
<adapter
factory=".contentfeed.ViralFeedItem"
trusted="true" />
<class class=".contentfeed.ViralFeedItem">
<require
permission="plone.syndication.ViewFeeds"
interface="plone.syndication.outbound.interfaces.IFeedItem" />
</class>

</configure>


One of the sprint tasks is creating an easy to follow, doctested, readme. Until that comes out hopefully this will help people use this brilliant addition to Plone!

Thanks derek_richardson, pbugni and everyone else who's contributed!

Rubber Jelly Mice (wobble wobble)

Whilst opening a new mouse, i was delighted to find it came with a free Jelly mould. After following the instructions on the back of the mouse packet, i was informed this "wireless jelly mouse has extra sensitive tracking, egonomic personal soft moulding technology and gives the user instant office cred."

So far, the Rubber Jelly Mouse has been refrained from actual use and has been on an office tour. Posing as a modern art installation, it has visited Developer Island, The Kirk Hullis Sales Room and Project Manager Island.

From Monday the 1st of October, the mouse will be put into its industrial placement - gliding across the desk of its Father (me).

Friday 21 September 2007

Optimisation, from the Viral contentnetwork blog

Hi all, with the new developer blog up I decided to make sure any python coders had seen my post from the Viral Content Network Developer Blog on Optimisation in python, you probably know it already, but if you can think of any other advice, drop them in the comments.


Tim

"'Bout time we did a developer blog" said Andy ...

"'bout time we did a developer blog" said Andy ...

So here it is . Whoo hoo !














Now what?