zope.interface

Defining circular references using zope.schema

三世轮回 提交于 2019-12-22 09:50:04
问题 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 in a database and there it is a simple matter of many-to-many relationship using foreign keys. No problem at all. Afterward the data is loaded through an ORM and stored in instances of python objects. Still no problem at all as the ORM used

Import Error in zope.interface.registry in python

喜夏-厌秋 提交于 2019-12-10 14:47:42
问题 I am installing a project in virtual environment. I am getting error from zope.interface.registry import Components Traceback (most recent call last): File "<console>", line 1, in <module> ImportError: No module named registry Version of this module as 4.0.5 >>> import pkg_resources >>> pkg_resources.get_distribution("zope.interface").version '4.0.5' I tried the same on my machine (not virtual env), >>> import pkg_resources >>> pkg_resources.get_distribution("zope.interface").version '4.0.1'

Verify that an unknown module/object is obliged to a specific interface (python)

我是研究僧i 提交于 2019-12-08 14:06:47
问题 I'd like to check at runtime, for example, that a given object has methods foo() and bar() . My research system, built in python 3.6, is highly parameterized and can/should accept any kind of object as a replacement of its build in modules. This functionality is very useful because many different students who use this system can easily research different behavior without changing the source code of my system. The problem is that if they built the module wrong, they might discover this only

Defining circular references using zope.schema

给你一囗甜甜゛ 提交于 2019-12-06 04:07:14
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 in a database and there it is a simple matter of many-to-many relationship using foreign keys. No problem at all. Afterward the data is loaded through an ORM and stored in instances of python objects. Still no problem at all as the ORM used (SQLAlchemy) manage backrefs. Now I want to check that the python objects comply to some interface using zope

Getting py2exe to work with zope.interface

泄露秘密 提交于 2019-11-29 04:51:23
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): File "tasks.py", line 4, in <module> File "ui\__init__.pyc", line 14, in <module> File "twisted\python\log.pyc", line 17, in <module> ImportError: No module named zope.interface Traceback (most recent call last): File "tasks.py", line 4, in <module> File "ui\__init__.pyc", line 14, in <module> File "twisted\python\log.pyc", line 17, in <module>

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

会有一股神秘感。 提交于 2019-11-28 05:25:31
问题 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): ... return "Foo(%s)" % self.x Obviously, the call of zope.interface.implements in some way alters the properties and behavior of the class Foo . How does this happen? How do I use this approach in my code? Example code is the part of zope.interface module. 回答1: The detailed "what happens" The

Getting py2exe to work with zope.interface

跟風遠走 提交于 2019-11-27 18:58:37
问题 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): File "tasks.py", line 4, in <module> File "ui\__init__.pyc", line 14, in <module> File "twisted\python\log.pyc", line 17, in <module> ImportError: No module named zope.interface Traceback (most recent call last): File "tasks.py", line 4, in <module>