rearrange configuration stuff
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3494 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
687401d1ff
commit
8063d211a9
3 changed files with 54 additions and 22 deletions
|
@ -20,7 +20,7 @@ to make sure the btree-based tracking link manager will be used.
|
|||
>>> manager = WikiManager()
|
||||
|
||||
>>> linkManagerName = 'tracking'
|
||||
>>> manager.linkManager = linkManagerName
|
||||
>>> manager.setConfig('linkManager', linkManagerName)
|
||||
>>> wiki = manager.addWiki(Wiki('demo_wiki'))
|
||||
>>> startPage = wiki.createPage('start_page')
|
||||
|
||||
|
|
|
@ -24,7 +24,18 @@ $Id$
|
|||
|
||||
from zope.interface import implements
|
||||
|
||||
from cybertools.wiki.interfaces import IWikiConfiguration
|
||||
from cybertools.wiki.interfaces import IWikiConfigInfo, IWikiConfiguration
|
||||
|
||||
|
||||
class WikiConfigInfo(dict):
|
||||
|
||||
implements(IWikiConfigInfo)
|
||||
|
||||
def set(self, functionality, value):
|
||||
self[functionality] = value
|
||||
|
||||
def __getattr__(self, attr):
|
||||
return self.get(attr, None)
|
||||
|
||||
|
||||
class BaseConfiguration(object):
|
||||
|
@ -33,31 +44,35 @@ class BaseConfiguration(object):
|
|||
|
||||
implements(IWikiConfiguration)
|
||||
|
||||
parent = None
|
||||
|
||||
writer = parser = None
|
||||
_configInfo = None
|
||||
|
||||
def getConfig(self, functionality):
|
||||
c = self.get(functionality)
|
||||
c = None
|
||||
ci = self._configInfo
|
||||
if ci is not None:
|
||||
c = ci.get(functionality)
|
||||
if c is None:
|
||||
parent = self.getConfigParent()
|
||||
if parent is not None:
|
||||
return parent.getConfig(functionality)
|
||||
return c
|
||||
|
||||
def get(self, key, default=None):
|
||||
return getattr(self, key, None)
|
||||
def setConfig(self, functionality, value):
|
||||
if self._configInfo is None:
|
||||
self._configInfo = WikiConfigInfo()
|
||||
self._configInfo.set(functionality, value)
|
||||
|
||||
def getConfigParent(self):
|
||||
return self.parent
|
||||
return None
|
||||
|
||||
|
||||
class WikiConfiguration(BaseConfiguration):
|
||||
""" A global utility providing the default settings.
|
||||
"""
|
||||
|
||||
parser = 'docutils.rstx'
|
||||
writer = 'docutils.html'
|
||||
linkManager = 'basic'
|
||||
|
||||
nodeProcessors = dict(reference=['default'])
|
||||
_configInfo = WikiConfigInfo(
|
||||
parser='docutils.rstx',
|
||||
writer='docutils.html',
|
||||
linkManager='basic',
|
||||
nodeProcessors=dict(reference=['default']),
|
||||
)
|
||||
|
|
|
@ -25,9 +25,8 @@ $Id$
|
|||
from zope.interface import Interface, Attribute
|
||||
|
||||
|
||||
class IWikiConfiguration(Interface):
|
||||
""" Provides information about the implementations to be used for
|
||||
the various kinds of wiki plug-ins.
|
||||
class IWikiConfigInfo(Interface):
|
||||
""" A collection of configuration settings.
|
||||
"""
|
||||
|
||||
writer = Attribute('Plug-in component converting from internal tree '
|
||||
|
@ -35,16 +34,34 @@ class IWikiConfiguration(Interface):
|
|||
parser = Attribute('Plug-in component converting from text input '
|
||||
'format to internal tree format.')
|
||||
|
||||
def get(functionality):
|
||||
""" Return the setting for the functionality given or None if not set.
|
||||
"""
|
||||
|
||||
def set(functionality, value):
|
||||
""" Register the value given for the functionality given.
|
||||
"""
|
||||
|
||||
|
||||
class IWikiConfiguration(Interface):
|
||||
""" Provides information about the implementations to be used for
|
||||
the various kinds of wiki plug-ins.
|
||||
"""
|
||||
|
||||
def getConfig(functionality):
|
||||
""" Return the name of the component that should used for the
|
||||
functionality given.
|
||||
"""
|
||||
|
||||
def setConfig(functionality, value):
|
||||
""" Register the value given for the functionality given.
|
||||
"""
|
||||
|
||||
def getConfigParent():
|
||||
""" Return the parent object in case this configuration does not
|
||||
provide configuration information for a certain functionality.
|
||||
"""
|
||||
|
||||
def getConfig(functionality):
|
||||
""" Return the name of the plugin that should used for the
|
||||
functionality given.
|
||||
"""
|
||||
|
||||
|
||||
class IWikiManager(Interface):
|
||||
""" Manages wikis and wiki-related objects, like plugins.
|
||||
|
|
Loading…
Add table
Reference in a new issue