more on breadcrumbs: for resources; get view for breadcrumbs parent via new standard NodeView method
This commit is contained in:
		
							parent
							
								
									a86c8afcfa
								
							
						
					
					
						commit
						3dd1698b80
					
				
					 2 changed files with 19 additions and 8 deletions
				
			
		|  | @ -444,9 +444,7 @@ class NodeView(BaseView): | |||
|     def targetRender(self): | ||||
|         return u'<div>%s</div>' % self.targetView('download.html', 'show') | ||||
| 
 | ||||
|     @Lazy | ||||
|     def virtualTarget(self): | ||||
|         obj = self.virtualTargetObject | ||||
|     def getViewForTarget(self, obj): | ||||
|         if obj is not None: | ||||
|             basicView = component.getMultiAdapter((obj, self.request)) | ||||
|             if obj == self.targetObject: | ||||
|  | @ -456,6 +454,10 @@ class NodeView(BaseView): | |||
|             if hasattr(basicView, 'view'): | ||||
|                 return basicView.view | ||||
| 
 | ||||
|     @Lazy | ||||
|     def virtualTarget(self): | ||||
|         return self.getViewForTarget(self.virtualTargetObject) | ||||
| 
 | ||||
|     @Lazy | ||||
|     def targetId(self): | ||||
|         target = self.virtualTargetObject | ||||
|  |  | |||
|  | @ -18,8 +18,6 @@ | |||
| 
 | ||||
| """ | ||||
| View class for resource objects. | ||||
| 
 | ||||
| $Id$ | ||||
| """ | ||||
| 
 | ||||
| import urllib | ||||
|  | @ -134,9 +132,6 @@ class ResourceView(BaseView): | |||
|         else: | ||||
|             return self.template.macros['download'] | ||||
| 
 | ||||
|     #def __init__(self, context, request): | ||||
|     #    super(ResourceView, self).__init__(context, request) | ||||
| 
 | ||||
|     def setupController(self): | ||||
|         cont = self.controller | ||||
|         if cont is None: | ||||
|  | @ -157,6 +152,20 @@ class ResourceView(BaseView): | |||
|                             subMacro=version_macros.macros['portlet_versions'], | ||||
|                             priority=25, info=self) | ||||
| 
 | ||||
|     def breadcrumbs(self): | ||||
|         data = [] | ||||
|         if self.breadcrumbsParent is not None: | ||||
|             data.extend(self.breadcrumbsParent.breadcrumbs()) | ||||
|         if self.context != self.nodeView.targetObject: | ||||
|             data.append(dict(label=self.title, | ||||
|                              url=self.nodeView.getUrlForTarget(self.context))) | ||||
|         return data | ||||
| 
 | ||||
|     @Lazy | ||||
|     def breadcrumbsParent(self): | ||||
|         for c in self.context.getConcepts([self.defaultPredicate]): | ||||
|             return self.nodeView.getViewForTarget(c) | ||||
| 
 | ||||
|     @Lazy | ||||
|     def view(self): | ||||
|         context = self.context | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue