Add new Action for ContentType

9 views
Skip to first unread message

Lingfeng Xiong

unread,
Jan 11, 2013, 2:22:05 AM1/11/13
to ko...@googlegroups.com
Hi all,
I want to add a Action for a self-defined ContentType.  For example, I defined a ContentType named 'Server', and I want to add a Action for it, like 'Resync State'. I have read the code in kotti/view/edit/actions.py, but I believe Action is global... so any idea to add a ContentType special Action? Or any future plan to add such support?
Thanks in advanced.

Daniel Nouri

unread,
Jan 11, 2013, 2:53:20 PM1/11/13
to Kotti mailing list, Lingfeng Xiong
Hi

With the existing code what you can do is override the view, call the
original, and conditionally add your own action. But it's not too
elegant. And only one add-on can do it.

Your idea of adding contet-type specific actions sounds fine to me.
I'm open for a pull request that adds to Content.type_info a list of
type-specific actions, similar to edit_links. This should be easy
enough to add though it needs docs and a test.

Daniel
> --
>
>



--
http://danielnouri.org

Andreas Kaiser

unread,
Jan 14, 2013, 3:18:20 AM1/14/13
to ko...@googlegroups.com, Lingfeng Xiong

On 11.01.2013, at 20:53, Daniel Nouri <daniel...@gmail.com> wrote:

> On Fri, Jan 11, 2013 at 8:22 AM, Lingfeng Xiong <xiongl...@gmail.com> wrote:
>> I want to add a Action for a self-defined ContentType. For example, I
>> defined a ContentType named 'Server', and I want to add a Action for it,
>> like 'Resync State'. I have read the code in kotti/view/edit/actions.py, but
>> I believe Action is global... so any idea to add a ContentType special
>> Action? Or any future plan to add such support?
> With the existing code what you can do is override the view, call the
> original, and conditionally add your own action. But it's not too
> elegant. And only one add-on can do it.
>
> Your idea of adding contet-type specific actions sounds fine to me.
> I'm open for a pull request that adds to Content.type_info a list of
> type-specific actions, similar to edit_links. This should be easy
> enough to add though it needs docs and a test.

+1 for the content type specific actions.

For this particular use case there could be another solution: you could
implement a custom workflow for your content type with a (not so) final
state "synced" that has only a transition "resync" with destination
state also set to "synced" (kind of recursive). You could then
subscribe to the WorkflowTransition event and do your sync code in the
subscriber.


Andreas
Reply all
Reply to author
Forward
0 new messages