Questions tagged [zope.component]

The zope.component package implements the core functionality of the Zope Component Architecture (ZCA).

The Zope Component Architecture lets you register and retrieve independent components, that together make a flexible component-based system.

Components are reusable Python objects with introspectable interfaces (implemented using ). Using zope.component lets you define utilities, adapters and subscribers, which together let you build large-scale Python software while decoupling disparate parts and implementations.

See A Comprehensive Guide to Zope Component Architecture for more details.

19 questions
11
votes
3 answers

Mocking ImportError in Python

I'm trying this for almost two hours now, without any luck. I have a module that looks like this: try: from zope.component import queryUtility # and things like this except ImportError: # do some fallback operations <-- how to test…
Attila O.
  • 15,659
  • 11
  • 54
  • 84
3
votes
2 answers

Python, Zope Component Architecture, Registering an adapter

In a stand-alone python application I use zope.interface, zope.component packages to register and access application's adapters. I thought I could use metaclass concept to register adapters from inside init method of the metaclass. This would…
Alex Kotliarov
  • 183
  • 1
  • 6
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

Create a reusable component with ZCA and SQLAlchemy

Actually i'm designing a large application for desktop with python 3.4. I choosed the Port and Adapter architecture as know as Hexagonal architecture. The main purpose it to work with reusable component. To organize the code and put some rules we…
PyNico
  • 695
  • 5
  • 21
2
votes
1 answer

Manipulating cookies after sending response on Plone 4.3

I need to change data stored inside cookies, or set new cookies when a user access a Plone URL. The official Plone documentation contains exactly what I need in the Modifying HTTP response cookies section. Unluckily it seems to be a deprecated…
keul
  • 7,673
  • 20
  • 45
2
votes
1 answer

How to get "cast like" adaption to work with pure zope.interface?

I would like to get the "C++ cast like" adaption to work with the code from zope.interface. In my real use case, I'm using a registry from Pyramid but it derives from zope.interface.registry.Components, which according to the changes.txt was…
Achim
  • 15,415
  • 15
  • 80
  • 144
2
votes
2 answers

What is the difference between a Zope utility defined with a factory versus a component?

It's a little confusing that ZCML registrations for Zope utilities can accept a component or a factory. versus What is the difference?
joeforker
  • 40,459
  • 37
  • 151
  • 246
2
votes
1 answer

Issue with zope.component subscriber adapters adapting multiple objects

Given the following code: from zope.component import getGlobalSiteManager, adapts, subscribers from zope.interface import Interface, implements class A(object): pass class B(object): pass class C(B): pass class AB(object): …
Ben
  • 2,422
  • 2
  • 16
  • 23
1
vote
1 answer

Providing backward compatibility for a zope component

I'm working on a new release of collective.imagetags in which all the functionality that was carried by a browser view (imagetags-manage) is now moved to a new adapter (not commited yet) which provides almost the same interface that the browser…
marcosfromero
  • 2,853
  • 17
  • 17
1
vote
1 answer

Change Zope2 browser resourceDirectory permission to allow only Authenticated users

I have a browser:resourceDirectory setup in Zope2 and I have: permission="zope2.Public". what should be changed in order to allow only "Authenticated" users access to the resource directory?
userisnew
  • 11
  • 3
1
vote
1 answer

Plone/Zope style view overrides in Pyramid

I have Add-on product defining a view ("my_view") Application using this addon Both application views.py are scanned by configurator during the application startup. My application needs to have a more specific version of my_view, as addon…
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
1
vote
1 answer

zope.annotation example in documentation fails. Help needed to correct it

I am trying to understand Annotations from this document: http://docs.zope.org/zope.annotation/index.html However the example fails when run. I get: Traceback (most recent call last): File "./zopepy", line 366, in
sureshvv
  • 4,234
  • 1
  • 26
  • 32
0
votes
1 answer

In Python Zope, how do I dump the error_log to the browser?

We are a big org and we use Python Zope. We have naturally two versions: prod and dev. In production I understand due to security reasons we should not show error log to end users, but how do I do that for dev? It is very cumbersome to check the…
João Pimentel Ferreira
  • 14,289
  • 10
  • 80
  • 109
0
votes
1 answer

Why is my MultiAdapter failing to register?

I'm currently experimenting with the ZCA and I've run into a bit of a hitch. The script below defines an IFuncttion interface, which is used to create function objects that can be chained (i.e. monads). In this example, I'm trying to create a…
Louis Thibault
  • 20,240
  • 25
  • 83
  • 152
0
votes
2 answers

How to make zope load my ZCML?

When I write some utility, register it and then query with getUtility it works ok: class IOperation(Interface): def __call__(a, b): ''' performs operation on two operands ''' class Plus(object): implements(IOperation) def…
Bunyk
  • 7,635
  • 8
  • 47
  • 79
1
2