Blankman
Blankman

Reputation: 267020

creating events in my classes, and allowing others to hook into them in my django app

I want to create events for my classes.

Say I create a CMS application that has a Article object.

I create events like:

OnEdit
OnCreate
OnDelete
PreCreate
PreDelete

Now I want someone to be able to hook into these events, and add their custom functionality at each event they wish.

I don't want them touching the core source code, so they would have to wire these custom methods to fire somewhere else.

I'm new to both python and django so please be as detailed as possible if you can.

Upvotes: 0

Views: 211

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599610

Signals are what you want. You can define custom signals in your application and send them when certain events happen, then users can get their code to listen to these signals and take any action they want.

Upvotes: 1

Related Questions