Changeset 2193 in products


Ignore:
Timestamp:
Apr 21, 2010 8:02:33 PM (14 years ago)
Author:
mylan
Message:

implemented portlet for get data from object, identified by physical_path

Location:
quintagroup.portlet.map/trunk/quintagroup/portlet/map
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.portlet.map/trunk/quintagroup/portlet/map/configure.zcml

    r2188 r2193  
    22    xmlns="http://namespaces.zope.org/zope" 
    33    xmlns:five="http://namespaces.zope.org/five" 
     4    xmlns:browser="http://namespaces.zope.org/browser" 
    45    xmlns:genericsetup="http://namespaces.zope.org/genericsetup" 
    56    xmlns:plone="http://namespaces.plone.org/plone" 
     
    3435         /> 
    3536 
     37    <!-- overrides IMapEnabledView --> 
     38    <browser:page 
     39        for="Products.ATContentTypes.interface.IATTopic" 
     40        name="maps_googlemaps_enabled_view" 
     41        class=".map_fix.FolderMapView" 
     42        permission="zope.Public" 
     43        layer=".interfaces.IQGMapPortletLayer" 
     44        allowed_interface="Products.Maps.interfaces.map.IMapEnabledView" 
     45        /> 
     46 
     47    <browser:page 
     48        for="Products.ATContentTypes.interface.IATFolder" 
     49        name="maps_googlemaps_enabled_view" 
     50        class=".map_fix.FolderMapView" 
     51        permission="zope.Public" 
     52        layer=".interfaces.IQGMapPortletLayer" 
     53        allowed_interface="Products.Maps.interfaces.map.IMapEnabledView" 
     54        /> 
     55 
     56 
    3657</configure> 
  • quintagroup.portlet.map/trunk/quintagroup/portlet/map/qgmapportlet.pt

    r2188 r2193  
    11<metal:block use-macro="here/global_defines/macros/defines" /> 
    2 <tal:portlet 
    3     define="view context/@@maps_googlemaps_view; 
    4             enabled context/@@maps_googlemaps_enabled_view/enabled" 
    5     condition="python:isViewTemplate and enabled and [m for m in view.getMarkers()]" 
    6     on-error="nothing"> 
     2<tal:portlet> 
    73 
    8   <dl class="portlet portletMapsPortlet"> 
     4  <dl class="portlet portletMapsPortlet" 
     5      tal:define="view view/gmapview;"> 
    96 
    107      <dt class="portletHeader"> 
     
    3128          <span> 
    3229            <a href="#" 
    33                tal:attributes="href string:${here/absolute_url}/maps_map" 
     30               tal:attributes="href string:${view/collection/absolute_url}/maps_map" 
    3431               i18n:domain="quintagroup.portlet.map" i18n:translate="label_full_map">Full Map</a></span> 
    3532          <span class="portletBottomRight"></span> 
  • quintagroup.portlet.map/trunk/quintagroup/portlet/map/qgmapportlet.py

    r2188 r2193  
    11from zope.interface import implements 
     2from zope.component import queryMultiAdapter, getMultiAdapter 
    23 
     4from plone.memoize import ram 
     5from plone.memoize.instance import memoize 
     6from plone.memoize.compress import xhtml_compress 
     7 
     8from plone.app.portlets.portlets import base 
     9from plone.app.portlets.cache import render_cachekey 
    310from plone.portlets.interfaces import IPortletDataProvider 
    4 from plone.app.portlets.portlets import base 
    511 
    612from zope import schema 
    713from zope.formlib import form 
     14 
     15from Acquisition import aq_inner 
    816from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile 
    917 
    1018from quintagroup.portlet.map import QGMapPortletMessageFactory as _ 
    1119 
     20from logging import getLogger 
     21logger = getLogger("Plone") 
    1222 
    1323class IQGMapPortlet(IPortletDataProvider): 
     
    2434    # below. 
    2535 
    26     # some_field = schema.TextLine(title=_(u"Some field"), 
    27     #                              description=_(u"A field to use"), 
    28     #                              required=True) 
     36    collection_path = schema.TextLine(title=_(u"Path to collection"), 
     37        description=_(u"A plone physical path to collection of locations"), 
     38        required=True) 
    2939 
    3040 
     
    4050    # TODO: Set default values for the configurable parameters here 
    4151 
    42     # some_field = u"" 
    43  
    44     # TODO: Add keyword parameters for configurable parameters here 
    45     # def __init__(self, some_field=u""): 
    46     #    self.some_field = some_field 
    47  
    48     def __init__(self): 
    49         pass 
     52    def __init__(self, collection_path=""): 
     53       self.collection_path = str(collection_path) 
    5054 
    5155    @property 
     
    6569    """ 
    6670 
    67     render = ViewPageTemplateFile('qgmapportlet.pt') 
     71    _template = ViewPageTemplateFile('qgmapportlet.pt') 
     72 
     73    def __init__(self, *args): 
     74        base.Renderer.__init__(self, *args) 
     75        context = aq_inner(self.context) 
     76        portal_state = getMultiAdapter((context, self.request), name=u'plone_portal_state') 
     77        self.portal = portal_state.portal() 
     78        self.gmapview = queryMultiAdapter((self.collection, self.request), 
     79                                          name='maps_googlemaps_enabled_view') 
     80        #self._data = self.collection 
     81 
     82    #@ram.cache(render_cachekey) 
     83    def render(self): 
     84        return xhtml_compress(self._template()) 
     85 
     86    @property 
     87    def available(self): 
     88        return bool(self.gmapview and \ 
     89                    self.gmapview.enabled and \ 
     90                    self.gmapview.getMarkers()) 
     91 
     92    @property 
     93    def collection(self): 
     94        try: 
     95            return self.portal.restrictedTraverse(self.data.collection_path) 
     96        except: 
     97            return None 
    6898 
    6999 
    70100class AddForm(base.AddForm): 
    71     """Portlet add form. 
    72  
    73     This is registered in configure.zcml. The form_fields variable tells 
    74     zope.formlib which fields to display. The create() method actually 
    75     constructs the assignment that is being added. 
    76     """ 
    77101    form_fields = form.Fields(IQGMapPortlet) 
     102    label = _(u"Add Quintagroup Map Portlet") 
     103    description = _(u"This portlet displays Locations from the collection on the Google Map.") 
    78104 
    79105    def create(self, data): 
    80         return Assignment(**data) 
    81  
    82  
    83 # NOTE: If this portlet does not have any configurable parameters, you 
    84 # can use the next AddForm implementation instead of the previous. 
    85  
    86 # class AddForm(base.NullAddForm): 
    87 #     """Portlet add form. 
    88 #     """ 
    89 #     def create(self): 
    90 #         return Assignment() 
    91  
    92  
    93 # NOTE: If this portlet does not have any configurable parameters, you 
    94 # can remove the EditForm class definition and delete the editview 
    95 # attribute from the <plone:portlet /> registration in configure.zcml 
    96  
     106        portal_state = getMultiAdapter((self.context, self.request), 
     107                                       name=u'plone_portal_state') 
     108        default_path = '/'.join(portal_state.portal().getPhysicalPath()) + '/events' 
     109        return Assignment(collection_path=data.get('collection_path', default_path)) 
    97110 
    98111class EditForm(base.EditForm): 
    99     """Portlet edit form. 
    100  
    101     This is registered with configure.zcml. The form_fields variable tells 
    102     zope.formlib which fields to display. 
    103     """ 
    104112    form_fields = form.Fields(IQGMapPortlet) 
     113    label = _(u"Edit Quintagroup Map Portlet") 
     114    description = _(u"This portlet displays Locations from the collection on the Google Map.") 
Note: See TracChangeset for help on using the changeset viewer.