Changeset 5083 for main/waeup.sirp/trunk/src/waeup/sirp/browser
- Timestamp:
- 25 Mar 2010, 15:47:43 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py
r5005 r5083 4 4 5 5 from hurry import yui 6 from zope.component import getMultiAdapter 6 from zope.component import getMultiAdapter, queryAdapter 7 from zope.interface import Interface 7 8 from zope.location.interfaces import ISite 8 9 from waeup.sirp.browser.pages import ( … … 57 58 grok.baseclass() 58 59 grok.context(IWAeUPObject) 59 grok.template('actionbutton')60 60 grok.viewletmanager(ActionBar) 61 61 icon = 'actionicon_modify.png' # File must exist in static/ … … 63 63 text = 'Edit settings' # Text to display on the button 64 64 65 # We set the template file explicitly (instead of using 66 # ``grok.template('actionbutton')``) to stick with this template 67 # also in derived classes in other packages. If we didn't, those 68 # derived ActionButton viewlets had to provide an own template, 69 # which would not be updated automatically, when the local 70 # template ``templates/actionbutton.pt`` changes. 71 # 72 # Inheriting viewlets that wish to use their own template anyway 73 # can do so by setting their local ``grok.template(<mytemplate>)`` 74 # and setting ``template`` to ``None`` for the class:: 75 # 76 # class DerivedActionButton(ActionButton): 77 # ... 78 # grok.template('overriding_template') 79 # template = None 80 # ... 81 # 82 template = grok.PageTemplateFile('templates/actionbutton.pt') 83 65 84 @property 66 85 def alt(self): … … 73 92 """Get the icon URL. 74 93 """ 75 return self.view.static[self.icon]() 94 static = self.view.static 95 if static is None or static.get(self.icon, None) is None: 96 # In derived classes defined in other modules/packages 97 # than w.s.browser, ``static`` might refer to a static dir 98 # local to the derived class' module. As we often like to 99 # get the icons from here 100 # (i.e. waeup.sirp.browser/static), we set the directory 101 # resource appropiately. 102 # 103 # XXX: The hardcoding of 'w.s.browser' should be replaced 104 # by something smarter. 105 # 106 # TODO: notes in here should go to general documentation. 107 static = queryAdapter( 108 self.request, Interface, name='waeup.sirp.browser') 109 return static[self.icon]() 76 110 77 111 @property
Note: See TracChangeset for help on using the changeset viewer.