Yes, but it should be optional (in case that isn't obvious), meaning
that a developer doesn't have to specify a default event type.
> 2) Model-Glue 3 allows for an event handler to have multiple event types.
> This means the Default Event Type should technically stay with the
> Event-Handler regardless if the Event-Handler has other Event Types. If this
> is the case, how does a Default Event Type differ from adding logic to
> OnRequestStart? If not, and the Default Event Type vanishes if a specific
> type is set for a specific Event Handler, what would the usage be?
>
I think that the default event type should vanish if one or more types
is specified for the event-handler. To me that's what default means:
use this if I'm not overridden. One should be able to specify multiple
event types as the default event type, just as one can specify
multiple event types on an event-handler. In order to allow a
developer to specify *no* event types for a particular event-handler,
they could specify type="" in the <event-handler> element. In terms
of how to implement it in the xml, I can see a couple of options:
1. Make it a Model-Glue configuration setting, for example
"DefaultEventTypes", and allow a comma delimited list of event types.
2. Allow for a <default-event-types> element inside the <event-types>
element. For example:
<event-types>
<default-event-types="TemplatedEvent,SecuredEvent" />
<event-type name="TemplatedEvent">
<after>
<views>
<include name="main" template="templates/main.cfm" />
</views>
</after>
</event-type>
<event-type name="SecuredEvent">
<before>
<broadcasts>
<message name=”LoginRequired” />
</broadcasts>
<results>
<result name=”NotLoggedIn” do=”user.login” />
</results>
</before>
</event-type>
</event-types>
>
> The Model-Glue mailing list is full of very smart people, so let's get the
> initial ideas out there and we'll work on refining them as we go along.
>
>
> Your input appreciated.
> DW
--
Bob Silverberg
www.silverwareconsulting.com
> While i think of it, would it be any use to have a defaultEventType
> attribute for the event-handlers block, like Coldspring has the
> defaultAutoWire attribute for the beans tag?
> <event-handlers defaultEventType="TemplatedEvent,SecuredEvent">
> ...
> </event-handlers>
> <event-handlers defaultEventType="SomeOtherEventType">
> ...
> </event-handlers>
> <event-handlers>
> ...
> </event-handlers>
>
Oooh, I like that. That would allow a developer, for example, to have
one set of default event types for the public side and a different set
of default event types for the admin side.
Were you thinking that that approach would be in addition to being
able to set one set of default event types in the model-glue config,
or in place of that? I can see how giving developers two different
ways of specifying default event types could be seen as confusing by
some, but it would allow for maximum flexibility.
Bob
--
Bob Silverberg
www.silverwareconsulting.com
What about using some form of advice instead of configuring the event
handlers themselves?
I had pretty good success wrapping the event stuff in some CS advice
and doing things based on the event name, etc..
Just tossing it out there. *shrug*
--
Avoid lawsuits beyond all things; they pervert your conscience, impair
your health, and dissipate your property.
Jean de la Bruyere
Unless you yourself have a need, of course! ;-)
I'm very fond of heavy vetting (that almost sounded funny)-- if the
need/use cases don't stand up under that bright light, that's "a
sign", ja know?
FWIW, accomplishing this end goal seems like it would give *far* more
bang for the buck than, say, dicking with lazy-loading controllers.
Scaffolding, for instance, is has some pretty good ROI as far as R&D
and whatnot. We could make sooooo many people's lives sooooooo much
easier... ;-)
So, be an advocate for the devil all you want, he (she? ;]) always
gets his due, so it's best to think about it a bit ahead of time.
--
"Three cheers for not just saying 'yes, sounds swell, done deal'"
-Denny
I pretty much always split my MG XML into separate files, for the sake
of organization, so the suggested modification to the event-handlers
block would tie in quite nice.
A nice thing about XML is that you don't *have* to define the element
if it's not required by the DTD ;).
There's always CS for advice based on event names* (tho it would be
nice if one didn't have to extend the MG core to wrap the event
handler stuff, and it was in the default ModelGlue.xml instead, like
the orm stuffs).
*Example name-based advice is stuff like public.home, private.home,
sometemplate.mainpage, public.sometemplate.home, etc.. with SES for
pretty-ness and whatnot.
--
If our life is unhappy it is painful to bear; if it is happy it is
horrible to lose, So the one is pretty equal to the other.
Jean de la Bruyere
On Wed, May 20, 2009 at 5:57 AM, Doug Hughes <dhu...@alagad.com> wrote:
> I must admit that if pressed to pick an idea I liked best, I like having the
> ability to have multiple <event-handlers> blocks with an eventType attribute
> which overrides the event type attribute on the <event-handler> tag.
>
--
Bob Silverberg
www.silverwareconsulting.com
Can anyone show me an example where my time spent learning MG,
developing an application, and maintaining that application is reduced
with this feature?
<event-types>
<event-type name="SecuredEvent">
<before>
<broadcasts>
<message name="LoginRequired" />
</broadcasts>
<results>
<result name="NotLoggedIn" do="user.login" />
</results>
</before>
</event-type>
</event-types>
<event-handlers defaultType="SecuredEvent"> <event-handler name="admin.administrate"> <broadcasts> <message name="AdminIsDoingStuff" /> </broadcasts> <views> <include name="body" value="admin.cfm" /> </views> </event-handler> ...
</event-handlers>
<event-handlers> <event-handler name="home.page"> <views> <include name="home" value="home.cfm" /> </views> </event-handler> ... </event-handlers>
On Wed, May 20, 2009 at 10:21 AM, Doug Hughes <dhu...@alagad.com> wrote:
> If we're grouping events by type, then the attribute on event-handlers
> should not be default, but type.
>
> Doug Hughes, President
> Alagad Inc.
> dhu...@alagad.com
> 888 Alagad4 (x300)
> Office: 919-550-0755
> Fax: 888-248-7836
>
>
--
Bob Silverberg
www.silverwareconsulting.com
Are you saying that because you looked at what needs changing in the
code, or because we've been hashing it out so well?
If it's the former, ok, that's valid, but if it's the later, I'm
actually kinda happy with the discussion, and don't think it implies a
muddy concept.
FWIW, I like the idea of defaultType in the handlers block, which can
be overridden for each handler.
Seems to make semantic sense, will cut down on cut'n'pasting (always
nice), and encourages people to organize their handlers (I've been
splitting things into their own files, usually by controller, for
ages, and I can tell you, coming from a 4am coder, it's made a pretty
big difference in "finding" stuff).
--
Next to sound judgment, diamonds and pearls are the rarest things in the world.
Jean de la Bruyere
--
Lola J. Lee Beno
LinkedIn: http://www.linkedin.com/in/lolajleebeno
Facebook: http://www.facebook.com/profile.php?id=714355583
Blog: http://www.lolajl.net/blog/
I've run into the same thing with scaffolding.
What about "special" keywords? Something like:
<event-handlers defaultType="secured,templated>
<event-handler name="login.form" type="_allExcept_secured,foo">
</event-handler>
</event-handlers>
Kinda ugly, but... it's an idea. =]
--
The great gift of conversation lies less in displaying it ourselves
than in drawing it out of others. He who leaves your company pleased
with himself and his own cleverness is perfectly well pleased with
you.
Jean de la Bruyere