organize: Python3 fixes for: comment, job, stateful

This commit is contained in:
Helmut Merz 2024-09-25 23:37:00 +02:00
parent 52ac41a82f
commit 956a6d01b3
5 changed files with 16 additions and 52 deletions

View file

@ -2,8 +2,6 @@
loops - Linked Objects for Organization and Processing Services
===============================================================
($Id$)
Let's do some basic setup
>>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
@ -72,10 +70,10 @@ Viewing comments
>>> items = list(comments.allItems())
>>> items
[<Comment ['27', 1, '33', '... ...']:
{'text': 'Comment text', 'subject': 'My comment'}>]
{'subject': 'My comment', 'text': 'Comment text'}>]
>>> item = items[0]
>>> item.subject, item.timeStamp, item.user['title']
('My comment', u'... ...', u'john')
('My comment', '... ...', 'john')
Reporting

View file

@ -1,27 +1,10 @@
#
# 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
#
# loops.organize.comment.base
"""
Base classes for comments/discussions.
""" Base classes for comments/discussions.
"""
from zope.component import adapts
from zope.interface import implementer, implements
from zope.interface import implementer
from zope.traversing.api import getParent
from cybertools.stateful.definition import StatesDefinition
@ -46,10 +29,9 @@ def commentStates():
initialState='new')
@implementer(IComment)
class Comment(Stateful, Track):
implements(IComment)
metadata_attributes = Track.metadata_attributes + ('state',)
index_attributes = metadata_attributes
typeName = 'Comment'

View file

@ -1,23 +1,6 @@
#
# 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
#
# organize.comment.interfaces
"""
Interface definitions for comments - discussions - forums.
""" Interface definitions for comments - discussions - forums.
"""
from zope.interface import Interface, Attribute

View file

@ -2,8 +2,6 @@
loops - Linked Objects for Organization and Processing Services
===============================================================
($Id$)
Let's do some basic setup
>>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
@ -57,7 +55,7 @@ the loops root object.
>>> from loops.organize.job.base import JobManager
>>> class Notifier(JobManager):
... def process(self):
... print 'processing...'
... print('processing...')
>>> component.provideAdapter(Notifier, name='loops_notifier')
>>> loopsRoot.options = ['organize.job.managers:loops_notifier']

View file

@ -146,8 +146,8 @@ The form view gives us access to the states of the object.
... sto = st.getStateObject()
... transitions = st.getAvailableTransitions()
... userTrans = st.getAvailableTransitionsForUser()
... print st.statesDefinition, sto.title, [t.title for t in transitions],
... print [t.title for t in userTrans]
... print(st.statesDefinition, sto.title, [t.title for t in transitions], end=' ')
... print([t.title for t in userTrans])
classification_quality unclassified ['classify', 'verify'] ['verify']
simple_publishing published ['retract', 'archive'] ['retract', 'archive']
@ -169,8 +169,11 @@ Querying objects by state
>>> from loops.organize.stateful.browser import StateQuery
>>> view = StateQuery(stateQuery, TestRequest())
>>> view.rcStatesDefinitions
{'concept': [], 'resource': [...StatesDefinition..., ...StatesDefinition...]}
>>> stdef = view.rcStatesDefinitions
>>> stdef['resource']
[...StatesDefinition..., ...StatesDefinition...]
>>> stdef['concept']
[]
>>> input = {'state.resource.classification_quality': ['verified']}
>>> view = StateQuery(stateQuery, TestRequest(form=input))