forked from smcmahon/collective.comment_titles
-
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.
- Loading branch information
0 parents
commit 9bff091
Showing
19 changed files
with
633 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,3 @@ | ||
*.egg-info | ||
*.pyc | ||
|
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,10 @@ | ||
Introduction | ||
============ | ||
|
||
Registers an extender for plone.app.discussion commenting fields | ||
that adds a "title" field. | ||
|
||
Uses a browserlayer installed via generic setup. | ||
|
||
Note: p.a.d already supports titles to some extent. If they're available, | ||
they're used. But they aren't on the forms. |
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,6 @@ | ||
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages | ||
try: | ||
__import__('pkg_resources').declare_namespace(__name__) | ||
except ImportError: | ||
from pkgutil import extend_path | ||
__path__ = extend_path(__path__, __name__) |
Binary file not shown.
Binary file not shown.
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,5 @@ | ||
# -*- extra stuff goes here -*- | ||
|
||
|
||
def initialize(context): | ||
"""Initializer called when used as a Zope 2 product.""" |
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 @@ | ||
# http://pythonhosted.org/plone.app.discussion/howtos/howto_extend_the_comment_form.html | ||
# Customized to add "title" rather than "website" | ||
|
||
from persistent import Persistent | ||
|
||
from z3c.form.field import Fields | ||
|
||
from zope import interface | ||
from zope import schema | ||
|
||
from zope.annotation import factory | ||
from zope.component import adapts | ||
from zope.interface import Interface | ||
from zope.publisher.interfaces.browser import IDefaultBrowserLayer | ||
|
||
from plone.z3cform.fieldsets import extensible | ||
|
||
from plone.app.discussion.browser.comments import CommentForm | ||
from plone.app.discussion.comment import Comment | ||
|
||
|
||
# Interface to define the fields we want to add to the comment form. | ||
class ICommentExtenderFields(Interface): | ||
title = schema.TextLine(title=u"Title", required=False) | ||
|
||
|
||
# Persistent class that implements the ICommentExtenderFields interface | ||
class CommentExtenderFields(Persistent): | ||
interface.implements(ICommentExtenderFields) | ||
adapts(Comment) | ||
title = u"" | ||
|
||
# CommentExtenderFields factory | ||
CommentExtenderFactory = factory(CommentExtenderFields) | ||
|
||
|
||
# Extending the comment form with the fields defined in the | ||
# ICommentExtenderFields interface. | ||
class CommentExtender(extensible.FormExtender): | ||
adapts(Interface, IDefaultBrowserLayer, CommentForm) | ||
|
||
fields = Fields(ICommentExtenderFields) | ||
|
||
def __init__(self, context, request, form): | ||
self.context = context | ||
self.request = request | ||
self.form = form | ||
|
||
def update(self): | ||
# Add the fields defined in ICommentExtenderFields to the form. | ||
self.add(ICommentExtenderFields, prefix="") | ||
# Move the title field to the top of the comment form. | ||
self.move('title', before='text', prefix="") |
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,30 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:five="http://namespaces.zope.org/five" | ||
xmlns:i18n="http://namespaces.zope.org/i18n" | ||
xmlns:genericsetup="http://namespaces.zope.org/genericsetup" | ||
i18n_domain="collective.comment_titles"> | ||
|
||
<five:registerPackage package="." initialize=".initialize" /> | ||
|
||
<genericsetup:registerProfile | ||
name="default" | ||
title="collective.comment_titles" | ||
directory="profiles/default" | ||
description="Installs the collective.comment_titles package" | ||
provides="Products.GenericSetup.interfaces.EXTENSION" | ||
/> | ||
|
||
<adapter | ||
factory=".commentextender.CommentExtenderFactory" | ||
provides=".commentextender.ICommentExtenderFields" | ||
layer=".interfaces.ExtenderLayer" | ||
/> | ||
|
||
<adapter | ||
factory=".commentextender.CommentExtender" | ||
provides="plone.z3cform.fieldsets.interfaces.IFormExtender" | ||
layer=".interfaces.ExtenderLayer" | ||
/> | ||
|
||
</configure> |
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,6 @@ | ||
from zope.interface import Interface | ||
|
||
|
||
class ExtenderLayer(Interface): | ||
"""Marker interface that defines a Zope 3 browser layer. | ||
""" |
Binary file not shown.
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,8 @@ | ||
<?xml version="1.0"?> | ||
<!-- Register the package-specific browser layer, | ||
so that it will be activated | ||
when this product is installed. --> | ||
<layers> | ||
<layer name="collective.comment_titles.customization.layer" | ||
interface="collective.comment_titles.interfaces.ExtenderLayer" /> | ||
</layers> |
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,4 @@ | ||
<?xml version="1.0"?> | ||
<metadata> | ||
<version>1000</version> | ||
</metadata> |
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,55 @@ | ||
import unittest | ||
|
||
#from zope.testing import doctestunit | ||
#from zope.component import testing | ||
from Testing import ZopeTestCase as ztc | ||
|
||
from Products.Five import fiveconfigure | ||
from Products.PloneTestCase import PloneTestCase as ptc | ||
from Products.PloneTestCase.layer import PloneSite | ||
ptc.setupPloneSite() | ||
|
||
import collective.comment_titles | ||
|
||
|
||
class TestCase(ptc.PloneTestCase): | ||
|
||
class layer(PloneSite): | ||
|
||
@classmethod | ||
def setUp(cls): | ||
fiveconfigure.debug_mode = True | ||
ztc.installPackage(collective.comment_titles) | ||
fiveconfigure.debug_mode = False | ||
|
||
@classmethod | ||
def tearDown(cls): | ||
pass | ||
|
||
|
||
def test_suite(): | ||
return unittest.TestSuite([ | ||
|
||
# Unit tests | ||
#doctestunit.DocFileSuite( | ||
# 'README.txt', package='collective.comment_titles', | ||
# setUp=testing.setUp, tearDown=testing.tearDown), | ||
|
||
#doctestunit.DocTestSuite( | ||
# module='collective.comment_titles.mymodule', | ||
# setUp=testing.setUp, tearDown=testing.tearDown), | ||
|
||
|
||
# Integration tests that use PloneTestCase | ||
#ztc.ZopeDocFileSuite( | ||
# 'README.txt', package='collective.comment_titles', | ||
# test_class=TestCase), | ||
|
||
#ztc.FunctionalDocFileSuite( | ||
# 'browser.txt', package='collective.comment_titles', | ||
# test_class=TestCase), | ||
|
||
]) | ||
|
||
if __name__ == '__main__': | ||
unittest.main(defaultTest='test_suite') |
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,7 @@ | ||
Changelog | ||
========= | ||
|
||
1.0dev (unreleased) | ||
------------------- | ||
|
||
- Initial release |
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 @@ | ||
collective.comment_titles Installation | ||
-------------------------------------- | ||
|
||
To install collective.comment_titles into the global Python environment (or a workingenv), | ||
using a traditional Zope 2 instance, you can do this: | ||
|
||
* When you're reading this you have probably already run | ||
``easy_install collective.comment_titles``. Find out how to install setuptools | ||
(and EasyInstall) here: | ||
http://peak.telecommunity.com/DevCenter/EasyInstall | ||
|
||
* If you are using Zope 2.9 (not 2.10), get `pythonproducts`_ and install it | ||
via:: | ||
|
||
python setup.py install --home /path/to/instance | ||
|
||
into your Zope instance. | ||
|
||
* Create a file called ``collective.comment_titles-configure.zcml`` in the | ||
``/path/to/instance/etc/package-includes`` directory. The file | ||
should only contain this:: | ||
|
||
<include package="collective.comment_titles" /> | ||
|
||
.. _pythonproducts: http://plone.org/products/pythonproducts | ||
|
||
|
||
Alternatively, if you are using zc.buildout and the plone.recipe.zope2instance | ||
recipe to manage your project, you can do this: | ||
|
||
* Add ``collective.comment_titles`` to the list of eggs to install, e.g.: | ||
|
||
[buildout] | ||
... | ||
eggs = | ||
... | ||
collective.comment_titles | ||
|
||
* Tell the plone.recipe.zope2instance recipe to install a ZCML slug: | ||
|
||
[instance] | ||
recipe = plone.recipe.zope2instance | ||
... | ||
zcml = | ||
collective.comment_titles | ||
|
||
* Re-run buildout, e.g. with: | ||
|
||
$ ./bin/buildout | ||
|
||
You can skip the ZCML slug if you are going to explicitly include the package | ||
from another package's configure.zcml file. |
Oops, something went wrong.