organize: Python3 fixes for: comment, job, stateful
This commit is contained in:
parent
52ac41a82f
commit
956a6d01b3
5 changed files with 16 additions and 52 deletions
|
@ -2,8 +2,6 @@
|
||||||
loops - Linked Objects for Organization and Processing Services
|
loops - Linked Objects for Organization and Processing Services
|
||||||
===============================================================
|
===============================================================
|
||||||
|
|
||||||
($Id$)
|
|
||||||
|
|
||||||
Let's do some basic setup
|
Let's do some basic setup
|
||||||
|
|
||||||
>>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
|
>>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
|
||||||
|
@ -72,10 +70,10 @@ Viewing comments
|
||||||
>>> items = list(comments.allItems())
|
>>> items = list(comments.allItems())
|
||||||
>>> items
|
>>> items
|
||||||
[<Comment ['27', 1, '33', '... ...']:
|
[<Comment ['27', 1, '33', '... ...']:
|
||||||
{'text': 'Comment text', 'subject': 'My comment'}>]
|
{'subject': 'My comment', 'text': 'Comment text'}>]
|
||||||
>>> item = items[0]
|
>>> item = items[0]
|
||||||
>>> item.subject, item.timeStamp, item.user['title']
|
>>> item.subject, item.timeStamp, item.user['title']
|
||||||
('My comment', u'... ...', u'john')
|
('My comment', '... ...', 'john')
|
||||||
|
|
||||||
|
|
||||||
Reporting
|
Reporting
|
||||||
|
|
|
@ -1,27 +1,10 @@
|
||||||
#
|
# loops.organize.comment.base
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" Base classes for comments/discussions.
|
||||||
Base classes for comments/discussions.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
from zope.interface import implementer, implements
|
from zope.interface import implementer
|
||||||
from zope.traversing.api import getParent
|
from zope.traversing.api import getParent
|
||||||
|
|
||||||
from cybertools.stateful.definition import StatesDefinition
|
from cybertools.stateful.definition import StatesDefinition
|
||||||
|
@ -46,10 +29,9 @@ def commentStates():
|
||||||
initialState='new')
|
initialState='new')
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IComment)
|
||||||
class Comment(Stateful, Track):
|
class Comment(Stateful, Track):
|
||||||
|
|
||||||
implements(IComment)
|
|
||||||
|
|
||||||
metadata_attributes = Track.metadata_attributes + ('state',)
|
metadata_attributes = Track.metadata_attributes + ('state',)
|
||||||
index_attributes = metadata_attributes
|
index_attributes = metadata_attributes
|
||||||
typeName = 'Comment'
|
typeName = 'Comment'
|
||||||
|
|
|
@ -1,23 +1,6 @@
|
||||||
#
|
# organize.comment.interfaces
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
""" Interface definitions for comments - discussions - forums.
|
||||||
Interface definitions for comments - discussions - forums.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.interface import Interface, Attribute
|
from zope.interface import Interface, Attribute
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
loops - Linked Objects for Organization and Processing Services
|
loops - Linked Objects for Organization and Processing Services
|
||||||
===============================================================
|
===============================================================
|
||||||
|
|
||||||
($Id$)
|
|
||||||
|
|
||||||
Let's do some basic setup
|
Let's do some basic setup
|
||||||
|
|
||||||
>>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
|
>>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
|
||||||
|
@ -57,7 +55,7 @@ the loops root object.
|
||||||
>>> from loops.organize.job.base import JobManager
|
>>> from loops.organize.job.base import JobManager
|
||||||
>>> class Notifier(JobManager):
|
>>> class Notifier(JobManager):
|
||||||
... def process(self):
|
... def process(self):
|
||||||
... print 'processing...'
|
... print('processing...')
|
||||||
|
|
||||||
>>> component.provideAdapter(Notifier, name='loops_notifier')
|
>>> component.provideAdapter(Notifier, name='loops_notifier')
|
||||||
>>> loopsRoot.options = ['organize.job.managers:loops_notifier']
|
>>> loopsRoot.options = ['organize.job.managers:loops_notifier']
|
||||||
|
|
|
@ -146,8 +146,8 @@ The form view gives us access to the states of the object.
|
||||||
... sto = st.getStateObject()
|
... sto = st.getStateObject()
|
||||||
... transitions = st.getAvailableTransitions()
|
... transitions = st.getAvailableTransitions()
|
||||||
... userTrans = st.getAvailableTransitionsForUser()
|
... userTrans = st.getAvailableTransitionsForUser()
|
||||||
... print st.statesDefinition, sto.title, [t.title for t in transitions],
|
... print(st.statesDefinition, sto.title, [t.title for t in transitions], end=' ')
|
||||||
... print [t.title for t in userTrans]
|
... print([t.title for t in userTrans])
|
||||||
classification_quality unclassified ['classify', 'verify'] ['verify']
|
classification_quality unclassified ['classify', 'verify'] ['verify']
|
||||||
simple_publishing published ['retract', 'archive'] ['retract', 'archive']
|
simple_publishing published ['retract', 'archive'] ['retract', 'archive']
|
||||||
|
|
||||||
|
@ -169,8 +169,11 @@ Querying objects by state
|
||||||
>>> from loops.organize.stateful.browser import StateQuery
|
>>> from loops.organize.stateful.browser import StateQuery
|
||||||
>>> view = StateQuery(stateQuery, TestRequest())
|
>>> view = StateQuery(stateQuery, TestRequest())
|
||||||
|
|
||||||
>>> view.rcStatesDefinitions
|
>>> stdef = view.rcStatesDefinitions
|
||||||
{'concept': [], 'resource': [...StatesDefinition..., ...StatesDefinition...]}
|
>>> stdef['resource']
|
||||||
|
[...StatesDefinition..., ...StatesDefinition...]
|
||||||
|
>>> stdef['concept']
|
||||||
|
[]
|
||||||
|
|
||||||
>>> input = {'state.resource.classification_quality': ['verified']}
|
>>> input = {'state.resource.classification_quality': ['verified']}
|
||||||
>>> view = StateQuery(stateQuery, TestRequest(form=input))
|
>>> view = StateQuery(stateQuery, TestRequest(form=input))
|
||||||
|
|
Loading…
Add table
Reference in a new issue