provide 'view/requestUrl' method to be used instead of 'request/URL'
This commit is contained in:
		
							parent
							
								
									8166a0e3c3
								
							
						
					
					
						commit
						8777d1ecdb
					
				
					 2 changed files with 13 additions and 2 deletions
				
			
		|  | @ -34,7 +34,7 @@ | ||||||
|     <link rel="icon" type="image/png" |     <link rel="icon" type="image/png" | ||||||
|           tal:attributes="href string:${resourceBase}favicon.png" /> |           tal:attributes="href string:${resourceBase}favicon.png" /> | ||||||
| 
 | 
 | ||||||
|     <base href="." tal:attributes="href request/URL"> |     <base href="." tal:attributes="href view/requestUrl"> | ||||||
|   </head> |   </head> | ||||||
| 
 | 
 | ||||||
|   <body class="tundra" |   <body class="tundra" | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| # | # | ||||||
| #  Copyright (c) 2011 Helmut Merz helmutm@cy55.de | #  Copyright (c) 2016 Helmut Merz helmutm@cy55.de | ||||||
| # | # | ||||||
| #  This program is free software; you can redistribute it and/or modify | #  This program is free software; you can redistribute it and/or modify | ||||||
| #  it under the terms of the GNU General Public License as published by | #  it under the terms of the GNU General Public License as published by | ||||||
|  | @ -27,6 +27,7 @@ from zope.interface import Interface, implements | ||||||
| from zope.cachedescriptors.property import Lazy | from zope.cachedescriptors.property import Lazy | ||||||
| from zope import component | from zope import component | ||||||
| from zope.event import notify | from zope.event import notify | ||||||
|  | from zope.publisher.http import URLGetter as BaseURLGetter | ||||||
| from zope.publisher.interfaces.browser import IBrowserSkinType | from zope.publisher.interfaces.browser import IBrowserSkinType | ||||||
| 
 | 
 | ||||||
| from cybertools.browser.renderer import CachableRenderer | from cybertools.browser.renderer import CachableRenderer | ||||||
|  | @ -63,6 +64,12 @@ class BodyTemplateView(object): | ||||||
|     bodyTemplate = UnboundTemplateFile('liquid/body.pt') |     bodyTemplate = UnboundTemplateFile('liquid/body.pt') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | class URLGetter(BaseURLGetter): | ||||||
|  | 
 | ||||||
|  |     def __str__(self): | ||||||
|  |         return self.__request.getURL().rstrip('/@@index.html') | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| class GenericView(object): | class GenericView(object): | ||||||
| 
 | 
 | ||||||
|     index = mainTemplate |     index = mainTemplate | ||||||
|  | @ -103,6 +110,10 @@ class GenericView(object): | ||||||
|         # this is useful for a top-level page only |         # this is useful for a top-level page only | ||||||
|         return self.index(*args, **kw) |         return self.index(*args, **kw) | ||||||
| 
 | 
 | ||||||
|  |     @property | ||||||
|  |     def requestUrl(self): | ||||||
|  |         return URLGetter(self.request) | ||||||
|  | 
 | ||||||
|     @Lazy |     @Lazy | ||||||
|     def isAuthenticated(self): |     def isAuthenticated(self): | ||||||
|         return not IUnauthenticatedPrincipal.providedBy(self.request.principal) |         return not IUnauthenticatedPrincipal.providedBy(self.request.principal) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue