I am writing a Plone calendar module to reserve different resources. This module contains a calendar whose events are stored in Postgresql. Each calendar is a Dexterity object stored in ZODB.
To establish a connection between Plone and Postgresql, I naturally turned to the uuid property of Plone objects. Thus, each uuid in Plone acts as a foreign key in Postgresql, which supports uuid natively.
This worked well for me in the last 6 months, until I started using Plone 4.1.4. It introduced plone.uuid 1.0.2, which changes the string representation of uuids from uuids to uuids without dashes.
The problem with this change is that I can no longer be sure which representation will be used on any given object. Objects created before Plone 4.1.4 contain a formatted uuid string differently than objects created after.
In short, to make sure my code works with any uuid view, I would love to be able to search using the uuid type of Python.
So instead:
catalog.searchResults(UID='325dc47e-08f9-4fa1-bc18-3944a725adb4')
Which returns different results than this:
catalog.searchResults(UID='325dc47e08f94fa1bc183944a725adb4')
I would like to do this:
from uuid import UUID
catalog.searchResults(UID=UUID('325dc47e-08f9-4fa1-bc18-3944a725adb4'))
Which would be equivalent to this:
catalog.searchResults(UID=UUID('325dc47e08f94fa1bc183944a725adb4'))
Does anyone know how I can achieve such independence from representing uuid in Plone?
source
share