Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
a7b9e4cf
Commit
a7b9e4cf
authored
Jul 08, 2005
by
Philipp von Weitershausen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stab at making this work:
>>> fromZ3Interface(x) is fromZ3Interface(x) True
parent
452a9b45
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
lib/python/Interface/bridge.py
lib/python/Interface/bridge.py
+13
-16
No files found.
lib/python/Interface/bridge.py
View file @
a7b9e4cf
...
...
@@ -14,7 +14,6 @@
$Id$
"""
from
Interface._InterfaceClass
import
Interface
as
Z2_InterfaceClass
from
Interface
import
Interface
as
Z2_Interface
from
Interface
import
Attribute
as
Z2_Attribute
...
...
@@ -25,9 +24,9 @@ from zope.interface.interface import Interface as Z3_Interface
from
zope.interface.interface
import
Attribute
as
Z3_Attribute
from
zope.interface.interface
import
Method
as
Z3_Method
_bridges
=
{
Z3_interface
:
Z2_Interface
}
def
fromZ3Interface
(
z3i
):
""" Return a Zope 2 interface corresponding to 'z3i'.
o 'z3i' must be a Zope 3 interface.
...
...
@@ -35,36 +34,35 @@ def fromZ3Interface(z3i):
if
not
isinstance
(
z3i
,
Z3_InterfaceClass
):
raise
ValueError
,
'Not a Zope 3 interface!'
if
z3i
i
s
Z3_Interface
:
# special case; root in new hierarchy!
return
Z2_Interface
if
z3i
i
n
_bridges
:
return
_bridges
[
z3i
]
name
=
z3i
.
getName
()
bases
=
[
fromZ3Interface
(
x
)
for
x
in
z3i
.
getBases
()
]
bases
=
[
fromZ3Interface
(
x
)
for
x
in
z3i
.
getBases
()]
attrs
=
{}
for
k
,
v
in
z3i
.
namesAndDescriptions
():
if
isinstance
(
v
,
Z3_Method
):
v
=
fromZ3Method
(
v
)
elif
isinstance
(
v
,
Z3_Attribute
):
v
=
fromZ3Attribute
(
v
)
#TODO bridge Fields to Attributes?
attrs
[
k
]
=
v
# XXX: Note that we pass the original interface's __module__;
# we may live to regret that.
return
Z2_InterfaceClass
(
name
=
name
,
bases
=
bases
,
attrs
=
attrs
,
__doc__
=
z3i
.
getDoc
(),
__module__
=
z3i
.
__module__
,
)
z2i
=
Z2_InterfaceClass
(
name
=
name
,
bases
=
bases
,
attrs
=
attrs
,
__doc__
=
z3i
.
getDoc
(),
__module__
=
z3i
.
__module__
)
_bridges
[
z3i
]
=
z2i
return
z2i
def
fromZ3Attribute
(
z3a
):
""" Return a Zope 2 interface attribute corresponding to 'z3a'.
o 'z3a' must be a Zope 3 interface attribute.
...
...
@@ -75,7 +73,6 @@ def fromZ3Attribute(z3a):
return
Z2_Attribute
(
z3a
.
getName
(),
z3a
.
getDoc
())
def
fromZ3Method
(
z3m
):
""" Return a Zope 2 interface method corresponding to 'z3a'.
o 'z3a' must be a Zope 3 interface method.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment