[BlueBream] Attribute Annotation
justin.ryan at reliefgarden.org
Fri Jun 18 22:23:12 EDT 2010
I think I did follow the directions, without an adapter registered in
zcml I got an adaptation failure.
Once it's adapted, it doesn't persist is my problemski.
On Thu, Jun 17, 2010 at 6:57 PM, Ilshad Khabibullin
<astoon.net at gmail.com> wrote:
> Hi Justin,
> That's crafty hook with "factories" to build annnotation, yes :)
> It seems you missed Persistent inheritance for that adapter factory, i.e.::
> class GeoCodedLocation(Persistent):
> def __init__(self, context):
> self.longitude = 0.0
> self.latitude = 0.0
> 2010/6/18 Justin Ryan <justin.ryan at reliefgarden.org>
>> FWIW, when I put the lat/long schema fields onto IGeoLocation, and
>> changed all adaptions from IGeoCodedLocation to IGeoLocation, which of
>> course the object already implemented, everything worked.
>> There are some details in here where, I set the form up with two
>> schemas, but the IGeoLocation adaption was just the original object.
>> If what I'm doing is crazy, I'd appreciate any input, and be happy to
>> help impart that wisdom into the BB docs.
>> On Thu, Jun 17, 2010 at 6:05 PM, Justin Ryan
>> <justin.ryan at reliefgarden.org> wrote:
>> > Howdy!
>> > I'm trying to use an Attribute Annotation Adapter to store Geo
>> > Location info on some content types. Roughly, I've been following the
>> > doctest at:
>> > http://pypi.python.org/pypi/zope.annotation
>> > I am happy to provide example code, what I have is a bit frazzled at
>> > the moment because I upgraded my mac to snow leopard the other day and
>> > apparently failed to commit the last set of changes to my project.
>> > Whups.
>> > Basically, here's the thing.
>> > I have a couple interfaces:
>> > class IGeoLocation(Interface):
>> > address = TextLine(title=u"Address")
>> > class IGeoCodedLocation(Interface)
>> > latitude = Float(title=u"Latitude")
>> > longitude = Float(title=u"Longitude")
>> > I have an annotation adapter, as best I could manage:
>> > class GeoCodedLocation(object):
>> > implements(IGeoCodedLocation)
>> > adapts(IGeoLocation)
>> > def __init__(self, context):
>> > self.longitude = 0.0
>> > self.latitude = 0.0
>> > I have an event subscriber for (IObjectModified, IGeoLocation) which
>> > is able to successfully adapt my original content type implement
>> > IGeoLocation to an IGeoCodedLocation, hit the Google Geocoding API,
>> > and log the geocoded lat and long. I am able to log the lat and log
>> > values from the adapted IGeoCodedLocation object.
>> > But, it doesn't persist. The next view of the object shows 0.0, 0.0.
>> > I have a report of someone who had a similar problem with grok. Is
>> > this an underutilized feature that has a problem, or am I a completely
>> > delusional idiot?
>> > :)
>> > Of course, I wish to contribute to the BlueBream docs info on this
>> > because Attribute Annotation Adapters are a super freaking handy
>> > pattern which are far more lightweight than containment for ancillary
>> > functionality like commenting, rating, geolocation, etc..
>> > Best,
>> > Justin
>> bluebream mailing list
>> bluebream at zope.org
> Ilshad R. Khabibullin
> +7 922 600 56 06
More information about the bluebream