work in progress: Python3 fixes

This commit is contained in:
Helmut Merz 2024-09-24 11:13:49 +02:00
parent 7b3c7c182e
commit 98bd9b0a46
12 changed files with 111 additions and 267 deletions

View file

@ -1,30 +1,13 @@
# # loops.base
# Copyright (c) 2019 Helmut Merz helmutm@cy55.de
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Implementation of loops root object.
Implementation of loops root object.
""" """
from zope.app.container.btree import BTreeContainer from zope.container.btree import BTreeContainer
from zope.app.folder.folder import Folder from zope.site.folder import Folder
from zope.app.folder.interfaces import IFolder from zope.site.interfaces import IFolder
from zope.traversing.api import getPath, traverse from zope.traversing.api import getPath, traverse
from zope.interface import implements from zope.interface import implementer
from cybertools.util.jeep import Jeep from cybertools.util.jeep import Jeep
from loops.interfaces import ILoops from loops.interfaces import ILoops
@ -32,17 +15,8 @@ from loops.interfaces import ILoops
loopsPrefix = '.loops' loopsPrefix = '.loops'
@implementer(ILoops)
class Loops(Folder): class Loops(Folder):
#class Loops(BTreeContainer):
implements(ILoops)
#def getSiteManager(self):
# return self.__parent__.getSiteManager()
#@property
#def _SampleContainer__data(self):
# return self.data
_skinName = '' _skinName = ''
def getSkinName(self): return self._skinName def getSkinName(self): return self._skinName
@ -72,10 +46,7 @@ class Loops(Folder):
return self.get('records') return self.get('records')
def getLoopsUri(self, obj): def getLoopsUri(self, obj):
#return str(loopsPrefix + getPath(obj)[len(getPath(self)):])
uri = loopsPrefix + getPath(obj)[len(getPath(self)):] uri = loopsPrefix + getPath(obj)[len(getPath(self)):]
#if isinstance(uri, unicode):
# uri = uri.encode('UTF-8')
return uri return uri
def loopsTraverse(self, uri): def loopsTraverse(self, uri):

View file

@ -1,29 +1,12 @@
# # loops.browser.util
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Utilities.
Utilities.
""" """
import re, urllib import re, urllib
from zope.app.pagetemplate import ViewPageTemplateFile from zope.browserpage import ViewPageTemplateFile
from zope.app.publisher.browser.menu import BrowserMenu from zope.browsermenu.menu import BrowserMenu
from zope.app.publisher.interfaces.browser import IBrowserSubMenuItem from zope.browsermenu.interfaces import IBrowserSubMenuItem
from zope import component from zope import component
from zope.formlib.namedtemplate import NamedTemplateImplementation from zope.formlib.namedtemplate import NamedTemplateImplementation

View file

@ -1,23 +1,6 @@
# # loops.common
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Common stuff.
Common stuff.
""" """
from zope import component from zope import component
@ -27,7 +10,7 @@ from zope.component import adapts
from zope.dublincore.interfaces import IZopeDublinCore from zope.dublincore.interfaces import IZopeDublinCore
from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter
from zope.dublincore.zopedublincore import ScalarProperty from zope.dublincore.zopedublincore import ScalarProperty
from zope.interface import implements from zope.interface import implementer
from zope.interface.interface import InterfaceClass from zope.interface.interface import InterfaceClass
from zope.security.proxy import isinstance from zope.security.proxy import isinstance
from zope.traversing.api import getName from zope.traversing.api import getName
@ -71,7 +54,7 @@ def baseObject(obj):
def collectAttributeNames(lst, name): def collectAttributeNames(lst, name):
attrs = [] attrs = []
for arg in lst: for arg in lst:
if isinstance(arg, basestring): if isinstance(arg, str):
attrs.append(arg) attrs.append(arg)
elif isinstance(arg, type): elif isinstance(arg, type):
attrs.extend(list(getattr(arg, name))) attrs.extend(list(getattr(arg, name)))
@ -182,9 +165,9 @@ class AdapterBase(object):
return self.title return self.title
@implementer(IStorageInfo)
class ResourceAdapterBase(AdapterBase): class ResourceAdapterBase(AdapterBase):
implements(IStorageInfo)
adapts(IResource) adapts(IResource)
_adapterAttributes = adapterAttributes('storageName', 'storageParams', AdapterBase) _adapterAttributes = adapterAttributes('storageName', 'storageParams', AdapterBase)
@ -200,9 +183,9 @@ class ResourceAdapterBase(AdapterBase):
# other adapters # other adapters
@implementer(IZopeDublinCore)
class LoopsDCAdapter(ZDCAnnotatableAdapter): class LoopsDCAdapter(ZDCAnnotatableAdapter):
implements(IZopeDublinCore)
adapts(ILoopsObject) adapts(ILoopsObject)
languageInfo = None languageInfo = None
@ -541,11 +524,11 @@ class ParentRelation(object):
# records/tracks # records/tracks
@implementer(ITracks)
class Tracks(object): class Tracks(object):
""" A tracking storage adapter managing tracks/records. """ A tracking storage adapter managing tracks/records.
""" """
implements(ITracks)
adapts(ITrackingStorage) adapts(ITrackingStorage)
def __init__(self, context): def __init__(self, context):

View file

@ -1,35 +1,18 @@
# # loops.concept
# Copyright (c) 2016 Helmut Merz helmutm@cy55.de
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Definition of the Concept and related classes.
Definition of the Concept and related classes.
""" """
from zope import component, schema from zope import component, schema
from zope.app.container.btree import BTreeContainer from zope.authentication.interfaces import IAuthentication, PrincipalLookupError
from zope.app.container.contained import Contained from zope.browser.interfaces import IAdding
from zope.app.container.interfaces import IAdding
from zope.app.security.interfaces import IAuthentication, PrincipalLookupError
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.component import adapts from zope.component import adapts
from zope.container.btree import BTreeContainer
from zope.container.contained import Contained
from zope.dublincore.interfaces import IZopeDublinCore from zope.dublincore.interfaces import IZopeDublinCore
from zope.event import notify from zope.event import notify
from zope.interface import implements from zope.interface import implementer
from zope.interface import alsoProvides, directlyProvides, directlyProvidedBy from zope.interface import alsoProvides, directlyProvides, directlyProvidedBy
from zope.interface.interfaces import ObjectEvent from zope.interface.interfaces import ObjectEvent
from zope.publisher.interfaces.browser import IBrowserRequest from zope.publisher.interfaces.browser import IBrowserRequest
@ -93,28 +76,25 @@ class BaseRelation(DyadicRelation):
# So we patched zope.location.location, line 109... # So we patched zope.location.location, line 109...
@implementer(IConceptRelation)
class ConceptRelation(BaseRelation): class ConceptRelation(BaseRelation):
""" A relation between concept objects. """ A relation between concept objects.
""" """
implements(IConceptRelation)
fallback = 'c*' fallback = 'c*'
@implementer(IConceptRelation)
class ResourceRelation(BaseRelation): class ResourceRelation(BaseRelation):
""" A relation between a concept and a resource object. """ A relation between a concept and a resource object.
""" """
implements(IConceptRelation)
fallback = 'r*' fallback = 'r*'
# concept # concept
@implementer(IConcept, IConceptManagerContained, IRelatable)
class Concept(Contained, Persistent): class Concept(Contained, Persistent):
implements(IConcept, IConceptManagerContained, IRelatable)
proxyInterface = IConceptView proxyInterface = IConceptView
workspaceInformation = None workspaceInformation = None
@ -362,10 +342,9 @@ class Concept(Contained, Persistent):
# concept manager # concept manager
@implementer(IConceptManager, ILoopsContained)
class ConceptManager(BTreeContainer): class ConceptManager(BTreeContainer):
implements(IConceptManager, ILoopsContained)
typeConcept = None typeConcept = None
typePredicate = None typePredicate = None
defaultPredicate = None defaultPredicate = None
@ -402,10 +381,9 @@ class ConceptManager(BTreeContainer):
# adapters and similar components # adapters and similar components
@implementer(schema.interfaces.IIterableSource)
class ConceptTypeSourceList(object): class ConceptTypeSourceList(object):
implements(schema.interfaces.IIterableSource)
def __init__(self, context): def __init__(self, context):
if IBrowserRequest.providedBy(context): if IBrowserRequest.providedBy(context):
context = context.context context = context.context
@ -428,10 +406,9 @@ class ConceptTypeSourceList(object):
return len(self.conceptTypes) return len(self.conceptTypes)
@implementer(schema.interfaces.IIterableSource)
class PredicateSourceList(object): class PredicateSourceList(object):
implements(schema.interfaces.IIterableSource)
def __init__(self, context): def __init__(self, context):
self.context = context self.context = context
self.concepts = self.context.getLoopsRoot().getConceptManager() self.concepts = self.context.getLoopsRoot().getConceptManager()
@ -458,9 +435,9 @@ class PredicateSourceList(object):
return len(self.predicates) return len(self.predicates)
@implementer(IIndexAttributes)
class IndexAttributes(object): class IndexAttributes(object):
implements(IIndexAttributes)
adapts(IConcept) adapts(IConcept)
def __init__(self, context): def __init__(self, context):
@ -537,19 +514,17 @@ class IndexAttributes(object):
# events # events
@implementer(IAssignmentEvent)
class AssignmentEvent(ObjectEvent): class AssignmentEvent(ObjectEvent):
implements(IAssignmentEvent)
def __init__(self, obj, relation): def __init__(self, obj, relation):
super(AssignmentEvent, self).__init__(obj) super(AssignmentEvent, self).__init__(obj)
self.relation = relation self.relation = relation
@implementer(IDeassignmentEvent)
class DeassignmentEvent(ObjectEvent): class DeassignmentEvent(ObjectEvent):
implements(IDeassignmentEvent)
def __init__(self, obj, relation): def __init__(self, obj, relation):
super(DeassignmentEvent, self).__init__(obj) super(DeassignmentEvent, self).__init__(obj)
self.relation = relation self.relation = relation

View file

@ -1,30 +1,10 @@
# # loops.i18n.common
# Copyright (c) 2007 Helmut Merz helmutm@cy55.de
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Common i18n (internationalization) stuff.
Common stuff.
$Id$
""" """
from zope import component from zope import component
from zope.component import adapts from zope.component import adapts
from zope.interface import implements
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.security.proxy import removeSecurityProxy from zope.security.proxy import removeSecurityProxy
from persistent.mapping import PersistentMapping from persistent.mapping import PersistentMapping

View file

@ -1,23 +1,6 @@
# # loops.interfaces
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ loops interface definitions.
loops interface definitions.
""" """
from zope.interface import Interface, Attribute from zope.interface import Interface, Attribute
@ -287,15 +270,15 @@ class IBaseResource(ILoopsObject):
data = schema.Bytes( data = schema.Bytes(
title=_(u'Data'), title=_(u'Data'),
description=_(u'Resource raw data'), description=_(u'Resource raw data'),
default='', default=b'',
missing_value='', missing_value=b'',
required=False) required=False)
contentType = schema.BytesLine( contentType = schema.BytesLine(
title=_(u'Content Type'), title=_(u'Content Type'),
description=_(u'Content type (format) of the data field'), description=_(u'Content type (format) of the data field'),
default='', default=b'',
missing_value='', missing_value=b'',
required=False) required=False)
metaInfo = Attribute('Optional additional information about the resource ' metaInfo = Attribute('Optional additional information about the resource '
@ -361,15 +344,15 @@ class IResourceSchema(Interface):
data = schema.Bytes( data = schema.Bytes(
title=_(u'Data'), title=_(u'Data'),
description=_(u'Resource raw data'), description=_(u'Resource raw data'),
default='', default=b'',
missing_value='', missing_value=b'',
required=False) required=False)
contentType = schema.BytesLine( contentType = schema.BytesLine(
title=_(u'Content Type'), title=_(u'Content Type'),
description=_(u'Content type (format) of the data field'), description=_(u'Content type (format) of the data field'),
default='', default=b'',
missing_value='', missing_value=b'',
required=False) required=False)
metaInfo = Attribute('Optional additional information about the resource ' metaInfo = Attribute('Optional additional information about the resource '
@ -720,14 +703,14 @@ class ITypeConcept(IConceptSchema, ILoopsAdapter, IOptions):
title=_(u'Concept Manager Name'), title=_(u'Concept Manager Name'),
description=_(u'Name of the concept manager in which objects of this ' description=_(u'Name of the concept manager in which objects of this '
u'type should be created.'), u'type should be created.'),
default='', #determined at runtime: 'concepts' or 'resources' default=b'', #determined at runtime: 'concepts' or 'resources'
required=False) required=False)
namePrefix = schema.BytesLine( namePrefix = schema.BytesLine(
title=_(u'Name Prefix'), title=_(u'Name Prefix'),
description=_(u'String that will be prepended to the (generated) name ' description=_(u'String that will be prepended to the (generated) name '
u'of a newly created object of this type.'), u'of a newly created object of this type.'),
default='', default=b'',
required=False) required=False)
viewName = schema.TextLine( viewName = schema.TextLine(
@ -821,8 +804,8 @@ class IFile(IResourceAdapter, IResourceSchema):
data = schema.Bytes( data = schema.Bytes(
title=_(u'Data'), title=_(u'Data'),
description=_(u'Resource raw data'), description=_(u'Resource raw data'),
default='', default=b'',
missing_value='', missing_value=b'',
required=False) required=False)
localFilename = Attribute('Filename provided during upload.') localFilename = Attribute('Filename provided during upload.')
@ -854,16 +837,16 @@ class IStorageInfo(Interface):
title=_(u'Storage Name'), title=_(u'Storage Name'),
description=_(u'The name of a storage utility used for this ' description=_(u'The name of a storage utility used for this '
'object.'), 'object.'),
default='', default=b'',
missing_value='', missing_value=b'',
required=False) required=False)
storageParams = schema.BytesLine( storageParams = schema.BytesLine(
title=_(u'Storage Parameters'), title=_(u'Storage Parameters'),
description=_(u'Information used to address the external ' description=_(u'Information used to address the external '
'storage, e.g. a filename or path.'), 'storage, e.g. a filename or path.'),
default='', default=b'',
missing_value='', missing_value=b'',
required=False) required=False)
externalAddress = ExternalAddressField( externalAddress = ExternalAddressField(
@ -883,8 +866,8 @@ class IExternalFile(IFile):
data = schema.Bytes( data = schema.Bytes(
title=_(u'Data'), title=_(u'Data'),
description=_(u'Resource raw data'), description=_(u'Resource raw data'),
default='', default=b'',
missing_value='', missing_value=b'',
required=False) required=False)
externalAddress = ExternalAddressField( externalAddress = ExternalAddressField(

View file

@ -1,26 +1,6 @@
#! /usr/bin/env python # loops.main
#
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Entry point for the loops application.
Entry point for the loops application.
$Id$
""" """
import os, sys import os, sys
@ -68,7 +48,7 @@ def setInstanceHomeInZopeConf():
zc.close() zc.close()
command, key, value = [w.strip() for w in l1.split()] command, key, value = [w.strip() for w in l1.split()]
if command == '%define' and key == 'INSTANCE' and value != instanceHome: if command == '%define' and key == 'INSTANCE' and value != instanceHome:
print 'INSTANCE variable changed from %s to %s.' % (value, instanceHome) print('INSTANCE variable changed from %s to %s.' % (value, instanceHome))
l1 = ' '.join((command, key, instanceHome)) + '\n' l1 = ' '.join((command, key, instanceHome)) + '\n'
zc = open(configFile, 'w') zc = open(configFile, 'w')
zc.write(l1) zc.write(l1)
@ -86,7 +66,7 @@ def startZope(configFile):
main(["-C", configFile]) main(["-C", configFile])
except IOError, e: except IOError, e:
if str(e) == '[Errno 11] Resource temporarily unavailable': if str(e) == '[Errno 11] Resource temporarily unavailable':
print 'WARNING: Background process already running.' print('WARNING: Background process already running.')
#from startup import openBrowser #from startup import openBrowser
#openBrowser(None) #openBrowser(None)

View file

@ -1,32 +1,14 @@
# # loops.security.common
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Common functions and other stuff for working with permissions and roles.
Common functions and other stuff for working with permissions and roles.
""" """
from persistent import Persistent from persistent import Persistent
from zope import component from zope import component
from zope.annotation.interfaces import IAttributeAnnotatable from zope.annotation.interfaces import IAttributeAnnotatable
from zope.app.container.interfaces import IObjectAddedEvent
from zope.app.security.settings import Allow, Deny, Unset
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.interface import implements from zope.interface import implementer
from zope.lifecycleevent import IObjectAddedEvent
from zope.lifecycleevent import IObjectCreatedEvent, IObjectModifiedEvent from zope.lifecycleevent import IObjectCreatedEvent, IObjectModifiedEvent
from zope.location.interfaces import IRoot, ILocation from zope.location.interfaces import IRoot, ILocation
from zope.security import canAccess, canWrite from zope.security import canAccess, canWrite
@ -34,6 +16,7 @@ from zope.security import checkPermission as baseCheckPermission
from zope.security.management import getInteraction from zope.security.management import getInteraction
from zope.securitypolicy.interfaces import IPrincipalRoleManager from zope.securitypolicy.interfaces import IPrincipalRoleManager
from zope.securitypolicy.interfaces import IRolePermissionManager from zope.securitypolicy.interfaces import IRolePermissionManager
from zope.securitypolicy.settings import Allow, Deny, Unset
from zope.traversing.api import getName, getParents from zope.traversing.api import getName, getParents
from zope.traversing.interfaces import IPhysicallyLocatable from zope.traversing.interfaces import IPhysicallyLocatable
@ -228,13 +211,12 @@ def revokeAcquiredSecurity(obj, event):
# workspace handling # workspace handling
@implementer(IPhysicallyLocatable, IWorkspaceInformation)
class WorkspaceInformation(Persistent): class WorkspaceInformation(Persistent):
""" For storing security-related stuff pertaining to """ For storing security-related stuff pertaining to
children and resources of the context (=parent) object. children and resources of the context (=parent) object.
""" """
implements(IPhysicallyLocatable, IWorkspaceInformation)
__name__ = u'workspace_information' __name__ = u'workspace_information'
#propagateRolePermissions = 'object' # or 'none' #propagateRolePermissions = 'object' # or 'none'
@ -259,9 +241,9 @@ class WorkspaceInformation(Persistent):
return [p] + getParents(p) return [p] + getParents(p)
@implementer(ILocation)
class LocationWSI(object): class LocationWSI(object):
implements(ILocation)
component.adapts(WorkspaceInformation) component.adapts(WorkspaceInformation)
def __init__(self, context): def __init__(self, context):

20
loops/tests/config.py Normal file
View file

@ -0,0 +1,20 @@
# py-scopes/demo/config.py
from dotenv import load_dotenv
from os import getenv
from scopes.server.app import zope_app_factory
load_dotenv()
server_port = getenv('SERVER_PORT', '8099')
app_factory = zope_app_factory
# storage settings
from scopes.storage.db.postgres import StorageFactory
dbengine = 'postgresql+psycopg'
dbname = getenv('DBNAME', 'demo')
dbuser = getenv('DBUSER', 'demo')
dbpassword = getenv('DBPASSWORD', 'secret')
dbschema = getenv('DBSCHEMA', 'demo')

View file

@ -9,7 +9,7 @@ from zope.publisher.browser import BrowserView
from zope import component from zope import component
from zope.catalog.interfaces import ICatalog from zope.catalog.interfaces import ICatalog
from zope.interface import Attribute, Interface from zope.interface import Attribute, Interface
from zope.interface import directlyProvides, directlyProvidedBy, implements from zope.interface import directlyProvides, directlyProvidedBy, implementer
from zope.intid.interfaces import IIntIds from zope.intid.interfaces import IIntIds
from zope.i18nmessageid import MessageFactory from zope.i18nmessageid import MessageFactory
from zope.publisher.interfaces.browser import IBrowserRequest from zope.publisher.interfaces.browser import IBrowserRequest
@ -53,9 +53,9 @@ MarkdownSourceFactory = SourceFactory(
IMarkdownSource, _("Markdown(md))"), IMarkdownSource, _("Markdown(md))"),
_("Markdown(md) Source")) _("Markdown(md) Source"))
@implementer(IHTMLRenderer)
class MarkdownToHTMLRenderer(BrowserView): class MarkdownToHTMLRenderer(BrowserView):
implements(IHTMLRenderer)
component.adapts(IMarkdownSource, IBrowserRequest) component.adapts(IMarkdownSource, IBrowserRequest)
def render(self, settings_overrides={}): def render(self, settings_overrides={}):
@ -94,7 +94,7 @@ def nl2br(text):
return '<br />\n'.join(text.split('\r')) return '<br />\n'.join(text.split('\r'))
def toUnicode(value, encoding='UTF-8'): def toUnicode(value, encoding='UTF-8'):
if type(value) is not unicode: if type(value) is not str:
try: try:
return value.decode(encoding) return value.decode(encoding)
except UnicodeDecodeError: except UnicodeDecodeError:

View file

@ -1,25 +1,6 @@
# # loops.view
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
""" """ Definition of the View and related classses.
Definition of the View and related classses.
$Id$
""" """
from zope import component from zope import component
@ -28,7 +9,7 @@ from zope.app.container.contained import Contained
from zope.app.container.ordered import OrderedContainer from zope.app.container.ordered import OrderedContainer
from zope.cachedescriptors.property import Lazy, readproperty from zope.cachedescriptors.property import Lazy, readproperty
from zope.component import adapts from zope.component import adapts
from zope.interface import implements from zope.interface import implementer
from zope.interface import alsoProvides, directlyProvides, directlyProvidedBy from zope.interface import alsoProvides, directlyProvides, directlyProvidedBy
from zope.intid.interfaces import IIntIds from zope.intid.interfaces import IIntIds
from zope.publisher.browser import applySkin from zope.publisher.browser import applySkin
@ -55,10 +36,9 @@ from loops import util
from loops.util import _ from loops.util import _
@implementer(IView, INodeContained, IRelatable)
class View(object): class View(object):
implements(IView, INodeContained, IRelatable)
def __init__(self, title=u'', description=u''): def __init__(self, title=u'', description=u''):
self.title = title self.title = title
self.description = description self.description = description
@ -86,8 +66,9 @@ class View(object):
if len(rels) == 0: if len(rels) == 0:
return None return None
if len(rels) > 1: if len(rels) > 1:
targets = [getName(r.second) for r in rels]
raise ValueError('There may be only one target for a View object: %s - %s' raise ValueError('There may be only one target for a View object: %s - %s'
% (getName(self), `[getName(r.second) for r in rels]`)) % (getName(self), targets))
return list(rels)[0].second return list(rels)[0].second
def setTarget(self, target): def setTarget(self, target):
@ -114,10 +95,9 @@ class View(object):
return Jeep() return Jeep()
@implementer(INode)
class Node(View, OrderedContainer): class Node(View, OrderedContainer):
implements(INode)
_nodeType = 'info' _nodeType = 'info'
def getNodeType(self): return self._nodeType def getNodeType(self): return self._nodeType
def setNodeType(self, nodeType): self._nodeType = nodeType def setNodeType(self, nodeType): self._nodeType = nodeType
@ -180,10 +160,9 @@ class Node(View, OrderedContainer):
return self.nodeType in ('page', 'menu') return self.nodeType in ('page', 'menu')
@implementer(IViewManager, ILoopsContained)
class ViewManager(OrderedContainer): class ViewManager(OrderedContainer):
implements(IViewManager, ILoopsContained)
def getLoopsRoot(self): def getLoopsRoot(self):
return getParent(self) return getParent(self)
@ -194,21 +173,22 @@ class ViewManager(OrderedContainer):
return Jeep() return Jeep()
@implementer(ITargetRelation)
class TargetRelation(DyadicRelation): class TargetRelation(DyadicRelation):
""" A relation between a view and its target. """ A relation between a view and its target.
""" """
implements(ITargetRelation) pass
# adapters # adapters
@implementer(INodeAdapter)
class NodeAdapter(AdapterBase): class NodeAdapter(AdapterBase):
""" Allows nodes to be adapted like concepts and resources, e.g. """ Allows nodes to be adapted like concepts and resources, e.g.
for i18n (needs derivation from I18NAdapterBase), for i18n (needs derivation from I18NAdapterBase),
specific capabilities or dynamic attributes. specific capabilities or dynamic attributes.
""" """
implements(INodeAdapter)
adapts(INode) adapts(INode)
_contextAttributes = ('title', 'description', 'body',) _contextAttributes = ('title', 'description', 'body',)
@ -222,10 +202,9 @@ nodeTypes = [
('raw', _(u'Raw')), # render body as is, viewName may contain content type ('raw', _(u'Raw')), # render body as is, viewName may contain content type
] ]
@implementer(schema.interfaces.IIterableSource)
class NodeTypeSourceList(object): class NodeTypeSourceList(object):
implements(schema.interfaces.IIterableSource)
def __init__(self, context): def __init__(self, context):
self.context = context self.context = context

View file

@ -13,6 +13,14 @@ authors = [{name = "Helmut Merz", email = "helmutm@cy55.de"}]
dependencies = [ dependencies = [
"cybertools", "cybertools",
"py-scopes",
"markdown",
"python-dotenv",
"zope.app.renderer",
"zope.browsermenu",
"zope.securitypolicy",
"zope.site",
"zope.thread",
] ]
[project.optional-dependencies] [project.optional-dependencies]