Compare commits

..

No commits in common. "3master" and "2master" have entirely different histories.

667 changed files with 7086 additions and 2015 deletions

2
.gitignore vendored
View file

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

View file

@ -1,10 +1,28 @@
# 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.
""" Embed Dojo using the cybertools.composer.layout procedure. $Id$
""" """
from io import StringIO from cStringIO import StringIO
from zope.browserpage import ViewPageTemplateFile from zope.app.pagetemplate 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,18 +1,38 @@
# 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 implementer from zope.interface import implements
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)
@ -26,9 +46,10 @@ 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 = []

41
brain/session.py Normal file
View file

@ -0,0 +1,41 @@
#
# 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)

55
brain/state.py Normal file
View file

@ -0,0 +1,55 @@
#
# 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,4 +1,3 @@
# cybertools.brain.tests
import unittest, doctest import unittest, doctest
from zope.interface.verify import verifyClass from zope.interface.verify import verifyClass
@ -19,8 +18,9 @@ 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.TestLoader().loadTestsFromTestCase(TestBrain), unittest.makeSuite(TestBrain),
doctest.DocFileSuite('README.txt', optionflags=flags,), doctest.DocFileSuite('README.txt',
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, implementer >>> from zope.interface import Interface, implements
>>> from zope.publisher.interfaces.browser import IBrowserRequest >>> from zope.publisher.interfaces.browser import IBrowserRequest
@ -17,10 +17,8 @@ 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):
... pass ... implements(Interface)
>>> SomeObject = implementer(Interface)(SomeObject)
>>> obj = SomeObject() >>> obj = SomeObject()
>>> from cybertools.browser.view import GenericView >>> from cybertools.browser.view import GenericView
@ -124,7 +122,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:
@ -140,7 +138,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
@ -223,7 +221,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,12 +1,31 @@
# 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.parse import urlencode from urllib import urlencode
from zope import component from zope import component
from zope.browserpage import ViewPageTemplateFile from zope.app.pagetemplate 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,13 +1,32 @@
# 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, implementer from zope.interface import Interface, Attribute, implements
# interfaces # interfaces
@ -44,11 +63,12 @@ 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
@ -89,9 +109,10 @@ 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
@ -107,9 +128,10 @@ 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,10 +1,27 @@
# 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.browserpage import ViewPageTemplateFile from zope.app.pagetemplate 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

48
browser/form.py Normal file
View file

@ -0,0 +1,48 @@
#
# 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

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

View file

Before

Width:  |  Height:  |  Size: 685 B

After

Width:  |  Height:  |  Size: 685 B

View file

Before

Width:  |  Height:  |  Size: 777 B

After

Width:  |  Height:  |  Size: 777 B

View file

Before

Width:  |  Height:  |  Size: 753 B

After

Width:  |  Height:  |  Size: 753 B

View file

Before

Width:  |  Height:  |  Size: 778 B

After

Width:  |  Height:  |  Size: 778 B

View file

Before

Width:  |  Height:  |  Size: 848 B

After

Width:  |  Height:  |  Size: 848 B

View file

Before

Width:  |  Height:  |  Size: 840 B

After

Width:  |  Height:  |  Size: 840 B

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 493 B

After

Width:  |  Height:  |  Size: 493 B

View file

Before

Width:  |  Height:  |  Size: 780 B

After

Width:  |  Height:  |  Size: 780 B

View file

Before

Width:  |  Height:  |  Size: 807 B

After

Width:  |  Height:  |  Size: 807 B

View file

Before

Width:  |  Height:  |  Size: 784 B

After

Width:  |  Height:  |  Size: 784 B

View file

Before

Width:  |  Height:  |  Size: 856 B

After

Width:  |  Height:  |  Size: 856 B

View file

Before

Width:  |  Height:  |  Size: 783 B

After

Width:  |  Height:  |  Size: 783 B

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