This repository has been archived by the owner on Apr 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from plone/no-zcml-contenttypes
be able to provide content types and behaviors with decorators
- Loading branch information
Showing
31 changed files
with
647 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Application Configuration | ||
|
||
`plone.server` handles configuration application customizations and extension | ||
mostly with decorators in code. | ||
|
||
This page is meant to be a reference to the available decorators and options | ||
to those decorators. | ||
|
||
|
||
## service | ||
|
||
*`configure.service`* | ||
|
||
* _context_: Content type interface this service is registered against. Example: ISite | ||
* _method_: HTTP method this service works against. Default is `GET` | ||
* _permission_: Permission this service requires. Default is configure default_permission setting | ||
* _layer_: Layer this service is registered for. Default is `IDefaultLayer` | ||
* _name_: This is used as part of the uri. Example `@foobar` -> `/mycontent/@foobar`. Leave empty to be used for base uri of content -> `/mycontent`. | ||
|
||
|
||
## content type | ||
|
||
*`configure.contenttype`* | ||
|
||
* _portal_type_: Name of the content type | ||
* _schema_: Interface schema to use for type | ||
* _add_permission_: Permission required to add content. Defaults to `plone.AddContent` | ||
* _allowed_types_: List of types allowed to be added inside this content assuming it is a Folder type. Defaults to allowing all types. | ||
|
||
|
||
## behavior | ||
|
||
*`configure.behavior`* | ||
|
||
* _title_: Name of behavior | ||
* _provides_: Interface this behavior provides | ||
* _marker_: Marker interface to apply to utilized instance's behavior | ||
* _for__: Content type this behavior is available for | ||
|
||
|
||
## addon | ||
|
||
*`configure.addon`* | ||
|
||
* _name_ | ||
* _title_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Content types | ||
|
||
Content types allow you to provide custom schemas and content to your services. | ||
|
||
OOTB, `plone.server` ships with simple `Folder` and `Item` content types. The | ||
`Folder` type allowing someone to add items inside of it. Both types only have | ||
simple dublin core fields. | ||
|
||
|
||
## Defining content types | ||
|
||
A content type consists of a class and optionally, a schema to define the custom | ||
fields you want your class to use. | ||
|
||
A simple type will look like this:: | ||
|
||
```python | ||
from plone.server import configure | ||
from plone.server.content import Folder | ||
from plone.server.interfaces import IItem | ||
from zope import schema | ||
|
||
class IMySchema(IItem): | ||
foo = schema.Text() | ||
|
||
@configure.contenttype( | ||
portal_type="MyType", | ||
schema=IMySchema, | ||
behaviors=["plone.server.behaviors.dublincore.IDublinCore"]) | ||
class MyType(Folder): | ||
pass | ||
``` | ||
|
||
This example creates a simple schema and assigns it to the `MyType` content | ||
type. | ||
|
||
|
||
**Scanning** | ||
If your service modules are not imported at run-time, you may need to provide an | ||
additional scan call to get your services noticed by `plone.server`. | ||
|
||
In your application `__init__.py` file, you can simply provide a `scan` call. | ||
|
||
```python | ||
from plone.server import configure | ||
|
||
def includeme(root): | ||
configure.scan('my.package.content') | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.