Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better dexterity content type skeleton #3

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ Changelog
* Mostly derived from zopeskel.dexterity; see that project's repository for
earlier history.
[smcmahon]

* Replaced SampleView with Index view that based on dexterity.DisplayForm and
plone.app.dexterity default view
[izhar]

* Inherit and plonetest's plone4.x.cfg for buildout so that we always use the
latest plone4 buildout.
[izhar]
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,12 @@ class ${interface_name}(form.Schema, IImageScaleTraversable):
form.model("models/${content_class_filename}.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.

#if str($folderish) == 'True'
class ${contenttype_classname}(dexterity.Container):
#else
class ${contenttype_classname}(dexterity.Item):
#end if
grok.implements(${interface_name})

# Add your class methods and properties here


\# View class
\# The view will automatically use a similarly named template in
\# ${content_class_filename}_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):
class Index(dexterity.DisplayForm):
grok.context(${interface_name})
grok.require('zope2.View')

\# grok.name('view')
grok.name('view')
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<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="${package_dotted_name}">
<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">

<tal:block repeat="widget view/widgets/values">
<div class="field" tal:condition="python:widget.__name__ not in ('IBasic.title', 'IBasic.description', 'title', 'description',)">
<label tal:content="widget/label" />
<br />
<div tal:content="structure widget/render" />
</div>
</tal:block>

<fieldset tal:repeat="group view/groups"
tal:attributes="id python:''.join((group.prefix, 'groups.', group.__name__)).replace('.', '-')">
<legend tal:content="group/label" />
<div class="field" tal:repeat="widget group/widgets/values">
<label tal:content="widget/label" />
<br />
<div tal:content="structure widget/render" />
</div>
</fieldset>

#if str($folderish) == 'True'
<fieldset id="folder-listing">
<legend>Contents</legend>
<tal:block define="listing_macro context/folder_listing/macros/listing">
<metal:use_macro use-macro="listing_macro" />
</tal:block>
</fieldset>
#end if

</metal:content-core>
</metal:main>

</body>
</html>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@

<!-- schema and class used for content items -->
<property name="schema">${package_dotted_name}.${content_class_filename}.${interface_name}</property>
<property name="klass">${package_dotted_name}.${content_class_filename}.${contenttype_classname}</property>

#if str($folderish) == 'True'
<property name="klass">plone.dexterity.content.Container</property>
#else
<property name="klass">plone.dexterity.content.Item</property>
#end if
<property name="behaviors">
<element value="plone.app.content.interfaces.INameFromTitle" />
<element value="plone.app.dexterity.behaviors.metadata.IBasic"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ it will create or modify the following files and directories:
content_class_templates : directory
Put templates for your new type here

content_class_templates/sampleview.pt
content_class_templates/index.pt
A sample view template for your new content type

models : directory
Expand Down
14 changes: 9 additions & 5 deletions src/templer/dexterity/templates/dexterity/buildout.cfg_tmpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[buildout]
extends = http://dist.plone.org/release/4.2.1/versions.cfg
develop = .
parts = test
versions = versions
extends = http://svn.plone.org/svn/collective/buildout/plonetest/test-4.x.cfg
package-name = ${namespace_package}.${package}
parts += omelette

[test]
recipe = zc.recipe.testrunner
defaults = ['--tests-pattern', '^f?tests$', '-v']
eggs = ${namespace_package}.${package} [test]

[versions]
[omelette]
recipe = collective.recipe.omelette
eggs = \${instance:eggs}

[instance]
eggs += Pillow