Changeset 357
- Timestamp:
- 06/30/06 12:08:49
- Files:
-
- geolocation/trunk/adapter.py (modified) (3 diffs)
- geolocation/trunk/browser/edit_location.pt (modified) (4 diffs)
- geolocation/trunk/browser/location.py (modified) (1 diff)
- geolocation/trunk/configure.zcml (modified) (4 diffs)
- geolocation/trunk/interface.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
geolocation/trunk/adapter.py
r356 r357 1 1 from zope.interface import implements 2 from interface import IGEOLocat ion2 from interface import IGEOLocated 3 3 from zope.app.annotation.interfaces import IAnnotations, IAnnotatable 4 4 from Products.CMFPlone.CatalogTool import registerIndexableAttribute 5 5 6 class GEOLocat ion(object):6 class GEOLocated(object): 7 7 """ geolocation 8 8 """ 9 implements(IGEOLocat ion)9 implements(IGEOLocated) 10 10 11 11 def __init__(self, context): … … 34 34 self.annotations['latitude'] = value 35 35 36 #def updateLocation(self, longitude, latitude): 37 # """ """ 38 36 def setLocation(self, longitude, latitude): 37 """ set location """ 38 self.annotations['longitude'] = value 39 self.annotations['latitude'] = value 40 39 41 default = None 42 43 def geoLocation(obj, portal, **kw): 44 """ long idx """ 45 adapter = IGEOLocated(obj, None) 46 if adapter: 47 return (adapter.getLongitude(), adapter.getLatitude()) 48 return default 40 49 41 50 def Longitude(obj, portal, **kw): 42 51 """ long idx """ 43 adapter = IGEOLocat ion(obj, None)52 adapter = IGEOLocated(obj, None) 44 53 if adapter: 45 54 return adapter.getLongitude() … … 48 57 def Latitude(obj, portal, **kw): 49 58 """ lat idx """ 50 adapter = IGEOLocat ion(obj, None)59 adapter = IGEOLocated(obj, None) 51 60 if adapter: 52 61 return adapter.getLatitude() geolocation/trunk/browser/edit_location.pt
r356 r357 11 11 12 12 <div tal:define="location context/@@LocationView"> 13 13 <tal:x condition="location/location"> 14 14 <h1 class="documentFirstHeading" 15 15 i18n:translate="heading_location">Location</h1> 16 17 16 <form action="#" method="post" 18 17 tal:attributes="action context/absolute_url"> … … 26 25 </label> 27 26 <input type="text" name="longitude" 28 tal:attributes="value location/ getLongitude" />27 tal:attributes="value location/longitude" /> 29 28 </div> 30 29 <div class="field"> … … 33 32 </label> 34 33 <input type="text" name="latitude" 35 tal:attributes="value location/ getLatitude" />34 tal:attributes="value location/latitude" /> 36 35 </div> 37 36 … … 43 42 </fieldset> 44 43 </form> 45 46 44 </tal:x> 45 <tal:x condition="not:location/location"> 46 The object can't be adapted to IGEOLocated 47 </tal:x> 47 48 </div> 48 49 </div> geolocation/trunk/browser/location.py
r356 r357 6 6 7 7 # Product imports 8 from Products.geolocation.interface import IGEOLocat ion, ILocationView8 from Products.geolocation.interface import IGEOLocated, IGEOLocatedView 9 9 from zLOG import LOG 10 10 import sys, traceback 11 11 from StringIO import StringIO 12 12 13 class LocationView(BrowserView):13 class GEOLocatedView(BrowserView): 14 14 15 implements(ILocationView) 16 17 ## def __init__(self, context, request): 18 ## """ adapt the context """ 19 ## if IGEOLocation.providedBy(self): 20 ## return self 21 ## else: 22 ## location = IGEOLocation(self.context).__of__(self.context) 23 ## return super(LocationView, location).__init__(context, request) 24 15 implements(IGEOLocatedView) 16 25 17 def __init__(self, context, request): 18 """ init view """ 26 19 self.context = context 27 20 self.request = request 28 self.location = IGEOLocat ion(self.context)29 self.longitude = self.location .getLongitude()30 self.latitude = self.location .getLatitude()21 self.location = IGEOLocated(self.context, None) 22 self.longitude = self.location and self.location.getLongitude() or 0 23 self.latitude = self.location and self.location.getLatitude() or 0 31 24 32 def getLongitude(self):33 """ return longtitude """34 return self.longitude35 36 def getLatitude(self):37 """ return latitude """38 return self.latitude39 40 25 def editLocation(self,longitude=None, latitude=None): 41 26 """ update location properties """ 42 self.location.setLongitude(longitude) 43 self.location.setLatitude(latitude) 27 self.location.setLocation(longitude, latitude) 44 28 self.context.reindexObject() 45 29 geolocation/trunk/configure.zcml
r356 r357 1 <configure 1 <configureŗ 2 2 xmlns="http://namespaces.zope.org/zope" 3 3 xmlns:browser="http://namespaces.zope.org/browser" … … 12 12 <adapter 13 13 for="Products.ATContentTypes.interface.document.IATDocument" 14 provides=".interface.IGEOLocat ion"15 factory=".adapter.GEOLocat ion"14 provides=".interface.IGEOLocated" 15 factory=".adapter.GEOLocated" 16 16 /> 17 17 … … 19 19 for="*" 20 20 name="LocationView" 21 class=".browser.location. LocationView"21 class=".browser.location.GEOLocatedView" 22 22 permission="zope2.View" 23 allowed_interface=".interface.I LocationView"23 allowed_interface=".interface.IGEOLocatedView" 24 24 /> 25 25 … … 34 34 for="*" 35 35 name="editLocation" 36 class=".browser.location. LocationView"36 class=".browser.location.GEOLocatedView" 37 37 attribute="editLocation" 38 38 permission="zope2.View" geolocation/trunk/interface.py
r356 r357 3 3 from zope.schema import Float 4 4 5 class IGEOLocat ion(Interface):5 class IGEOLocated(Interface): 6 6 """GEO location cordinates 7 7 """ … … 30 30 """ set latitutde """ 31 31 32 class ILocationView(Interface): 32 def setLocation(longitude, latitude): 33 """ set location """ 34 35 class IGEOLocatedView(Interface): 33 36 """browser view 34 37 """ 35 38 36 def editLocation(self, request):39 def editLocation(self, longitude, latitude): 37 40 """ update location properties """
