From b79666d1b54d55f4324d88495bc84cd8ae352747 Mon Sep 17 00:00:00 2001 From: helmutm Date: Wed, 10 May 2006 18:44:34 +0000 Subject: [PATCH] work-in-progress: loops.organize: type 'person' implemented git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1207 fd906abe-77d9-0310-91a1-e0d9ade77398 --- browser/concept_resources.pt | 4 +-- browser/configure.zcml | 2 +- configure.zcml | 2 +- organize/__init__.py | 4 +++ organize/configure.zcml | 21 +++++++++++ organize/party.py | 69 ++++++++++++++++++++++++++++++++++++ organize/tests.py | 25 +++++++++++++ 7 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 organize/__init__.py create mode 100644 organize/configure.zcml create mode 100644 organize/party.py create mode 100755 organize/tests.py diff --git a/browser/concept_resources.pt b/browser/concept_resources.pt index 734fa2c..8c46029 100644 --- a/browser/concept_resources.pt +++ b/browser/concept_resources.pt @@ -9,13 +9,13 @@
- +
diff --git a/configure.zcml b/configure.zcml index d0b70a4..f46b0b9 100644 --- a/configure.zcml +++ b/configure.zcml @@ -306,7 +306,7 @@ name="loops.PredicateSource" /> - + diff --git a/organize/__init__.py b/organize/__init__.py new file mode 100644 index 0000000..4bc90fb --- /dev/null +++ b/organize/__init__.py @@ -0,0 +1,4 @@ +""" +$Id$ +""" + diff --git a/organize/configure.zcml b/organize/configure.zcml new file mode 100644 index 0000000..34f2d7d --- /dev/null +++ b/organize/configure.zcml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + diff --git a/organize/party.py b/organize/party.py new file mode 100644 index 0000000..348b557 --- /dev/null +++ b/organize/party.py @@ -0,0 +1,69 @@ +# +# 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 +# + +""" +Adapters for IConcept providing interfaces from the cybertools.organize package. + +$Id$ +""" + +from zope.app import zapi +from zope.component import adapts +from zope.interface import implements +from zope.cachedescriptors.property import Lazy +from zope.security.proxy import removeSecurityProxy + +from cybertools.organize.interfaces import IPerson +from loops.interfaces import IConcept +from loops.type import TypeInterfaceSourceList + + +TypeInterfaceSourceList.typeInterfaces += (IPerson,) + + +class Person(object): + """ typeInterface adapter for concepts of type 'person'. + """ + + implements(IPerson) + adapts(IConcept) + + def __init__(self, context): + self.context = context + self.__parent__ = context # to get the permission stuff right + + def getFirstName(self): + return getattr(self.context, '_firstName', u'') + def setFirstName(self, firstName): + self.context._firstName = firstName + firstName = property(getFirstName, setFirstName) + + def getLastName(self): + return getattr(self.context, '_lastName', u'') + def setLastName(self, lastName): + self.context._lastName = lastName + lastName = property(getLastName, setLastName) + + def getBirthDate(self): + return getattr(self.context, '_birthDate', u'') + def setBirthDate(self, birthDate): + self.context._birthDate = birthDate + birthDate = property(getBirthDate, setBirthDate) + + + diff --git a/organize/tests.py b/organize/tests.py new file mode 100755 index 0000000..63413f5 --- /dev/null +++ b/organize/tests.py @@ -0,0 +1,25 @@ +# $Id$ + +import unittest, doctest +from zope.testing.doctestunit import DocFileSuite +from zope.app.testing import ztapi +from zope.interface.verify import verifyClass +from loops.organize.party import Person + +class Test(unittest.TestCase): + "Basic tests for the organize sub-package." + + def testSomethin(self): + pass + + +def test_suite(): + flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS + return unittest.TestSuite(( + unittest.makeSuite(Test), + #DocFileSuite('../README.txt', optionflags=flags), + #DocFileSuite('../helpers.txt', optionflags=flags), + )) + +if __name__ == '__main__': + unittest.main(defaultTest='test_suite')