-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use a utility in the view to (artificially) create a place where we d…
…on't have direct access to the request
- Loading branch information
Showing
4 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
from zope.publisher.browser import BrowserPage | ||
from zope.interface import Interface | ||
from zope.component import queryUtility | ||
|
||
|
||
class IFoo(Interface): | ||
""" interface for a foo-ish utility """ | ||
|
||
def foo(): | ||
""" return some foo """ | ||
|
||
|
||
class FooView(BrowserPage): | ||
""" a browser view """ | ||
|
||
def __call__(self, *args, **kw): | ||
return 'sif!' | ||
foo = queryUtility(IFoo, default=None) | ||
if foo is not None: | ||
return foo.foo() | ||
else: | ||
return 'sif!' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters