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