work in progress: construct base interfaces and sample base implementations
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3059 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
bef6db8f1d
commit
28b0abcf56
3 changed files with 44 additions and 25 deletions
|
@ -25,8 +25,7 @@ $Id$
|
||||||
import re
|
import re
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
|
|
||||||
from cybertools.wiki.base.link import Link
|
from cybertools.wiki.base.link import Link, LinkManager
|
||||||
from cybertools.wiki.base.manager import SampleManager
|
|
||||||
from cybertools.wiki.interfaces import IFormat, IFormatInstance
|
from cybertools.wiki.interfaces import IFormat, IFormatInstance
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,7 +72,7 @@ class BasicFormat(object):
|
||||||
|
|
||||||
def __init__(self, manager=None):
|
def __init__(self, manager=None):
|
||||||
if manager is None:
|
if manager is None:
|
||||||
manager = SampleManager()
|
manager = LinkManager()
|
||||||
self.manager = manager
|
self.manager = manager
|
||||||
|
|
||||||
def getInstance(self, context):
|
def getInstance(self, context):
|
||||||
|
|
|
@ -25,7 +25,34 @@ $Id$
|
||||||
import re
|
import re
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
|
|
||||||
from cybertools.wiki.interfaces import ILink
|
from cybertools.wiki.interfaces import ILink, ILinkManager
|
||||||
|
|
||||||
|
|
||||||
|
class LinkManager(object):
|
||||||
|
""" A very basic link manager implementation.
|
||||||
|
"""
|
||||||
|
|
||||||
|
implements(ILinkManager)
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.links = {}
|
||||||
|
|
||||||
|
def registerLink(self, link):
|
||||||
|
if link.identifier is None:
|
||||||
|
self.generateLinkIdentifier(link)
|
||||||
|
if link.identifier not in self.links:
|
||||||
|
self.links[link.identifier] = link
|
||||||
|
link.manager = self
|
||||||
|
|
||||||
|
def unregisterLink(self, link):
|
||||||
|
if link.identifier in self.links:
|
||||||
|
del self.links[link.identifier]
|
||||||
|
link.manager = None
|
||||||
|
|
||||||
|
def generateLinkIdentifier(self, link):
|
||||||
|
identifier = 'l%07i' % (max(self.links.keys() or [0]) + 1)
|
||||||
|
link.identifier = identifier
|
||||||
|
return identifier
|
||||||
|
|
||||||
|
|
||||||
class Link(object):
|
class Link(object):
|
||||||
|
|
|
@ -17,37 +17,30 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
A Wiki manager, i.e. a repository for pages and other information like
|
A Wiki manager managing wikis and wiki-related objects, esp plugins.
|
||||||
links, images, etc.
|
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
|
|
||||||
from cybertools.wiki.interfaces import IWikiManager
|
from cybertools.wiki.interfaces import IWikiManager, IWiki, IWikiPage
|
||||||
|
|
||||||
|
|
||||||
class SampleManager(object):
|
class WikiManager(object):
|
||||||
""" A very basic Wiki manager implementation.
|
|
||||||
"""
|
implements(IWikiManager)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.links = {}
|
self.wikis = {}
|
||||||
|
self.plugins = {}
|
||||||
|
|
||||||
def registerLink(self, link):
|
|
||||||
if link.identifier is None:
|
|
||||||
self.generateLinkIdentifier(link)
|
|
||||||
if link.identifier not in self.links:
|
|
||||||
self.links[link.identifier] = link
|
|
||||||
link.manager = self
|
|
||||||
|
|
||||||
def unregisterLink(self, link):
|
class Wiki(object):
|
||||||
if link.identifier in self.links:
|
|
||||||
del self.links[link.identifier]
|
|
||||||
link.manager = None
|
|
||||||
|
|
||||||
def generateLinkIdentifier(self, link):
|
implements(IWiki)
|
||||||
identifier = 'l%07i' % (max(self.links.keys() or [0]) + 1)
|
|
||||||
link.identifier = identifier
|
|
||||||
return identifier
|
class WikiPage(object):
|
||||||
|
|
||||||
|
implements(IWikiPage)
|
Loading…
Add table
Reference in a new issue