| 1 |
############################################################################## |
|---|
| 2 |
# |
|---|
| 3 |
# Copyright (c) 2005-2006 Nuxeo and Contributors. |
|---|
| 4 |
# All Rights Reserved. |
|---|
| 5 |
# |
|---|
| 6 |
# This software is subject to the provisions of the Zope Public License, |
|---|
| 7 |
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
|---|
| 8 |
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
|---|
| 9 |
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|---|
| 10 |
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
|---|
| 11 |
# FOR A PARTICULAR PURPOSE. |
|---|
| 12 |
# |
|---|
| 13 |
############################################################################## |
|---|
| 14 |
""" |
|---|
| 15 |
|
|---|
| 16 |
$Id$ |
|---|
| 17 |
""" |
|---|
| 18 |
__docformat__ = "reStructuredText" |
|---|
| 19 |
|
|---|
| 20 |
from zope.interface import implements |
|---|
| 21 |
from zope.schema.interfaces import IField |
|---|
| 22 |
from zope.schema import Choice |
|---|
| 23 |
|
|---|
| 24 |
class IIntCoupleChoice(IField): |
|---|
| 25 |
"""A choice field containing couples of integers e.g. (0, 1)""" |
|---|
| 26 |
|
|---|
| 27 |
class IntCoupleChoice(Choice): |
|---|
| 28 |
implements(IIntCoupleChoice) |
|---|
| 29 |
|
|---|
| 30 |
def fromUnicode(self, text): |
|---|
| 31 |
self.validate(text) |
|---|
| 32 |
a, b = text[1:-1].split(u', ') |
|---|
| 33 |
return (int(a), int(b)) |
|---|
| 34 |
|
|---|
| 35 |
def validate(self, value): |
|---|
| 36 |
# FIXME |
|---|
| 37 |
return True |
|---|
| 38 |
|
|---|