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
0
votes
2 answers

How to use zope.interface.directlyProvides with instances of build in types (dict, string, ...)

I have a bunch of dictionaries, which I would like to annotate with type information, to be able to later get adapters for them. In the following example, the failing case is what I would like to do and the other case shows a working version. Is it…
Achim
  • 15,415
  • 15
  • 80
  • 144
0
votes
1 answer

Cannot I declare an attribute with type in zope.interface?

I'm using zope.interface module to declare an interface with some methods and attributes. Also, cannot I somehow declare not only the attribute names, but also their types? from zope.interface import Interface, Attribute, implementer, verify class…
Felix
  • 3,351
  • 6
  • 40
  • 68
0
votes
2 answers

Pyinstaller import error: zope.interface not found

I am trying to create standalone exe of twisted application using PyInstaller. Everything is ok, even executable file is getting build, but its not working. I mean if try to execute it gives error 'Import error: Twisted requires zope.interface 3.6.0…
userx
  • 806
  • 1
  • 11
  • 23
0
votes
1 answer

What's the point in registering a Zope component to the GlobalSiteManager?

I'm reading the awesome tutorial about the zope component architecture from: http://www.muthukadan.net/docs/zca.html#adapters I can't seem to understand the Adapters chapter. >>> from zope.interface import implements >>> from zope.component…
Mark
  • 2,137
  • 4
  • 27
  • 42
0
votes
1 answer

Can I adapt strings and built-in types in Z

I have an Interface like: class IRepository(Interface): def __init__(path, **options): pass I have implementations of this interface for both Git, and Mercurial. Now I want to write repository-factory that takes a string (the path) and…
manu
  • 3,544
  • 5
  • 28
  • 50
0
votes
1 answer

Zope component discrepancy between Interface(obj) and getAdapter(obj, Interface)

What could cause Interface(obj) to return obj, while getAdapter(obj, Interface) returns a properly adapted object?
Ben
  • 2,422
  • 2
  • 16
  • 23
0
votes
0 answers

getMultiAdapter fails with ComponentLookupError

I have a code that looks up an iterface with get multi adapter. One of the element's members that get passed to multi adapter is providing that interface but not the element itself. I have no control about what gets passed to multi adapter but I…
Alex Volkov
  • 2,812
  • 23
  • 27
0
votes
1 answer

Querying adapters against plone.directives.form.Schema

I have a form model created as following: from plone.app.directives import Form class IFormSchema(form.Schema): foobar = schema.Bool(title=u"Just another field") I'd like to register an adapter against this…
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
1 2 3
4