forked from smcmahon/collective.dexterity_class
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a container type via paster addcontent
- Loading branch information
Showing
5 changed files
with
151 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from five import grok | ||
from plone.directives import dexterity, form | ||
|
||
from zope import schema | ||
|
||
from z3c.form import group, field | ||
from plone.app.z3cform.wysiwyg import WysiwygFieldWidget | ||
|
||
from collective.dexterity_class import MessageFactory as _ | ||
|
||
|
||
# Interface class; used to define content-type schema. | ||
|
||
class IContainerforEverything(form.Schema): | ||
""" | ||
Description of the Example Type | ||
""" | ||
|
||
# If you want a schema-defined interface, delete the form.model | ||
# line below and delete the matching file in the models sub-directory. | ||
# If you want a model-based interface, edit | ||
# models/container_for_everything.xml to define the content type | ||
# and add directives here as necessary. | ||
|
||
form.model("models/container_for_everything.xml") | ||
|
||
|
||
# Custom content-type class; objects created for this content type will | ||
# be instances of this class. Use this class to add content-type specific | ||
# methods and properties. Put methods that are mainly useful for rendering | ||
# in separate view classes. | ||
|
||
class ContainerforEverything(dexterity.Container): | ||
grok.implements(IContainerforEverything) | ||
|
||
# Add your class methods and properties here | ||
|
||
|
||
# View class | ||
# The view will automatically use a similarly named template in | ||
# container_for_everything_templates. | ||
# Template filenames should be all lower case. | ||
# The view will render when you request a content object with this | ||
# interface with "/@@sampleview" appended. | ||
# You may make this the default view for content objects | ||
# of this type by uncommenting the grok.name line below or by | ||
# changing the view class name and template filename to View / view.pt. | ||
|
||
class SampleView(grok.View): | ||
grok.context(IContainerforEverything) | ||
grok.require('zope2.View') | ||
|
||
# grok.name('view) |
34 changes: 34 additions & 0 deletions
34
collective/dexterity_class/container_for_everything_templates/sampleview.pt
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,34 @@ | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" | ||
xmlns:tal="http://xml.zope.org/namespaces/tal" | ||
xmlns:metal="http://xml.zope.org/namespaces/metal" | ||
xmlns:i18n="http://xml.zope.org/namespaces/i18n" | ||
lang="en" | ||
metal:use-macro="context/main_template/macros/master" | ||
i18n:domain="collective.dexterity_class"> | ||
<body> | ||
|
||
<tal:comment tal:condition="nothing"> | ||
This is a sample view template. It will not be used for rendering the | ||
content unless activated by creation of a view class with a matching name. | ||
|
||
Note that we're using Plone 4 macros. Replace them with Plone 3 macros | ||
if needed. | ||
</tal:comment> | ||
|
||
<metal:main fill-slot="content-core"> | ||
<metal:content-core define-macro="content-core"> | ||
|
||
<h2> | ||
Rendered from | ||
container_for_everything_templates/<span tal:replace="template/id" /> | ||
</h2> | ||
|
||
|
||
<div tal:content="context/Title">Title inserted here</div> | ||
|
||
</metal:content-core> | ||
</metal:main> | ||
|
||
</body> | ||
</html> | ||
|
11 changes: 11 additions & 0 deletions
11
collective/dexterity_class/models/container_for_everything.xml
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,11 @@ | ||
<?xml version="1.0" ?> | ||
<model xmlns="http://namespaces.plone.org/supermodel/schema" | ||
xmlns:form="http://namespaces.plone.org/supermodel/form"> | ||
|
||
<schema> | ||
|
||
<!-- field definitions --> | ||
|
||
</schema> | ||
|
||
</model> |
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
52 changes: 52 additions & 0 deletions
52
...terity_class/profiles/default/types/collective.dexterity_class.containerforeverything.xml
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,52 @@ | ||
<?xml version="1.0"?> | ||
<object name="collective.dexterity_class.containerforeverything" | ||
meta_type="Dexterity FTI" | ||
i18n:domain="collective.dexterity_class" xmlns:i18n="http://xml.zope.org/namespaces/i18n"> | ||
|
||
<!-- Basic metadata --> | ||
<property name="title" i18n:translate="">Container for Everything</property> | ||
<property name="description" | ||
i18n:translate="">Description of the Example Type</property> | ||
<property name="icon_expr">string:${portal_url}/folder_icon.png</property> | ||
<property name="factory">collective.dexterity_class.containerforeverything</property> | ||
<property name="global_allow">True</property> | ||
<property name="filter_content_types">False</property> | ||
<property name="allowed_content_types" /> | ||
<property name="allow_discussion">False</property> | ||
|
||
<!-- schema and class used for content items --> | ||
<property name="schema">collective.dexterity_class.container_for_everything.IContainerforEverything</property> | ||
<property name="klass">collective.dexterity_class.container_for_everything.ContainerforEverything</property> | ||
|
||
<property name="behaviors"> | ||
<element value="plone.app.content.interfaces.INameFromTitle" /> | ||
<element value="plone.app.dexterity.behaviors.metadata.IBasic"/> | ||
</property> | ||
|
||
<!-- View information --> | ||
<property name="link_target"></property> | ||
<property name="immediate_view">view</property> | ||
<property name="default_view">view</property> | ||
<property name="view_methods"> | ||
<element value="view"/> | ||
</property> | ||
<property name="default_view_fallback">False</property> | ||
<property name="add_permission">cmf.AddPortalContent</property> | ||
|
||
|
||
<!-- Method aliases --> | ||
<alias from="(Default)" to="(dynamic view)" /> | ||
<alias from="view" to="(selected layout)" /> | ||
<alias from="edit" to="@@edit" /> | ||
<alias from="sharing" to="@@sharing" /> | ||
|
||
<!-- Actions --> | ||
<action title="View" action_id="view" category="object" condition_expr="" | ||
url_expr="string:${object_url}/" visible="True"> | ||
<permission value="View" /> | ||
</action> | ||
<action title="Edit" action_id="edit" category="object" condition_expr="" | ||
url_expr="string:${object_url}/edit" visible="True"> | ||
<permission value="Modify portal content" /> | ||
</action> | ||
</object> |