And mangle things such that the actual app test works
[catagits/CatalystX-DynamicComponent.git] / TODO
CommitLineData
ff05b07e 1TODO, or the plan for making this stuff work right.
2
3The goals:
4
51/ I want to be able to specify a Controller base class, like
6 Catalyst::Controller::MessageDriven. That's where my
7 message-handling actually lives, so I want to build controllers
8 based on that, or whichever other class.
9
102/ We need a calling convention for the model implementations - in the
11 absence of defined interfaces this should be simple unblessed data,
12 but if we do have an interface, we should be able to put proper
13 constraints on it.
14
153/ Given generated controllers where I expose a bunch of methods from
16 the actual model classes, there needs to be some way to control
56f4c9af 17 which methods are dispatchable - "very public", if you like.
ff05b07e 18
194/ I'd like to be able to write down an "interface", consisting of a
20 set of messages my app is willing to handle, and have the framework
21 (or the controller base class, probably) reject messages that
22 aren't in that set.
23
245/ I'd also like to be able to say in that interface definition what
56f4c9af 25 types of object those methods expect as a payload.
ff05b07e 26
276/ It'd be nice if exceptions from model methods were caught by the
56f4c9af 28 framework and converted into messages representing the error -
ff05b07e 29 i.e. to set an error status, and return the text of the exception.
30
31All these things should be based on configuration. So, we've got
32something to say what classes expose methods, which of those methods
33are dispatchable, and which types are expected.
34
35Possible Implementation
36
56f4c9af 37We can provide a number of controller base roles, for a number of
ff05b07e 38different message styles: YAML with type-tags, JSON bare hashes,
8518a75b 39etc. # FIXME - how does this work with role merging when you want to override the default?
40 # maybe base class knows how to serialize generically, and loads a serialization engine...
41 # or should we have serialization model.. Hmm, more thought needed.
56f4c9af 42
8518a75b 43We then provide strategy classes for a number of
44policies for what models, and which methods on those models
45get reflected / are dispatchable etc..
46
47FIXME - Models, or just the methods, I'm thinking the strategy
48just works out which methods.
56f4c9af 49
50These should be selectable by configuration, the default
ff05b07e 51controller class plus overrides for specific controllers.
52
8518a75b 53This makes the model to controller reflector config look like this:
54
55__PACKAGE__->config(
56 'CatalystX::DynamicComponent::ModelToControllerReflector' => {
57 strategy => {
58 name => 'InterfaceRole',
59 roles => [qw/ My::Model::Interface::Role /],
60 },
61 include => '(Datacash|Cybersource|Paypal)^', # Reflect these models.
62 controller_superclasses => [qw/ Catalyst::Controller /], # Default, you can omit this line
63 controller_roles => [qw/ My::ControllerRole /],
64 },
65 'Controller::Paypal' => {
66 superclasses => [qw/ My::Other::SuperClass /], # _replaces_ classes set above
67 roles => [qw/ My::Other::ControllerRole /], # merged with role set above
68 },
69);
70
ff05b07e 71The calling convention to model methods should be the "payload". That
72might be a bare hashref for simple messages, or a blessed object of
73some app-specific type if the message format contains first-class
74objects, like tagged YAML.
75
76The "interfaces" should be Roles, which don't provide any methods but
77which "need" methods to be implemented. We then use the "needed"
78methods as the set of dispatchable methods, given if we compile OK, we
56f4c9af 79know that the model class has all the required methods.
80*** Do we require that the model class in question has already composed
81the appropriate role, and just check that by introspection or do we just
82add it ourselves? Adding it ourselves involves making an anon subclass
83to avoid action at a distance, so the former if possibly preferable?
ff05b07e 84
85Types are implemented as type signatures on role methods, and we copy
56f4c9af 86them onto the actual methods on the model class at compile time.
87**** I'm thinking this happens at role composition time..
ff05b07e 88
89Exception handling probably needs to be behaviour from the controller
90base class, so that it can be specific to the type of message
91serialization being used.
56f4c9af 92