zeam.component is inspired by zope.component and grokcore.component, but stays much simpler, and have less base concepts. Hopefully this improve flexibility.
Registration
A base class can be used to register a component, zeam.component.Component. It supports all the directives grok.context, grok.adapts, grok.provides and grok.name like they are defined in Grok. You can use those to register your component as either an Utility, an (named) Adapter or a (named) MultiAdapter.
An another possibility to register a component is to use the component decorator, zeam.component.component. It takes as arguments the interfaces that the component adapts, and as keyword arguments, provides the Interface that the component provides, and as name the name under which it will be registered.
Lookup
You can lookup a specific registered component with zeam.component.getComponent. You can optionally provide:
specs: a tuple of objects or specifications that the component must adapt in order to be returned.
provided: an Interface that the component must provides in order to be returned.
name: a name under which the component must be registered in order to be returned.
default: a default value that will be returned if no component match the requirements. If you no default value is provided, and no component is found, an exception will be triggered.
You can lookup a list of possible registered component with zeam.component.getAllComponents. You can optionally provide:
specs: tuple of objects or specification stat the component must adapt in order to be returned.
provided: an Interface that the component must provides in order to be returned.
Please note that in both cases the component is directly returned. In any case, no construction is done with the result of the lookup.
An helper zeam.component.getWrapper that support the same options than the zeam.component.getComponent function will call the result of the lookup passing as argument the values given as specs to it. This is used in order to have a getAdapter or queryAdapter like behavior. Please note that if an error happens during the initialization of the component, the error won’t be catched for you.
Changes
1.0 (2012/09/03)
Initial release.
Metadata
Release files for zeam.component 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zeam.component-1.0.tar.gz | 4.4 kB | Without provenance | Details for zeam.component-1.0.tar.gz |
Release files / zeam.component-1.0.tar.gz
| Download URL | zeam.component-1.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3580593c782ba74fe5d90d1cd3f5c40c998bb45b849c1d4b58f5918dded3b833
|
|
BLAKE2b-256 checksum How to use checksums |
f35d76217dfb9499fe2a4289f8df82af072d660e8cc7427d57bda703b06d3c73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for zeam.component 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.