Core components in DrProject

I will attempt to explain DrProject‘s core components, which are depended on by the rest of the components. Copious amounts of metaprogramming are used, so beware of your sanity. Some relevant reference resources will be mentioned at the end.

Class drproject.core.ComponentMeta: The metaclass of Component. This ensures that all subclasses of Component follow the singleton pattern. Also, ComponentMeta keeps track of all the interfaces implemented by a class based on this metaclass.

Class drproject.core.Component: An abstract class for singleton components. It has subclasses such as AdminSystem and WikiSystem. Instances of these classes usually consist of event handlers. In subclasses of Component, methods decorated with @listen are automatically connected to the signal dispatcher. Component has some direct subclasses, and some indirect subclasses like Controller and EnvironmentSetupParticipant.

Class drproject.core.Interface: A marker base class. Doesn’t do anything, except making the programmer aware of interface classes. An example of a class that extends Interface is IWikiSyntaxProvider.

Method drproject.core.implements: Marks the class as implementing the specified interfaces (a list of classes that extend Interface). This marking is processed in ComponentMeta.__call__ (when a Component class makes the singleton objects). implements does not add methods – e.g. class Foo: implements(IBar) does not add IBar‘s methods to Foo!

Decorator drproject.core.listen: Marks the method as a signal listener. This marking is also processed in ComponentMeta.__call__. The associated signal is obtained from the method’s name, e.g. @listen def project_added(...) will be called when the project_added signal (as declared in is sent.

Class drproject.core.ExtensionPoint: This is a special kind of property. This class is not extended. An ExtensionPoint instance is associated with an interface. When an attribute is an instance of ExtensionPoint, getting its value returns the list of singleton components that implement the associated interface. For example, with class WikiSystem(Component): syntax_providers = ExtensionPoint(IWikiSyntaxProvider), reading WikiSystem().syntax_providers gives a list of singletons whose classes implement IWikiSyntaxProvider.

Class drproject.core.Environment (extends Component): In some ways, this is the God object. It is the starting point of the DrProject application. It handles setting up the database connection, and loading and initializing the components (e.g. ticket system, wiki system, mail system, etc.).

Class drproject.core.EnvironmentSetupParticipant (extends Component): Classes that extend ESP have their environment_created methods called when Environment is configured.

Class drproject.web.controller.Controller (extends Component): Instances of Controller subclasses (verb)process HTTP requests.

And lots of database tables declared using Elixir. These classes can be spotted by the fact that they extend elixir.Entity.


Explore posts in the same categories: DrProject, Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: