| 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.component import getUtilitiesFor |
|---|
| 21 |
from zope.interface import implements, Interface |
|---|
| 22 |
|
|---|
| 23 |
from cpsskins.relations import Predicate, CompoundPredicate, ProxyPredicate |
|---|
| 24 |
|
|---|
| 25 |
# Monadic predicates |
|---|
| 26 |
|
|---|
| 27 |
isDefault = Predicate('_ is default') |
|---|
| 28 |
|
|---|
| 29 |
# Dyadic predicates |
|---|
| 30 |
|
|---|
| 31 |
hasDisplay = Predicate('_ has display _') |
|---|
| 32 |
hasPortlet = Predicate('_ has portlet _') |
|---|
| 33 |
|
|---|
| 34 |
# Triadic predicates |
|---|
| 35 |
|
|---|
| 36 |
hasPortletFromPerspective = Predicate('_ has portlet _ from perspective _') |
|---|
| 37 |
hasDisplayFromPerspective = Predicate('_ has display _ from perspective _') |
|---|
| 38 |
|
|---|
| 39 |
# Compound predicates |
|---|
| 40 |
|
|---|
| 41 |
# Formats |
|---|
| 42 |
|
|---|
| 43 |
class IFormatPredicate(Interface): |
|---|
| 44 |
"""A predicate used by a format""" |
|---|
| 45 |
|
|---|
| 46 |
class FormatPredicate(object): |
|---|
| 47 |
"""A predicate used by a format |
|---|
| 48 |
""" |
|---|
| 49 |
implements(IFormatPredicate) |
|---|
| 50 |
|
|---|
| 51 |
def __init__(self, predicate): |
|---|
| 52 |
self.predicate = predicate |
|---|
| 53 |
|
|---|
| 54 |
def hasFormatProxy(): |
|---|
| 55 |
return CompoundPredicate( |
|---|
| 56 |
tuple([v.predicate for k, v in getUtilitiesFor(IFormatPredicate)] |
|---|
| 57 |
)) |
|---|
| 58 |
|
|---|
| 59 |
hasFormat = ProxyPredicate(hasFormatProxy) |
|---|