interfaces.py
2008-02-28 00:28python # -*- coding: utf-8; ...
#!/usr/bin/env python
# -*- coding: utf-8; -*-
__author__ = 'Gennady Kovalev, 2008'
__copyright__ = '''
Copyright (C) 2007 by Gennady Kovalev. All rights reserved.
Copyright (C) 2007 by BIGUR Company (http://www.bigur.ru/). All rights reserved.
See COPYING file that comes with this distribution.
'''
from zope.interface import Interface
from zope.schema import TextLine, Field
from zope.app.container.constraints import ContainerTypesConstraint
from zope.app.container.interfaces import IContainer, IContained
from zope.app.container.constraints import ItemTypePrecondition
class ISimpleHuman(Interface):
'''This is simple human object'''
first_name = TextLine(
title=u'First name',
description=u'Human\'s first name',
required=True)
last_name = TextLine(
title=u'Last name',
description=u'Human\'s last name',
required=True)
class ISimpleHumanContainer(IContainer):
'''This is a container for simple humans'''
name = TextLine(
title=u'Container\'s name',
description=u'Some text name'
)
def __setitem__(self, obj):
pass
__setitem__.precondition = ItemTypePrecondition(ISimpleHuman)
class ISimpleHumanContained(IContained):
''' A human that can only contained in HumanContainer'''
__parent__ = Field(
constraint = ContainerTypesConstraint(ISimpleHumanContainer))



