meshy/django-conman — pull request #20 by meshy (2014-10-04 21:59:36+00:00)
Title: Handler should be defined on the Node subclass

Defining `handler` as a choice on `conman.nav_tree.models.Node` makes no sense. What does it mean to have a `PageNode` with a `ArticlesAppHandler`? Nothing, that's what.

Instead, `handler` should be a required attribute on the subclass (it will need a [check](https://docs.djangoproject.com/en/1.7/topics/checks/)).

In simple cases this would be a string...

```python
class PageNode(Node):
handler = 'conman.pages.handlers.PageHandler'
```

...it could be defined in the database...

```python
class ChoiceNode(Node):
HANDLER_CHOICES = (
('path.to.Choice1', 'Choice1'),
('path.to.Choice2', 'Choice2'),
)
handler = models.CharField(choices=HANDLER_CHOICES)
```

...or it could be dynamic...

```python
class DynamicNode(Node):
@property
def handler(self):
if datetime.datetime.now().hour < 12:
return 'path.to.MorningHandler'
return 'path.to.AfternoonHandler'
```