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
0e245626
Commit
0e245626
authored
Nov 30, 2000
by
Michel Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new interface methods, refactored base classes
parent
0a504a18
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
24 deletions
+29
-24
lib/python/Interface/iclass.py
lib/python/Interface/iclass.py
+29
-24
No files found.
lib/python/Interface/iclass.py
View file @
0e245626
...
...
@@ -13,10 +13,11 @@ from Method import Method
from
Attr
import
Attribute
from
types
import
FunctionType
,
ClassType
import
Exceptions
from
InterfaceBase
import
InterfaceBase
_typeImplements
=
{}
class
Interface
:
class
Interface
(
InterfaceBase
)
:
"""Prototype (scarecrow) Interfaces Implementation
"""
...
...
@@ -51,29 +52,8 @@ class Interface:
self
.
__attrs
=
attrs
def
deferred
(
self
):
"""Return a defrered class corresponding to the interface
"""
if
hasattr
(
self
,
"_deferred"
):
return
self
.
_deferred
klass
=
{}
exec
"class %s: pass"
%
self
.
__name__
in
klass
klass
=
klass
[
self
.
__name__
]
self
.
__d
(
klass
.
__dict__
)
self
.
_deferred
=
klass
return
klass
def
__d
(
self
,
dict
):
for
k
,
v
in
self
.
__attrs
.
items
():
if
isinstance
(
v
,
Method
)
and
not
dict
.
has_key
(
k
):
dict
[
k
]
=
v
for
b
in
self
.
__bases__
:
b
.
__d
(
dict
)
def
getBases
(
self
):
return
self
.
__bases__
def
extends
(
self
,
other
):
"""Does an interface extend another?
...
...
@@ -139,6 +119,30 @@ class Interface:
"""
return
self
.
__attrs
.
get
(
name
,
default
)
def
deferred
(
self
):
"""Return a defrered class corresponding to the interface
"""
if
hasattr
(
self
,
"_deferred"
):
return
self
.
_deferred
klass
=
{}
exec
"class %s: pass"
%
self
.
__name__
in
klass
klass
=
klass
[
self
.
__name__
]
self
.
__d
(
klass
.
__dict__
)
self
.
_deferred
=
klass
return
klass
def
__d
(
self
,
dict
):
for
k
,
v
in
self
.
__attrs
.
items
():
if
isinstance
(
v
,
Method
)
and
not
dict
.
has_key
(
k
):
dict
[
k
]
=
v
for
b
in
self
.
__bases__
:
b
.
__d
(
dict
)
def
__any
(
self
,
interfaces
):
for
i
in
interfaces
:
if
isinstance
(
i
,
Interface
):
...
...
@@ -150,6 +154,7 @@ class Interface:
def
__repr__
(
self
):
return
"<Interface %s at %x>"
%
(
self
.
__name__
,
id
(
self
))
Base
=
Interface
(
"Interface"
)
class
Named
(
Base
):
...
...
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