-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move applySkin from zope.app.publisher.browser to zope.publisher.brow…
…ser.
- Loading branch information
Showing
2 changed files
with
116 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2004 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE. | ||
# | ||
############################################################################## | ||
"""Zope 3 API Documentation | ||
$Id$ | ||
""" | ||
__docformat__ = 'restructuredtext' | ||
|
||
from zope.interface import implements | ||
from zope.publisher.browser import applySkin | ||
|
||
from zope.app import zapi | ||
from zope.app.location import locate | ||
from zope.app.location.interfaces import ILocation | ||
|
||
from zope.app.apidoc.interfaces import IDocumentationModule | ||
from zope.app.apidoc.utilities import ReadContainerBase | ||
|
||
class APIDocumentation(ReadContainerBase): | ||
"""Represent the complete API Documentation. | ||
This documentation is implemented using a simply `IReadContainer`. The | ||
items of the container are all registered utilities for | ||
`IDocumentationModule`. | ||
""" | ||
implements(ILocation) | ||
|
||
def __init__(self, parent, name): | ||
self.__parent__ = parent | ||
self.__name__ = name | ||
|
||
def get(self, key, default=None): | ||
"""See zope.app.container.interfaces.IReadContainer""" | ||
utility = zapi.queryUtility(IDocumentationModule, key, default) | ||
if utility != default: | ||
locate(utility, self, key) | ||
return utility | ||
|
||
def items(self): | ||
"""See zope.app.container.interfaces.IReadContainer""" | ||
items = list(zapi.getUtilitiesFor(IDocumentationModule)) | ||
items.sort() | ||
utils = [] | ||
for key, value in items: | ||
locate(value, self, key) | ||
utils.append((key, value)) | ||
return utils | ||
|
||
|
||
class apidocNamespace(object): | ||
"""Used to traverse to an API Documentation.""" | ||
def __init__(self, ob, request=None): | ||
if request: | ||
from zope.app.apidoc.browser.skin import APIDOC | ||
applySkin(request, APIDOC) | ||
self.context = ob | ||
|
||
def traverse(self, name, ignore): | ||
return handleNamespace(self.context, name) | ||
|
||
def handleNamespace(ob, name): | ||
"""Used to traverse to an API Documentation.""" | ||
return APIDocumentation(ob, '++apidoc++'+name) |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2005 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE. | ||
# | ||
############################################################################## | ||
"""API Doc Preference Views | ||
$Id$ | ||
""" | ||
__docformat__ = "reStructuredText" | ||
|
||
from zope.publisher.browser import applySkin | ||
|
||
from zope.app import zapi | ||
from zope.app.apidoc.browser.skin import APIDOC | ||
from zope.app.tree.browser.cookie import CookieTreeView | ||
from zope.app.preference.browser import PreferenceGroupFilter | ||
from zope.app.preference.browser import EditPreferenceGroup | ||
|
||
class APIDocPreferencesTree(CookieTreeView): | ||
"""Preferences Tree using the stateful cookie tree.""" | ||
|
||
def apidocTree(self): | ||
root = zapi.getRoot(self.context)['apidoc'] | ||
filter = PreferenceGroupFilter() | ||
return self.cookieTree(root, filter) | ||
|
||
|
||
class ApidocEditPreferenceGroup(EditPreferenceGroup): | ||
|
||
def __init__(self, context, request): | ||
# Make sure we enter APIDOC territory. | ||
applySkin(request, APIDOC) | ||
super(ApidocEditPreferenceGroup, self).__init__(context, request) |