Python3 fixes: constraint, media, system

This commit is contained in:
Helmut Merz 2024-09-28 08:14:49 +02:00
parent 1da71c72a9
commit 6ae2590f50
9 changed files with 32 additions and 155 deletions

View file

@ -1,30 +1,11 @@
# # loops.constraint.base
# 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
#
""" """ Constraint definitions for restricting concepts and predicates available
Constraint definitions for restricting concepts and predicates available
for assignment as children or as concepts to resources. for assignment as children or as concepts to resources.
$Id$
""" """
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.interface import implements from zope.interface import implementer
from zope.traversing.api import getName from zope.traversing.api import getName
from loops.common import AdapterBase, adapterAttributes, contextAttributes from loops.common import AdapterBase, adapterAttributes, contextAttributes
@ -40,13 +21,12 @@ hasConstraint = 'hasconstraint'
hasChildConstraint = 'haschildconstraint' hasChildConstraint = 'haschildconstraint'
@implementer(IStaticConstraint)
class StaticConstraint(AdapterBase): class StaticConstraint(AdapterBase):
_contextAttributes = contextAttributes(AdapterBase, 'relationType', 'cardinality') _contextAttributes = contextAttributes(AdapterBase, 'relationType', 'cardinality')
_adapterAttributes = adapterAttributes(AdapterBase, 'predicates', 'types') _adapterAttributes = adapterAttributes(AdapterBase, 'predicates', 'types')
implements(IStaticConstraint)
def getPredicates(self): def getPredicates(self):
return self.context.getChildren([isPredicate]) return self.context.getChildren([isPredicate])
def setPredicates(self, value): def setPredicates(self, value):

View file

@ -1,13 +1,12 @@
""" # loops.constraint.testsetup
Set up a loops site for testing.
$Id$ """ Set up a loops site for testing.
""" """
import os import os
from zope import component from zope import component
from zope.app.catalog.interfaces import ICatalog from zope.catalog.interfaces import ICatalog
from zope.app.catalog.field import FieldIndex from zope.catalog.field import FieldIndex
from loops import util from loops import util
from loops.concept import Concept from loops.concept import Concept

View file

@ -2,8 +2,6 @@
loops - Linked Objects for Organization and Processing Services loops - Linked Objects for Organization and Processing Services
=============================================================== ===============================================================
($Id$)
Media Asset Management Media Asset Management
====================== ======================

View file

@ -1,23 +1,6 @@
# # loops.media.asset
# Copyright (c) 2014 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
#
""" """ Media asset file adapter.
Media asset file adapter.
Original authors: Johann Schimpf, Erich Seifert. Original authors: Johann Schimpf, Erich Seifert.
""" """
@ -28,7 +11,7 @@ import os
from zope import component from zope import component
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.interface import implements from zope.interface import implementer
from cybertools.media.asset import MediaAssetFile from cybertools.media.asset import MediaAssetFile
from cybertools.storage.interfaces import IExternalStorage from cybertools.storage.interfaces import IExternalStorage
@ -44,13 +27,12 @@ transformPrefix = 'asset_transform.'
TypeInterfaceSourceList.typeInterfaces += (IMediaAsset,) TypeInterfaceSourceList.typeInterfaces += (IMediaAsset,)
@implementer(IMediaAsset)
class MediaAsset(MediaAssetFile, ExternalFileAdapter): class MediaAsset(MediaAssetFile, ExternalFileAdapter):
""" Concept adapter for extracting metadata from assets and for creating """ Concept adapter for extracting metadata from assets and for creating
transformation variants. transformation variants.
""" """
implements(IMediaAsset)
_adapterAttributes = ExternalFileAdapter._adapterAttributes + ('modified',) _adapterAttributes = ExternalFileAdapter._adapterAttributes + ('modified',)
_contextAttributes = list(IMediaAsset) _contextAttributes = list(IMediaAsset)
@ -109,7 +91,7 @@ class MediaAsset(MediaAssetFile, ExternalFileAdapter):
pass pass
try: try:
return datetime.fromtimestamp(os.path.getmtime(dp)) return datetime.fromtimestamp(os.path.getmtime(dp))
except Exception, e: except Exception as e:
getLogger('loops.media.asset.MediaAsset').warn(e) getLogger('loops.media.asset.MediaAsset').warn(e)
return None return None

View file

@ -4,8 +4,6 @@ loops - Linked Objects for Organization and Processing Services
loops System Management. loops System Management.
($Id$)
Setting up a loops Site and Utilities Setting up a loops Site and Utilities
===================================== =====================================
@ -39,11 +37,11 @@ In addition to the application site we need a loops system management site.
>>> systemRoot = site['loops.system'] >>> systemRoot = site['loops.system']
>>> sorted(sysConcepts) >>> sorted(sysConcepts)
[u'domain', u'file', u'hasType', u'job', u'note', u'predicate', ['domain', 'file', 'hasType', 'job', 'note', 'predicate',
u'standard', u'textdocument', u'type'] 'standard', 'textdocument', 'type']
>>> list(systemRoot.getRecordManager().keys()) >>> list(systemRoot.getRecordManager().keys())
[u'jobs'] ['jobs']
Portal Links Portal Links

View file

@ -1,28 +1,9 @@
# # loops.system.job
# Copyright (c) 2010 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
#
""" """ Recording changes to loops objects.
Recording changes to loops objects.
$Id$
""" """
from zope.interface import implements from zope.interface import implementer
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.component import adapter from zope.component import adapter
@ -33,10 +14,9 @@ from loops.system.interfaces import IJobRecord, IJobRecords
from loops import util from loops import util
@implementer(IJobRecords)
class JobRecords(BaseRecordManager): class JobRecords(BaseRecordManager):
implements(IJobRecords)
storageName = 'jobs' storageName = 'jobs'
def __init__(self, context): def __init__(self, context):
@ -56,9 +36,8 @@ class JobRecords(BaseRecordManager):
return None return None
@implementer(IJobRecord)
class JobRecord(Track): class JobRecord(Track):
implements(IJobRecord)
typeName = 'JobRecord' typeName = 'JobRecord'

View file

@ -1,29 +1,9 @@
# # loops.system.setup
# Copyright (c) 2010 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
#
""" """ Automatic setup of a loops site for the system package.
Automatic setup of a loops site for the system package.
$Id$
""" """
from zope.component import adapts from zope.component import adapts
from zope.interface import implements, Interface
from cybertools.tracking.btree import TrackingStorage from cybertools.tracking.btree import TrackingStorage
from loops.concept import Concept from loops.concept import Concept

View file

@ -1,28 +1,9 @@
# # loops.system.site.link
# Copyright (c) 2010 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
#
""" """ Interfaces for linking to other pages on a portal page.
Interfaces for linking to other pages on a portal page.
$Id$
""" """
from zope.interface import implements from zope.interface import implementer
from zope import interface, component, schema from zope import interface, component, schema
from loops.common import AdapterBase from loops.common import AdapterBase
@ -34,8 +15,7 @@ from loops.util import _
TypeInterfaceSourceList.typeInterfaces += (ILink,) TypeInterfaceSourceList.typeInterfaces += (ILink,)
@implementer(ILink)
class Link(AdapterBase): class Link(AdapterBase):
implements(ILink)
_contextAttributes = list(ILink) _contextAttributes = list(ILink)

View file

@ -1,34 +1,15 @@
# # loops.system.sync.browser
# Copyright (c) 2010 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
#
""" """ view class(es) for import/export.
view class(es) for import/export.
$Id$
""" """
from cStringIO import StringIO from io import StringIO
from logging import getLogger from logging import getLogger
import os import os
import time import time
from urllib import urlopen, urlencode from urllib.parse import urlencode
from urllib.request import urlopen
from zope import component from zope import component
from zope.interface import Interface, implements
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.traversing.api import getName, getPath from zope.traversing.api import getName, getPath