Compare commits

...
Sign in to create a new pull request.

49 commits

Author SHA1 Message Date
0e5270f8d5 fix remaining 'implements'... 2025-02-22 11:31:19 +01:00
fe632fbeab more Python3 fixes (unicode, basestring) 2025-01-11 11:35:21 +01:00
860d18cae8 Python3 fix for schema.grid 2025-01-07 08:46:31 +01:00
569e197609 more minor Python3 fixes 2024-11-24 10:18:21 +01:00
12978d2389 tracks: determine indexAttributes dynamically, allowing later change 2024-11-24 10:11:25 +01:00
df1229d8fd minor fixes for avoiding errors with Python3 / up-to-date libraries 2024-10-26 19:22:59 +02:00
93a2acf7db some more Python3 fixes 2024-10-03 17:00:16 +02:00
25277a0b65 avoid testing deprecation errors with Python3.12 2024-10-02 10:14:22 +02:00
aef9ad8cb5 make Python3.12 happy 2024-10-02 09:45:57 +02:00
814d7c0762 changes to allow zodbupdate to migrate old data 2024-10-02 09:08:16 +02:00
8a6277fbff some more Python3 fixes 2024-10-01 16:09:46 +02:00
2cbd4c11d3 fix UID handling in commerce 2024-10-01 15:40:38 +02:00
968aeab42a one more Python3 fix in ajax 2024-09-29 12:04:56 +02:00
f1080df88b use zope-testrunner for running all relevant tests => more Python3 fixes 2024-09-28 11:42:20 +02:00
33ab512b7f some more Python3 fixes (composer.report, tracking) 2024-09-26 16:24:24 +02:00
17fbeb2c2c browser.loops.auth: Python3 fix 2024-09-25 17:05:19 +02:00
52e3fc72c6 more Python3 fixes in composer, knowledge 2024-09-25 10:57:30 +02:00
db31a73bc9 container: Python3 fix 2024-09-25 09:31:49 +02:00
ee82ee7b32 composer: some more Python3 fixes 2024-09-24 19:24:25 +02:00
71f36283b9 Merge branch '2master' into 3master 2024-09-24 17:15:06 +02:00
d66aa31058 more Python3 fixes (browser.action, composer...field) 2024-09-24 17:11:06 +02:00
5f3bd3c04f composer: more Python3 fixes 2024-09-24 11:14:22 +02:00
b22dbf879c remove deprecated zope.app.container references 2024-09-23 22:50:46 +02:00
9fbd97386e some more Python3 fixes... 2024-09-23 15:35:14 +02:00
b8eba239ed typology: Python3 fixes; + update of example data 2024-09-23 15:05:10 +02:00
61c78fe3e7 reporter: Python3 fixes 2024-09-23 13:12:33 +02:00
3ec90f4b66 relation: Python3 fixes 2024-09-23 12:17:52 +02:00
f9a3326ec7 process: Python3 fixes 2024-09-23 11:14:21 +02:00
8037ac38be organize: Python3 fixes 2024-09-23 11:00:35 +02:00
52990d1df6 work in progress: organize: Python3 fixes 2024-09-22 18:10:02 +02:00
8d260908a5 meta: Python3 fixes 2024-09-22 17:16:33 +02:00
b60d6d3b10 external: some Python3 fixes 2024-09-22 16:12:36 +02:00
e98dd2ed34 media: Python3 fixes 2024-09-22 15:24:24 +02:00
c9220d834d linK: Python3 fixes 2024-09-22 14:46:28 +02:00
383b77edf1 knowledge: Python3 fixes 2024-09-22 13:31:58 +02:00
b866ac4267 integrator.filesystem: Python3 fixes 2024-09-22 13:25:46 +02:00
ee9d062833 docgen: Python3 fixes 2024-09-22 11:16:47 +02:00
4b84e816b4 container: Python3 fixes 2024-09-22 10:41:30 +02:00
80766f2279 composer, util: Python3 fixes 2024-09-22 10:24:02 +02:00
87ca77df45 commerce: Python3 fixes, + composer (.base, .schema) 2024-09-21 22:36:59 +02:00
c5fe028756 catalog: Python3 fixes (+ some fixes in relation) 2024-09-21 17:04:16 +02:00
ad632e23ee browser: Python3 fixes 2024-09-21 16:12:03 +02:00
98ebc30bd5 tracking: tests OK, including some fixes in container 2024-09-21 15:04:57 +02:00
bd631677d6 brain: fixes (zope.interface.implementer); + text: improvements 2024-09-21 14:27:15 +02:00
06682d2a5c define project via pyproject.toml, removing setup.py; + fixes => cybertools.text tests OK 2024-09-21 09:06:42 +02:00
6f86e74feb work in progress: migration of records (tracking) - main development in python2 (2master) branch 2023-12-11 08:19:49 +01:00
1fb58a7db3 remove copyright comments - see LICENSE file 2023-11-29 13:19:47 +01:00
fad566b354 make package cybertools.tracking Python3-ready 2023-11-29 11:48:36 +01:00
43ea46e401 cybertools.text: OK on py3 2023-11-27 18:49:05 +01:00
667 changed files with 2015 additions and 7086 deletions

2
.gitignore vendored
View file

@ -1,6 +1,6 @@
*.pyc *.pyc
*.pyo *.pyo
ajax/dojo/* */ajax/dojo/dojo*
build/ build/
dist/ dist/
*.swp *.swp

View file

@ -1,41 +0,0 @@
#
# Copyright (c) 2006 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
#
"""
Transaction management.
$Id$
"""
from zope.interface import implements
from cybertools.brain.interfaces import ISession
class Session(object):
implements(ISession)
def __init__(self):
self.states = {}
def setState(self, neuron, state):
self.states[neuron] = state
def getState(self, neuron):
return self.states.get(neuron, neuron.state)

View file

@ -1,55 +0,0 @@
#
# Copyright (c) 2006 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 state and state manipulations using a float-based state.
$Id$
"""
from zope.interface import implements
from cybertools.brain.interfaces import IState, ITransition
class State(object):
""" The state of a neuron.
"""
implements(IState)
def __init__(self, value=0.0):
self.value = value
def __repr__(self):
return '<State %0.1f>' % self.value
class Transition(object):
implements(ITransition)
def __init__(self, synapsis, factor=1.0):
self.synapsis = synapsis
self.factor = factor
def execute(self, session=None):
oldState = self.synapsis.receiver.getState(session)
senderState = self.synapsis.sender.getState(session)
return State(oldState.value + senderState.value * self.factor)

View file

@ -1,48 +0,0 @@
#
# Copyright (c) 2006 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
#
"""Form Controller stuff: form processing is the part of the
model/view/controller pattern that deals withform input.
$Id$
"""
from zope.interface import Interface, implements
class IFormController(Interface):
""" Used as a named adapter by GenericView for processing form input.
"""
def update():
""" Processing form input...
"""
class FormController(object):
implements(IFormController)
def __init__(self, context, request):
self.view = self.__parent__ = view = context
self.context = view.context # the controller is adapted to a view
self.request = request
def update(self):
pass

View file

@ -1,38 +0,0 @@
#
# Copyright (c) 2017 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
#
""" URL manipulation utilities
$Id$
"""
from urlparse import urlparse
from zope.app.container.traversal import ItemTraverser
from zope.interface import Interface, implements
class TraversalRedirector(ItemTraverser):
port = 9083
names = ('ctt', 'sona',)
loc_pattern = 'www.%s.de'
skip = (0, 4)
def publishTraverse(self, request, name):
return super(TraversalRedirector, self).publishTraverse(request, name)

View file

@ -1,43 +0,0 @@
#
# 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
#
"""Keyword catalog index.
$Id$
"""
import zope.index.keyword
import zope.interface
import zope.app.container.contained
import zope.app.catalog.attribute
import zope.app.catalog.interfaces
class IKeywordIndex(zope.app.catalog.interfaces.IAttributeIndex,
zope.app.catalog.interfaces.ICatalogIndex):
"""Interface-based catalog keyword index.
"""
class KeywordIndex(zope.app.catalog.attribute.AttributeIndex,
zope.index.keyword.KeywordIndex,
zope.app.container.contained.Contained):
zope.interface.implements(IKeywordIndex)

View file

@ -1,46 +0,0 @@
#
# Copyright (c) 2009 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
#
"""
Customer classes.
$Id$
"""
from zope.interface import implements, Interface
from cybertools.commerce.common import RelationSet, BaseObject
from cybertools.commerce.interfaces import ICustomer, IAddress
class Customer(BaseObject):
implements(ICustomer)
def __init__(self, customerId, title=None, client=None):
self.name = self.customerId = customerId
self.title = title or u'unknown'
self.client = client
self.shops = self.collection(self, 'customers')
self.orders = self.collection(self, 'customer')
class Address(BaseObject):
implements(IAddress)

View file

@ -1,48 +0,0 @@
#
# Copyright (c) 2009 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.
$Id$
"""
from zope.interface import implements
from cybertools.commerce.common import RelationSet, BaseObject
from cybertools.commerce.interfaces import IShop
class Shop(BaseObject):
implements(IShop)
collection = RelationSet
def __init__(self, name, title=None):
self.name = name
self.title = title or u'Shop'
self.products = self.collection(self, 'shops')
self.customers = self.collection(self, 'shops')
self.orderNumber = 0
def getNewOrderId(self):
last = self.orderNumber or 0
num = last + 1
self.orderNumber = num
return '%05i' % num

View file

@ -1,62 +0,0 @@
#
# 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
#
"""
Basic classes for complex template structures.
$Id$
"""
from zope.interface import implements
from cybertools.composer.interfaces import IComponent, IElement, ICompound
from cybertools.composer.interfaces import ITemplate
from cybertools.util.jeep import Jeep
class Component(object):
implements(IComponent)
class Element(Component):
implements(IElement)
class Compound(Component):
implements(ICompound)
componentStorage = Jeep
def __init__(self):
self.parts = self.componentStorage()
class Template(object):
implements(ITemplate)
componentStorage = Jeep
components = None
def __init__(self):
if self.componentStorage is not None:
self.components = self.componentStorage()

View file

@ -1,55 +0,0 @@
#
# 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
#
"""
Base classes to be used for client adapters.
$Id$
"""
from zope.interface import implements
from cybertools.composer.interfaces import IInstance
class Instance(object):
implements(IInstance)
templateFactory = dict
templateAttributeName = '__ctc_template__'
aspect = 'composer.default'
def __init__(self, context):
self.context = context
def setTemplate(self, temp):
template = getattr(self.context,
self.templateAttributeName,
self.templateFactory())
template.setdefault(self.aspect, temp)
setattr(self.context, self.templateAttributeName, template)
def getTemplate(self):
template = getattr(self.context, self.templateAttributeName, {})
return template.get(self.aspect, [])
template = property(getTemplate, setTemplate)
def applyTemplates(self, *args, **kw):
raise ValueError('To be implemented by subclass')

View file

@ -1,43 +0,0 @@
#
# 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
#
"""
Default layouts for the liquid skin.
$Id$
"""
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.cachedescriptors.property import Lazy
from zope import component
from zope.interface import implements
from cybertools.browser.liquid import Liquid
from cybertools.browser.renderer import RendererFactory
from cybertools.composer.layout.base import Layout
from cybertools.composer.layout.browser.standard import standardRenderers
defaultRenderers = RendererFactory(ViewPageTemplateFile('default.pt'))
Layout('css.liquid', 'page.css', renderer=standardRenderers['css'],
media='all', resource='liquid.css', skin=Liquid)
Layout('body.liquid', 'page.body', renderer=defaultRenderers.body,
skin=Liquid)

View file

@ -1,39 +0,0 @@
#
# 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
#
"""
Region implementation.
$Id$
"""
from zope.interface import implements
from cybertools.composer.layout.interfaces import IRegion
from cybertools.util.jeep import Jeep
class Region(object):
implements(IRegion)
allowedLayoutCategories = None
def __init__(self, name):
self.name = name
self.layouts = Jeep()

View file

@ -1,52 +0,0 @@
#
# 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
#
"""
Rule instance and related classes.
$Id$
"""
from zope import component
from zope.component import adapts
from zope.interface import Interface, implements
from cybertools.composer.instance import Instance
from cybertools.composer.rule.interfaces import IRuleInstance, IActionHandler
class RuleInstance(Instance):
implements(IRuleInstance)
adapts(Interface)
template = None
event = None
def applyTemplate(self, **kw):
for c in self.template.conditions:
cond = component.getAdapter(self, ICondition, name=c)
if not cond():
continue
data = dict(request=self.event.request)
for action in self.template.actions:
handler = component.getAdapter(self, IActionHandler,
name=action.handlerName)
data = handler(data, action.parameters)
return data

View file

@ -1,55 +0,0 @@
#
# 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
#
"""
Ordered container implementation.
$Id$
"""
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.app.container.browser.contents import JustContents
from zope.app.i18n import ZopeMessageFactory as _
from zope.cachedescriptors.property import Lazy
from zope.interface import Interface
contents_template = ViewPageTemplateFile('contents.pt')
class ContainerView(JustContents):
def checkMoveAction(self):
pass
orderable = False
# informations for the ajax.inner.html view (template):
template = contents_template
#@Lazy
#def template(self):
# basicView = zapi.getMultiAdapter((self.context, self.request),
# Interface, name=u'contents.html')
# return basicView.index
@Lazy
def macro(self):
return self.template.macros['contents']

View file

@ -1,28 +1,10 @@
# # cybertools.ajax.dojo.layout
# 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
#
"""
Embed Dojo using the cybertools.composer.layout procedure.
$Id$ """ Embed Dojo using the cybertools.composer.layout procedure.
""" """
from cStringIO import StringIO from io import StringIO
from zope.app.pagetemplate import ViewPageTemplateFile from zope.browserpage import ViewPageTemplateFile
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from cybertools.browser.renderer import RendererFactory from cybertools.browser.renderer import RendererFactory

View file

@ -1,38 +1,18 @@
# # cybertools.brain.neuron
# Copyright (c) 2006 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
#
""" """ A simple basic implementation of Neuron and Synapsis.
A simple basic implementation of Neuron and Synapsis.
$Id$
""" """
from zope.interface import implements from zope.interface import implementer
from cybertools.brain.interfaces import INeuron, ISynapsis from cybertools.brain.interfaces import INeuron, ISynapsis
from cybertools.brain.state import State, Transition from cybertools.brain.state import State, Transition
@implementer(ISynapsis)
class Synapsis(object): class Synapsis(object):
""" A synapsis connects two neurons. """ A synapsis connects two neurons.
""" """
implements(ISynapsis)
def __init__(self, sender, receiver): def __init__(self, sender, receiver):
self.sender = sender self.sender = sender
sender.receivers.append(self) sender.receivers.append(self)
@ -46,10 +26,9 @@ class Synapsis(object):
receiver.notify(session) receiver.notify(session)
@implementer(INeuron)
class Neuron(object): class Neuron(object):
implements(INeuron)
def __init__(self): def __init__(self):
self.senders = [] self.senders = []
self.receivers = [] self.receivers = []

View file

@ -0,0 +1,21 @@
# cybertools.brain.session
""" Transaction management.
"""
from zope.interface import implementer
from cybertools.brain.interfaces import ISession
implementer(ISession)
class Session(object):
def __init__(self):
self.states = {}
def setState(self, neuron, state):
self.states[neuron] = state
def getState(self, neuron):
return self.states.get(neuron, neuron.state)

34
cybertools/brain/state.py Normal file
View file

@ -0,0 +1,34 @@
# cybertools.brain.state
""" Base classes for state and state manipulations using a float-based state.
"""
from zope.interface import implementer
from cybertools.brain.interfaces import IState, ITransition
@implementer(IState)
class State(object):
""" The state of a neuron.
"""
def __init__(self, value=0.0):
self.value = value
def __repr__(self):
return '<State %0.1f>' % self.value
@implementer(ITransition)
class Transition(object):
def __init__(self, synapsis, factor=1.0):
self.synapsis = synapsis
self.factor = factor
def execute(self, session=None):
oldState = self.synapsis.receiver.getState(session)
senderState = self.synapsis.sender.getState(session)
return State(oldState.value + senderState.value * self.factor)

View file

@ -1,3 +1,4 @@
# cybertools.brain.tests
import unittest, doctest import unittest, doctest
from zope.interface.verify import verifyClass from zope.interface.verify import verifyClass
@ -18,9 +19,8 @@ class TestBrain(unittest.TestCase):
def test_suite(): def test_suite():
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestBrain), unittest.TestLoader().loadTestsFromTestCase(TestBrain),
doctest.DocFileSuite('README.txt', doctest.DocFileSuite('README.txt', optionflags=flags,),
optionflags=flags,),
)) ))
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -3,7 +3,7 @@ Browser View Tools
================== ==================
>>> from zope import component, interface >>> from zope import component, interface
>>> from zope.interface import Interface, implements >>> from zope.interface import Interface, implementer
>>> from zope.publisher.interfaces.browser import IBrowserRequest >>> from zope.publisher.interfaces.browser import IBrowserRequest
@ -17,8 +17,10 @@ the common and node modules there.)
Let's start with a dummy content object and create a view on it: Let's start with a dummy content object and create a view on it:
>>> #@implementer(Interface)
>>> class SomeObject(object): >>> class SomeObject(object):
... implements(Interface) ... pass
>>> SomeObject = implementer(Interface)(SomeObject)
>>> obj = SomeObject() >>> obj = SomeObject()
>>> from cybertools.browser.view import GenericView >>> from cybertools.browser.view import GenericView
@ -122,7 +124,7 @@ ZPT macros:
>>> len(cssMacros) >>> len(cssMacros)
4 4
>>> m1 = cssMacros[0] >>> m1 = cssMacros[0]
>>> print m1.name, m1.media, m1.resourceName >>> print(m1.name, m1.media, m1.resourceName)
css all zope3_tablelayout.css css all zope3_tablelayout.css
Calling a macro provided by Controller.macros[] returns the real ZPT macro: Calling a macro provided by Controller.macros[] returns the real ZPT macro:
@ -138,7 +140,7 @@ The pre-set collection of macros for a certain slot may be extended
>>> len(controller.macros['css']) >>> len(controller.macros['css'])
5 5
>>> m5 = controller.macros['css'][4] >>> m5 = controller.macros['css'][4]
>>> print m5.name, m5.media, m5.resourceName >>> print(m5.name, m5.media, m5.resourceName)
css all node.css css all node.css
If an identifier is given (the second parameter) a certain macro is only If an identifier is given (the second parameter) a certain macro is only
@ -221,7 +223,7 @@ controller issues a redirect.
>>> from cybertools.browser.form import IFormController, FormController >>> from cybertools.browser.form import IFormController, FormController
>>> class MyController(FormController): >>> class MyController(FormController):
... def update(self): ... def update(self):
... print 'updating...' ... print('updating...')
... return True ... return True
>>> component.provideAdapter(MyController, (View, IBrowserRequest), >>> component.provideAdapter(MyController, (View, IBrowserRequest),

View file

@ -1,31 +1,12 @@
# # cybertools.browser.action
# 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
#
""" """ Base classes (sort of views) for action portlet items.
Base classes (sort of views) for action portlet items.
$Id$
""" """
from copy import copy from copy import copy
from urllib import urlencode from urllib.parse import urlencode
from zope import component from zope import component
from zope.app.pagetemplate import ViewPageTemplateFile from zope.browserpage import ViewPageTemplateFile
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
action_macros = ViewPageTemplateFile('action_macros.pt') action_macros = ViewPageTemplateFile('action_macros.pt')

View file

Before

Width:  |  Height:  |  Size: 655 B

After

Width:  |  Height:  |  Size: 655 B

View file

Before

Width:  |  Height:  |  Size: 455 B

After

Width:  |  Height:  |  Size: 455 B

View file

Before

Width:  |  Height:  |  Size: 537 B

After

Width:  |  Height:  |  Size: 537 B

View file

Before

Width:  |  Height:  |  Size: 777 B

After

Width:  |  Height:  |  Size: 777 B

View file

Before

Width:  |  Height:  |  Size: 641 B

After

Width:  |  Height:  |  Size: 641 B

View file

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View file

Before

Width:  |  Height:  |  Size: 691 B

After

Width:  |  Height:  |  Size: 691 B

View file

Before

Width:  |  Height:  |  Size: 741 B

After

Width:  |  Height:  |  Size: 741 B

View file

Before

Width:  |  Height:  |  Size: 591 B

After

Width:  |  Height:  |  Size: 591 B

View file

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View file

Before

Width:  |  Height:  |  Size: 663 B

After

Width:  |  Height:  |  Size: 663 B

View file

Before

Width:  |  Height:  |  Size: 195 B

After

Width:  |  Height:  |  Size: 195 B

View file

Before

Width:  |  Height:  |  Size: 103 B

After

Width:  |  Height:  |  Size: 103 B

View file

@ -1,32 +1,13 @@
# # cybertools.browser.configurator
# 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
#
""" """ A view configurator provides configuration data for a view controller.
A view configurator provides configuration data for a view controller.
$Id$
""" """
from zope import component from zope import component
from zope.annotation.interfaces import IAttributeAnnotatable, IAnnotations from zope.annotation.interfaces import IAttributeAnnotatable, IAnnotations
from zope.annotation.attribute import AttributeAnnotations from zope.annotation.attribute import AttributeAnnotations
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.interface import Interface, Attribute, implements from zope.interface import Interface, Attribute, implementer
# interfaces # interfaces
@ -63,12 +44,11 @@ class IMacroViewProperty(IViewProperty):
#default implementations #default implementations
@implementer(IViewConfigurator)
class ViewConfigurator(object): class ViewConfigurator(object):
""" An base class for adapters that allow the registration of view properties. """ An base class for adapters that allow the registration of view properties.
""" """
implements(IViewConfigurator)
def __init__(self, context, request): def __init__(self, context, request):
self.context = context self.context = context
self.request = request self.request = request
@ -109,10 +89,9 @@ class AnnotationViewConfigurator(ViewConfigurator):
return vp return vp
@implementer(IViewProperty)
class ViewProperty(object): class ViewProperty(object):
implements(IViewProperty)
def __init__(self, context, request): def __init__(self, context, request):
self.context = context self.context = context
self.request = request self.request = request
@ -128,10 +107,9 @@ class ViewProperty(object):
self.params = params self.params = params
@implementer(IMacroViewProperty)
class MacroViewProperty(ViewProperty): class MacroViewProperty(ViewProperty):
implements(IMacroViewProperty)
template = None template = None
def setParams(self, params): def setParams(self, params):

View file

@ -1,27 +1,10 @@
# # cybertools.browser.controller
# 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
#
""" """ Controller for views, templates, macros.
Controller for views, templates, macros.
""" """
from zope import component from zope import component
from zope.app.pagetemplate import ViewPageTemplateFile from zope.browserpage import ViewPageTemplateFile
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from cybertools.browser.configurator import IViewConfigurator, IMacroViewProperty from cybertools.browser.configurator import IViewConfigurator, IMacroViewProperty

View file

@ -0,0 +1,29 @@
# cybertools.browser.form
"""Form Controller stuff: form processing is the part of the
model/view/controller pattern that deals withform input.
"""
from zope.interface import Interface, implementer
class IFormController(Interface):
""" Used as a named adapter by GenericView for processing form input.
"""
def update():
""" Processing form input...
"""
@implementer(IFormController)
class FormController(object):
def __init__(self, context, request):
self.view = self.__parent__ = view = context
self.context = view.context # the controller is adapted to a view
self.request = request
def update(self):
pass

View file

Before

Width:  |  Height:  |  Size: 703 B

After

Width:  |  Height:  |  Size: 703 B

View file

Before

Width:  |  Height:  |  Size: 345 B

After

Width:  |  Height:  |  Size: 345 B

View file

Before

Width:  |  Height:  |  Size: 349 B

After

Width:  |  Height:  |  Size: 349 B

View file

Before

Width:  |  Height:  |  Size: 372 B

After

Width:  |  Height:  |  Size: 372 B

View file

Before

Width:  |  Height:  |  Size: 52 B

After

Width:  |  Height:  |  Size: 52 B

View file

Before

Width:  |  Height:  |  Size: 52 B

After

Width:  |  Height:  |  Size: 52 B

View file

Before

Width:  |  Height:  |  Size: 702 B

After

Width:  |  Height:  |  Size: 702 B

View file

Before

Width:  |  Height:  |  Size: 680 B

After

Width:  |  Height:  |  Size: 680 B

View file

Before

Width:  |  Height:  |  Size: 792 B

After

Width:  |  Height:  |  Size: 792 B

View file

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View file

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

Before

Width:  |  Height:  |  Size: 641 B

After

Width:  |  Height:  |  Size: 641 B

View file

Before

Width:  |  Height:  |  Size: 756 B

After

Width:  |  Height:  |  Size: 756 B

View file

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

Before

Width:  |  Height:  |  Size: 817 B

After

Width:  |  Height:  |  Size: 817 B

Some files were not shown because too many files have changed in this diff Show more