Compare commits
No commits in common. "3master" and "bbmaster2" have entirely different histories.
3
.gitignore
vendored
|
@ -1,9 +1,8 @@
|
|||
*.pyc
|
||||
*.pyo
|
||||
*/ajax/dojo/dojo*
|
||||
ajax/dojo/*
|
||||
build/
|
||||
dist/
|
||||
*.swp
|
||||
*.egg-info
|
||||
*.project
|
||||
*.pydevproject
|
||||
|
|
21
LICENSE
|
@ -1,21 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 2023 cyberconcepts.org team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -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 zope.browserpage import ViewPageTemplateFile
|
||||
from cStringIO import StringIO
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
|
||||
from cybertools.browser.renderer import RendererFactory
|
|
@ -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.state import State, Transition
|
||||
|
||||
|
||||
@implementer(ISynapsis)
|
||||
class Synapsis(object):
|
||||
""" A synapsis connects two neurons.
|
||||
"""
|
||||
|
||||
implements(ISynapsis)
|
||||
|
||||
def __init__(self, sender, receiver):
|
||||
self.sender = sender
|
||||
sender.receivers.append(self)
|
||||
|
@ -26,9 +46,10 @@ class Synapsis(object):
|
|||
receiver.notify(session)
|
||||
|
||||
|
||||
@implementer(INeuron)
|
||||
class Neuron(object):
|
||||
|
||||
implements(INeuron)
|
||||
|
||||
def __init__(self):
|
||||
self.senders = []
|
||||
self.receivers = []
|
41
brain/session.py
Normal 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
|
@ -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)
|
||||
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
# cybertools.brain.tests
|
||||
# $Id$
|
||||
|
||||
import unittest, doctest
|
||||
from zope.testing.doctestunit import DocFileSuite
|
||||
from zope.interface.verify import verifyClass
|
||||
|
||||
from cybertools.brain.interfaces import INeuron, ISynapsis
|
||||
|
@ -19,8 +20,9 @@ class TestBrain(unittest.TestCase):
|
|||
def test_suite():
|
||||
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
|
||||
return unittest.TestSuite((
|
||||
unittest.TestLoader().loadTestsFromTestCase(TestBrain),
|
||||
doctest.DocFileSuite('README.txt', optionflags=flags,),
|
||||
unittest.makeSuite(TestBrain),
|
||||
DocFileSuite('README.txt',
|
||||
optionflags=flags,),
|
||||
))
|
||||
|
||||
if __name__ == '__main__':
|
|
@ -3,7 +3,7 @@ Browser View Tools
|
|||
==================
|
||||
|
||||
>>> from zope import component, interface
|
||||
>>> from zope.interface import Interface, implementer
|
||||
>>> from zope.interface import Interface, implements
|
||||
>>> 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:
|
||||
|
||||
>>> #@implementer(Interface)
|
||||
>>> class SomeObject(object):
|
||||
... pass
|
||||
>>> SomeObject = implementer(Interface)(SomeObject)
|
||||
... implements(Interface)
|
||||
>>> obj = SomeObject()
|
||||
|
||||
>>> from cybertools.browser.view import GenericView
|
||||
|
@ -124,7 +122,7 @@ ZPT macros:
|
|||
>>> len(cssMacros)
|
||||
4
|
||||
>>> m1 = cssMacros[0]
|
||||
>>> print(m1.name, m1.media, m1.resourceName)
|
||||
>>> print m1.name, m1.media, m1.resourceName
|
||||
css all zope3_tablelayout.css
|
||||
|
||||
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'])
|
||||
5
|
||||
>>> m5 = controller.macros['css'][4]
|
||||
>>> print(m5.name, m5.media, m5.resourceName)
|
||||
>>> print m5.name, m5.media, m5.resourceName
|
||||
css all node.css
|
||||
|
||||
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
|
||||
>>> class MyController(FormController):
|
||||
... def update(self):
|
||||
... print('updating...')
|
||||
... print 'updating...'
|
||||
... return True
|
||||
|
||||
>>> component.provideAdapter(MyController, (View, IBrowserRequest),
|
|
@ -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 urllib.parse import urlencode
|
||||
from urllib import urlencode
|
||||
from zope import component
|
||||
from zope.browserpage import ViewPageTemplateFile
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
|
||||
action_macros = ViewPageTemplateFile('action_macros.pt')
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
Before Width: | Height: | Size: 455 B After Width: | Height: | Size: 455 B |
Before Width: | Height: | Size: 537 B After Width: | Height: | Size: 537 B |
Before Width: | Height: | Size: 777 B After Width: | Height: | Size: 777 B |
Before Width: | Height: | Size: 641 B After Width: | Height: | Size: 641 B |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 691 B After Width: | Height: | Size: 691 B |
Before Width: | Height: | Size: 741 B After Width: | Height: | Size: 741 B |
Before Width: | Height: | Size: 591 B After Width: | Height: | Size: 591 B |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 663 B After Width: | Height: | Size: 663 B |
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 195 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 103 B |
|
@ -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.annotation.interfaces import IAttributeAnnotatable, IAnnotations
|
||||
from zope.annotation.attribute import AttributeAnnotations
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
from zope.interface import Interface, Attribute, implementer
|
||||
from zope.interface import Interface, Attribute, implements
|
||||
|
||||
|
||||
# interfaces
|
||||
|
@ -44,11 +63,12 @@ class IMacroViewProperty(IViewProperty):
|
|||
|
||||
#default implementations
|
||||
|
||||
@implementer(IViewConfigurator)
|
||||
class ViewConfigurator(object):
|
||||
""" An base class for adapters that allow the registration of view properties.
|
||||
"""
|
||||
|
||||
implements(IViewConfigurator)
|
||||
|
||||
def __init__(self, context, request):
|
||||
self.context = context
|
||||
self.request = request
|
||||
|
@ -89,9 +109,10 @@ class AnnotationViewConfigurator(ViewConfigurator):
|
|||
return vp
|
||||
|
||||
|
||||
@implementer(IViewProperty)
|
||||
class ViewProperty(object):
|
||||
|
||||
implements(IViewProperty)
|
||||
|
||||
def __init__(self, context, request):
|
||||
self.context = context
|
||||
self.request = request
|
||||
|
@ -107,9 +128,10 @@ class ViewProperty(object):
|
|||
self.params = params
|
||||
|
||||
|
||||
@implementer(IMacroViewProperty)
|
||||
class MacroViewProperty(ViewProperty):
|
||||
|
||||
implements(IMacroViewProperty)
|
||||
|
||||
template = None
|
||||
|
||||
def setParams(self, params):
|
|
@ -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.browserpage import ViewPageTemplateFile
|
||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
|
||||
from cybertools.browser.configurator import IViewConfigurator, IMacroViewProperty
|
48
browser/form.py
Normal 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
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
# $Id$
|
||||
|
||||
import unittest, doctest
|
||||
from zope.testing.doctestunit import DocFileSuite
|
||||
from zope.app.testing.functional import FunctionalDocFileSuite
|
||||
|
||||
|
Before Width: | Height: | Size: 703 B After Width: | Height: | Size: 703 B |
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 345 B |
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 349 B |
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 52 B After Width: | Height: | Size: 52 B |
Before Width: | Height: | Size: 52 B After Width: | Height: | Size: 52 B |
Before Width: | Height: | Size: 702 B After Width: | Height: | Size: 702 B |
Before Width: | Height: | Size: 680 B After Width: | Height: | Size: 680 B |
Before Width: | Height: | Size: 792 B After Width: | Height: | Size: 792 B |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 641 B After Width: | Height: | Size: 641 B |
Before Width: | Height: | Size: 756 B After Width: | Height: | Size: 756 B |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 817 B After Width: | Height: | Size: 817 B |
Before Width: | Height: | Size: 685 B After Width: | Height: | Size: 685 B |
Before Width: | Height: | Size: 777 B After Width: | Height: | Size: 777 B |
Before Width: | Height: | Size: 753 B After Width: | Height: | Size: 753 B |
Before Width: | Height: | Size: 778 B After Width: | Height: | Size: 778 B |
Before Width: | Height: | Size: 848 B After Width: | Height: | Size: 848 B |
Before Width: | Height: | Size: 840 B After Width: | Height: | Size: 840 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 493 B After Width: | Height: | Size: 493 B |
Before Width: | Height: | Size: 780 B After Width: | Height: | Size: 780 B |
Before Width: | Height: | Size: 807 B After Width: | Height: | Size: 807 B |
Before Width: | Height: | Size: 784 B After Width: | Height: | Size: 784 B |
Before Width: | Height: | Size: 856 B After Width: | Height: | Size: 856 B |