Questions tagged [zope.interface]

The zope.interface module provides an implementation of "object interfaces" for Python.

Interfaces are a mechanism for labeling objects as conforming to a given API or contract. The zope.interface package can be considered as an implementation of the Design By Contract methodology in Python.

zope.interface does not depend on the Zope server framework and does not imply using any other part of Zope.

53 questions
36
votes
4 answers

Purpose of Zope Interfaces?

I have started using Zope interfaces in my code, and as of now, they are really only documentation. I use them to specify what attributes the class should possess, explicitly implement them in the appropriate classes and explicitly check for them…
Nikwin
  • 6,576
  • 4
  • 35
  • 43
6
votes
3 answers

Getting py2exe to work with zope.interface

I have a Python app based on Twisted and PyGTK. Twisted itself depends on zope.interface, and I don't import it directly. Unfortunately, when I try to run my app, the following error ends up in the error log: Traceback (most recent call last): …
detly
  • 29,332
  • 18
  • 93
  • 152
5
votes
2 answers

how do I get a list of classes that implement an interface? (zope.interface)

The question says everything. Or am I trying to use zope.interface for the wrong purpose? What I need is basically the One Way To Do It for registering classes that implement a certain functionality (Widgets or Portlets for a CMS). Basically like…
Luiz Geron
  • 1,357
  • 15
  • 22
5
votes
2 answers

Where do I place the .egg (Python)?

I'm trying to install the zope interface script for Python. However, the only download I saw was a .egg file type. I'm running Windows Python 2.7, where should I place this file for the Zope interface to work properly with my Python?
Noah R
  • 5,287
  • 21
  • 56
  • 75
5
votes
2 answers

Import Error in zope.interface.registry in python

I am installing a project in virtual environment. I am getting error from zope.interface.registry import Components Traceback (most recent call last): File "", line 1, in ImportError: No module named registry Version of this…
Netro
  • 7,119
  • 6
  • 40
  • 58
4
votes
0 answers

ABC or zope.interface?

I have this code: class AppInterface(zope.interface.Interface): def required_function(): pass @zope.interface.implementer(AppInterface) class DesktopApp: def other_function(self): print('Who I am') I didn't write the…
Hahan't
  • 481
  • 1
  • 4
  • 11
4
votes
1 answer

Why do I get "ImportError: Twisted requires zope.interface 3.6.0 or later." when running stratum mining proxy?

The entire return when running "sudo python ./mining_proxy.py" is: Traceback (most recent call last): File "./mining_proxy.py", line 67, in from twisted.internet import reactor, defer File…
ProGirlXOXO
  • 2,170
  • 6
  • 25
  • 47
4
votes
2 answers

How to dynamically add attributes to an interface

I need to add an attribute for every attribute in an interface. So I am trying to dynamically modify it to add them, but not with much success for now. Let's say I have the following interface: class IMember(Interface): first_name =…
Gagaro
  • 752
  • 7
  • 17
3
votes
2 answers

Defining circular references using zope.schema

I'm trying to do the following, define two classes whose instances mutually reference one another, like Users and Groups in the following exemple. A User can belong to several groups and a Group can contains several users. The actual data is stored…
kriss
  • 23,497
  • 17
  • 97
  • 116
3
votes
3 answers

Specify DateTime format on zope.schema.Date on Plone

I'm working on a form with Formlib that looks like this: from zope.schema import Choice, Float, Int, Date, TextLine from Products.Five.formlib.formbase import PageForm class ISimuladorForm(Interface): """ Zope Interface for the financial…
Noe Nieto
  • 2,521
  • 2
  • 17
  • 25
3
votes
1 answer

Error when try to register implementer of zope.interface

I have next class: @implementer(ISocial) class SocialVKSelenium: pass And when I add it to zope registry: gsm = getGlobalSiteManager() gsm.registerAdapter(SocialVKSelenium) I got: TypeError: The adapter factory doesn't have a…
eirenikos
  • 2,296
  • 25
  • 25
3
votes
2 answers

How does the function that is called inside the class declaration?

Have this code: >>> class Foo: ... zope.interface.implements(IFoo) ... ... def __init__(self, x=None): ... self.x = x ... ... def bar(self, q, r=None): ... return q, r, self.x ... ... def __repr__(self): ... …
defuz
  • 26,721
  • 10
  • 38
  • 60
2
votes
1 answer

Does a Zope Component Architecture component need to state the interfaces it implements?

Note: I am new to ZCA, so the code may be incorrect; however, I am somewhat familiar with the way ZCA works. Given for example: class I1(Interface): def c1(): pass class U1(object): implements(I1) #is this necessary? def c1(): …
Abbafei
  • 3,088
  • 3
  • 27
  • 24
2
votes
1 answer

Is the 'zope' package widely used?

I want to implement my project using interface oriented programming. Since Python itself does not have native support to the Interface keyword, I am planning to leverage the zope.* package. But the zope.component package is really a huge package…
David S.
  • 10,578
  • 12
  • 62
  • 104
2
votes
0 answers

Python3.8 typing Protocol: Anything standard for adapter registries?

The zope.interface has (among many other things) run-time adapter registries, which allow to find suitable implementations of some interface at run-time. Now, the python3.8 has structural subtyping support, but the question is: Are there any…
Roman Susi
  • 4,135
  • 2
  • 32
  • 47
1
2 3 4