Guest User

Untitled

a guest
Jan 29th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from zope.interface import Interface
  3. from zope.interface import implementer
  4. from zope import schema
  5.  
  6.  
  7. class IContainer(Interface):
  8.  
  9.     parent = schema.Object(
  10.         title=u'Parent container',
  11.         schema=IContainer,  # How can I do this, IContainer is not yet defined.
  12.         required=False,
  13.         default=None,
  14.     )
  15.  
  16.  
  17. @implementer(IContainer)
  18. class Container(object):
  19.  
  20.     parent = schema.fieldproperty.FieldProperty(IContainer['parent'])
  21.  
  22.     def __init__(self, parent=None):
  23.         self.parent = parent
  24.  
  25.  
  26. c1 = Container()
  27. c2 = Container(parent=c1)
Add Comment
Please, Sign In to add comment