Compare commits
	
		
			164 commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| d64dee25f6 | |||
| 350a600ffc | |||
| dc5e1fa251 | |||
| 0e5270f8d5 | |||
| fe632fbeab | |||
| 860d18cae8 | |||
| 569e197609 | |||
| 12978d2389 | |||
| df1229d8fd | |||
| 93a2acf7db | |||
| 25277a0b65 | |||
| aef9ad8cb5 | |||
| 814d7c0762 | |||
| 8a6277fbff | |||
| 2cbd4c11d3 | |||
| 968aeab42a | |||
| f1080df88b | |||
| 33ab512b7f | |||
| 17fbeb2c2c | |||
| 52e3fc72c6 | |||
| db31a73bc9 | |||
| ee82ee7b32 | |||
| 71f36283b9 | |||
| d66aa31058 | |||
| 5f3bd3c04f | |||
| b22dbf879c | |||
| 9fbd97386e | |||
| b8eba239ed | |||
| 61c78fe3e7 | |||
| 3ec90f4b66 | |||
| f9a3326ec7 | |||
| 8037ac38be | |||
| 52990d1df6 | |||
| 8d260908a5 | |||
| b60d6d3b10 | |||
| e98dd2ed34 | |||
| c9220d834d | |||
| 383b77edf1 | |||
| b866ac4267 | |||
| ee9d062833 | |||
| 4b84e816b4 | |||
| 80766f2279 | |||
| 87ca77df45 | |||
| c5fe028756 | |||
| ad632e23ee | |||
| 98ebc30bd5 | |||
| bd631677d6 | |||
| 06682d2a5c | |||
| 35ab24a78a | |||
| a6fb663192 | |||
| 94ce64ef00 | |||
| e5f1be9f91 | |||
| abfd75a782 | |||
| 6a52601060 | |||
| d6666c166f | |||
| 382ffe2e28 | |||
| 6f86e74feb | |||
| 1fb58a7db3 | |||
| fad566b354 | |||
| 43ea46e401 | |||
|   | f5c80948c0 | ||
|   | 88f8b968e6 | ||
|   | 674cd62ae6 | ||
|   | 1629defe3d | ||
|   | bd1aa11beb | ||
|   | 46582b51fe | ||
| 59cd18cc63 | |||
| ab72a31bf0 | |||
| a8565f58c3 | |||
| 51be7dbcbb | |||
| f2eae818db | |||
| 3c8edc3e90 | |||
| b690273bf0 | |||
| 9f1bbb5193 | |||
| 93249faf94 | |||
| bd3d7a0e2f | |||
| 3b53657c5d | |||
| 2e09bb3738 | |||
| 82bc58329b | |||
| d385dc8dea | |||
| c03e47ab3d | |||
| 325f463ce8 | |||
| 9205e8592e | |||
| 170e8f1d4e | |||
| 5aa9869181 | |||
| 4c18a9731c | |||
| 6cff2cc6df | |||
| 1cd5f59738 | |||
| d742b87c9c | |||
| ef05da60e1 | |||
| 0d1a37b5d2 | |||
| 81ae451969 | |||
| 443fee52bb | |||
| 813299d358 | |||
| 34d65623ad | |||
| 043d423a0e | |||
| 8777d1ecdb | |||
| 8166a0e3c3 | |||
| 2a2097fa0d | |||
| 65181d3098 | |||
| 5ab63ee78c | |||
| 99628fedd5 | |||
| 14cfdb7624 | |||
| fcb29171ad | |||
| caee0eccc5 | |||
| 917c2ae579 | |||
| 4690424b1d | |||
|   | fdc9d119ba | ||
|   | e5a09ed436 | ||
| 8eed8f52df | |||
| a6e9a8543c | |||
| 296ce1a3e8 | |||
| 773cf5f5a9 | |||
| c15039b9a7 | |||
| bf290aea2f | |||
| 6b22eb85dd | |||
| 6a356c6f9c | |||
| c5087b764b | |||
| 81d17e8966 | |||
| 620bf6fe25 | |||
| e32c0411d4 | |||
| dfe5aefa69 | |||
| 8824044726 | |||
| df41516015 | |||
| 12a5b339ad | |||
| a83f80a1f9 | |||
| b5b2b0c7b4 | |||
| aa8814b29b | |||
| abdf27372b | |||
| 2c5274e54b | |||
| 08880e3b91 | |||
| 13da77de0a | |||
| 3d3013b76c | |||
| 0aeb854014 | |||
| ba529fad7b | |||
| c9490bb1e9 | |||
| d05b9f7f70 | |||
| 73839ea015 | |||
| 3d8a162ae5 | |||
| 9c5a3ba263 | |||
| bfd628e434 | |||
| 419e899aa4 | |||
| 7b3065439a | |||
| b7efdf6a33 | |||
| 72528a62fc | |||
| 6e1333076b | |||
| 249d507a72 | |||
| 166c74ed31 | |||
| b1c8465219 | |||
| abae2c2bb3 | |||
| b8009b51f8 | |||
| 358545833f | |||
| 0f03b894f4 | |||
| b04daf0c51 | |||
| dc03f4fd00 | |||
| d994b646e9 | |||
| 94463df4d5 | |||
| cacca105ac | |||
| d50b1ca9df | |||
| cc696ee87d | |||
| cb365aaea2 | |||
| 2bc3267e9b | |||
| d4d7a47b09 | |||
| 9977e8b191 | 
							
								
								
									
										6
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						|  | @ -1,6 +1,10 @@ | ||||||
| *.pyc | *.pyc | ||||||
| *.pyo | *.pyo | ||||||
| ajax/dojo/* | */ajax/dojo/dojo* | ||||||
|  | build/ | ||||||
|  | dist/ | ||||||
|  | *.swp | ||||||
|  | *.egg-info | ||||||
| *.project | *.project | ||||||
| *.pydevproject | *.pydevproject | ||||||
| *.sublime-project | *.sublime-project | ||||||
|  |  | ||||||
							
								
								
									
										21
									
								
								LICENSE
									
										
									
									
									
										Normal file
									
								
							
							
						
						|  | @ -0,0 +1,21 @@ | ||||||
|  | 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. | ||||||
							
								
								
									
										14
									
								
								MANIFEST.in
									
										
									
									
									
										Normal file
									
								
							
							
						
						|  | @ -0,0 +1,14 @@ | ||||||
|  | global-include *.cfg | ||||||
|  | global-include *.css *.js | ||||||
|  | global-include *.gif *.jpg *.png | ||||||
|  | global-include *.html | ||||||
|  | global-include *.md *.txt | ||||||
|  | global-include *.mht | ||||||
|  | global-include *.mo *.po *.pot | ||||||
|  | global-include *.pt | ||||||
|  | global-include *.xml | ||||||
|  | global-include *.zcml | ||||||
|  | global-include mime.types | ||||||
|  | 
 | ||||||
|  | graft cybertools/integrator/tests/data | ||||||
|  | graft cybertools/text/testfiles | ||||||
							
								
								
									
										7
									
								
								README.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						|  | @ -0,0 +1,7 @@ | ||||||
|  | # Introduction | ||||||
|  | 
 | ||||||
|  | This is a set of utility libraries to be used mainly | ||||||
|  | with Zope 3 / bluebream and the web application platform | ||||||
|  | *loops*. | ||||||
|  | 
 | ||||||
|  | More information: see https://www.cyberconcepts.org. | ||||||
|  | @ -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) |  | ||||||
| 
 |  | ||||||
|  | @ -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) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|  | @ -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 |  | ||||||
| 
 |  | ||||||
|  | @ -1,38 +0,0 @@ | ||||||
| # |  | ||||||
| #  Copyright (c) 2011 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 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 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) |  | ||||||
|  | @ -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) |  | ||||||
| 
 |  | ||||||
|  | @ -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) |  | ||||||
| 
 |  | ||||||
|  | @ -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 |  | ||||||
|  | @ -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() |  | ||||||
| 
 |  | ||||||
|  | @ -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') |  | ||||||
| 
 |  | ||||||
|  | @ -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) |  | ||||||
| 
 |  | ||||||
|  | @ -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() |  | ||||||
|  | @ -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 |  | ||||||
| 
 |  | ||||||
|  | @ -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'] |  | ||||||
| 
 |  | ||||||
							
								
								
									
										6
									
								
								cybertools/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						|  | @ -0,0 +1,6 @@ | ||||||
|  | # package cybertools | ||||||
|  | 
 | ||||||
|  | # module aliases | ||||||
|  | import sys | ||||||
|  | import doctest | ||||||
|  | sys.modules['zope.testing.doctestunit'] = doctest | ||||||
|  | @ -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 | ||||||
|  | @ -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 = [] | ||||||
							
								
								
									
										21
									
								
								cybertools/brain/session.py
									
										
									
									
									
										Normal 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
									
								
							
							
						
						|  | @ -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) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -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,10 +19,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.makeSuite(TestBrain), |         unittest.TestLoader().loadTestsFromTestCase(TestBrain), | ||||||
|                 doctest.DocFileSuite('README.txt', |         doctest.DocFileSuite('README.txt', optionflags=flags,), | ||||||
|                              optionflags=flags,), |         )) | ||||||
|            )) |  | ||||||
| 
 | 
 | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main(defaultTest='test_suite') |     unittest.main(defaultTest='test_suite') | ||||||
|  | @ -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), | ||||||
|  | @ -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') | ||||||
| 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 | 
|  | @ -9,7 +9,7 @@ | ||||||
|       <div class="top span-6" |       <div class="top span-6" | ||||||
|            metal:define-slot="top"> |            metal:define-slot="top"> | ||||||
|         <a href="#" name="top" metal:define-slot="logo" |         <a href="#" name="top" metal:define-slot="logo" | ||||||
|            tal:attributes="href string:${request/URL/1}"><img class="logo" |            tal:attributes="href string:${view/requestUrl/1}"><img class="logo" | ||||||
|                src="logo.gif" border="0" alt="Home" |                src="logo.gif" border="0" alt="Home" | ||||||
|                tal:attributes="src string:${resourceBase}logo.gif" /></a> |                tal:attributes="src string:${resourceBase}logo.gif" /></a> | ||||||
|         <div metal:define-slot="top-actions"> |         <div metal:define-slot="top-actions"> | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| # | # | ||||||
| #  Copyright (c) 2011 Helmut Merz helmutm@cy55.de | #  Copyright (c) 2014 Helmut Merz helmutm@cy55.de | ||||||
| # | # | ||||||
| #  This program is free software; you can redistribute it and/or modify | #  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 | #  it under the terms of the GNU General Public License as published by | ||||||
|  | @ -37,9 +37,9 @@ class Controller(BaseController): | ||||||
|         macros = self.macros |         macros = self.macros | ||||||
|         presentationMode = self.request.get('liquid.viewmode') == 'presentation' |         presentationMode = self.request.get('liquid.viewmode') == 'presentation' | ||||||
|         params = [('blue/blue8.css', 'all', 20, False), |         params = [('blue/blue8.css', 'all', 20, False), | ||||||
|                   ('print.css', 'print', 25, False), |  | ||||||
|                   ('blue/ie.css', 'all', 30, True), |                   ('blue/ie.css', 'all', 30, True), | ||||||
|                   ('custom.css', 'all', 100, False)] |                   ('custom.css', 'all', 100, False), | ||||||
|  |                   ('print.css', 'print', 200, False),] | ||||||
|         #if presentationMode: |         #if presentationMode: | ||||||
|         #    params.append(('presentation.css', 'all', 30, False)) |         #    params.append(('presentation.css', 'all', 30, False)) | ||||||
|         for id, media, prio, ie in params: |         for id, media, prio, ie in params: | ||||||
| Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 103 B | 
|  | @ -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): | ||||||
|  | @ -1,29 +1,10 @@ | ||||||
| # | # cybertools.browser.controller | ||||||
| #  Copyright (c) 2011 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. |  | ||||||
| 
 |  | ||||||
| $Id$ |  | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
| 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 | ||||||
							
								
								
									
										29
									
								
								cybertools/browser/form.py
									
										
									
									
									
										Normal 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 | ||||||
|  | 
 | ||||||
| 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 |