FAQ
Why does Catalyst::Controller not allow additional attributes on Private
actions?

Marcus added this code in r5558 back in November of 2006.

5558 marcus if ( $attrs->{Private} && ( keys %$attrs > 1 ) ) {
5558 marcus $c->log->debug( 'Bad action definition "'

Yes, I asked[1] this same question a year an a half ago and Jonathan was
nice enough to recommend overriding register_actions if I wanted different
behavior. But, that didn't answer my question. Unfortunately, there's no
comments in the code, and the svn log for that change offers no hints.

Is there a specific reason that Private actions may not have additional
attributes?


1 http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg01403.html
--
Bill Moseley
moseley@hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090815/68bf716d/attachment.htm

Search Discussions

  • Eden Cardim at Aug 15, 2009 at 11:28 pm

    On Sat, Aug 15, 2009 at 3:44 PM, Bill Moseleywrote:
    Why does Catalyst::Controller not allow additional attributes on Private
    actions?

    Marcus added this code in r5558 back in November of 2006.

    ? 5558???? marcus???????? if ( $attrs->{Private} && ( keys %$attrs > 1 ) ) {
    ? 5558???? marcus???????????? $c->log->debug( 'Bad action definition "'

    Yes, I asked[1] this same question a year an a half ago and Jonathan was
    nice enough to recommend overriding register_actions if I wanted different
    behavior. But, that didn't answer my question. Unfortunately, there's no
    comments in the code, and the svn log for that change offers no hints.

    Is there a specific reason that Private actions may not have additional
    attributes?
    You can achieve the same effect by using the :Action tag instead, as
    mst suggested in reply to the same thread:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg01413.html

    --
    Eden Cardim Need help with your Catalyst or DBIx::Class project?
    Code Monkey http://www.shadowcat.co.uk/catalyst/
    Shadowcat Systems Ltd. Want a managed development or deployment platform?
    http://edenc.vox.com/ http://www.shadowcat.co.uk/servers/
  • Bill Moseley at Aug 16, 2009 at 5:40 pm
    On Sat, Aug 15, 2009 at 4:28 PM, Eden Cardim wrote:
    Is there a specific reason that Private actions may not have additional
    attributes?
    You can achieve the same effect by using the :Action tag instead, as
    mst suggested in reply to the same thread:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg01413.html


    Yes, I read that back then. That wasn't my question, though. My question
    was *why* Private actions cannot have additional attributes?
    Why is there code to explicitly prevent additional attributes on Private
    methods? Especially since there's a work-around by simply using :Action (or
    just any attribute) to make a method into an action.

    Perhaps only Marcus might be able to answer that if he added that code.

    Further, if *any* attribute can make a method into an action, is there
    chance at some point that only a pre-defined set of attribute values would
    be valid? Not sure there is any reason to do this, but for example might
    want to have sub attributes on methods that are *not* actions, too.




    BTW -- :Action is mentioned in the docs at:

    http://search.cpan.org/~hkclark/Catalyst-Manual-5.8000/lib/Catalyst/Manual/Intro.pod#Controllers

    But, the text says:

    Note that you can also supply attributes via the Controller's config so long
    as you have at least one attribute on a subref to be exported (:Action is
    commonly used for this) - for example the following is equivalent to the
    same controller above:
    That doesn't sound correct. I think just listing the method in config
    "actions" is enough. That is,

    __PACKAGE__->config( actions => { foo => { Path => 'bar' } } );
    sub foo {}
    will work because configured "actions" method names are just pushed onto the
    list of method names returned by
    $meta->get_nearest_methods_with_attributes. No ":Action" (or any attribute)
    required.




    --
    Bill Moseley
    moseley@hank.org
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090816/17d13104/attachment.htm
  • Moritz Onken at Aug 17, 2009 at 8:47 am

    __PACKAGE__->config( actions => { foo => { Path => 'bar' } } );
    sub foo {}
    This has been introduced in 5.80006. The Catalyst-Manual just didn't
    catch up with the changes.

    cheers,

    moritz
  • Tomas Doran at Aug 17, 2009 at 9:19 pm

    On 17 Aug 2009, at 09:47, Moritz Onken wrote:


    __PACKAGE__->config( actions => { foo => { Path => 'bar' } } );
    sub foo {}
    This has been introduced in 5.80006. The Catalyst-Manual just didn't
    catch up with the changes.

    No, it was not.

    What gave you that impression?

    http://www.catalystframework.org/calendar/2008/11

    Cat 5.7015 was the current version at the time of writing, and I think
    that worked for most (if not all) of the 5.70XX series.

    Cheers
    t0m
  • Moritz Onken at Aug 17, 2009 at 9:50 pm
    Am 17.08.2009 um 23:19 schrieb Tomas Doran:
    On 17 Aug 2009, at 09:47, Moritz Onken wrote:


    __PACKAGE__->config( actions => { foo => { Path => 'bar' } } );
    sub foo {}
    This has been introduced in 5.80006. The Catalyst-Manual just
    didn't catch up with the changes.

    No, it was not.

    What gave you that impression?

    http://www.catalystframework.org/calendar/2008/11

    Cat 5.7015 was the current version at the time of writing, and I
    think that worked for most (if not all) of the 5.70XX series.

    Cheers
    t0m
    Until then it was necessary to add at least one attribute to the method.
    The calendar uses :Local as attribute.

    moritz
  • Tomas Doran at Aug 17, 2009 at 9:57 pm

    On 17 Aug 2009, at 22:50, Moritz Onken wrote:
    Until then it was necessary to add at least one attribute to the
    method.
    The calendar uses :Local as attribute.
    Aaaaaah, yes - my bad, you're totally correct, you needed to
    sprinkle :Action around as decoration.. :)

    ++ Whoever fixed that...

    Cheers
    t0m
  • Bill Moseley at Aug 17, 2009 at 1:57 pm
    On Sun, Aug 16, 2009 at 10:40 AM, Bill Moseley wrote:
    On Sat, Aug 15, 2009 at 4:28 PM, Eden Cardim wrote:

    Is there a specific reason that Private actions may not have additional
    attributes?
    You can achieve the same effect by using the :Action tag instead, as
    mst suggested in reply to the same thread:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg01413.html


    My question was *why* Private actions cannot have additional attributes?
    I'm just after a bit more flexibility. Perhaps that limitation could be
    based on what dispatch types are available (i.e. don't allow Private with
    any other dispatch types such as Path) which would allow user-defined
    attributes on Private methods. Perhaps a better question is if there is
    any thought about only creating actions if the method has one or more of a
    defined set of attributes instead of just any attribute? I'm not clear if
    the intent is that any method with attributes becomes an action or if only a
    limited set of attributes should make a method an action.


    Sorry, I know this is not a very important issues. At work we have been
    kicking around some ideas for a new ACL system that uses method attributes
    and this limiation came up again. But, it's easy to work around it.

    Thanks,

    --
    Bill Moseley
    moseley@hank.org
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090817/0553ba0e/attachment.htm
  • Eden Cardim at Aug 17, 2009 at 3:14 pm

    On Mon, Aug 17, 2009 at 10:57 AM, Bill Moseleywrote:
    I'm just after a bit more flexibility.? Perhaps that limitation could be
    based on what dispatch types are available (i.e. don't allow Private with
    any other dispatch types such as Path) which would allow user-defined
    attributes on Private methods.?? Perhaps a better question is if there is
    any thought about only creating actions if the method has one or more of a
    defined set of attributes instead of just any attribute?? I'm not clear if
    the intent is that any method with attributes becomes an action or if only a
    limited set of attributes should make a method an action.
    Sorry, I know this is not a very important issues.? At work we have been
    kicking around some ideas for a new ACL system that uses method attributes
    and this limiation came up again.? But, it's easy to work around it.
    I don't understand your obsession over :Private. A method tagged with
    :Action, or any other attribute that doesn't make it use one of the
    available dispatch types is effectively *the same thing* as a Private
    action, except it doesn't restrict the use of other attributes, is
    this not what you want? Personally, I've dumped most uses of method
    attributes altogether, in favor of the config-based scheme, except for
    a few cases of chaining, so I'd vouch for dumping :Private as well.

    --
    Eden Cardim Need help with your Catalyst or DBIx::Class project?
    Code Monkey http://www.shadowcat.co.uk/catalyst/
    Shadowcat Systems Ltd. Want a managed development or deployment platform?
    http://edenc.vox.com/ http://www.shadowcat.co.uk/servers/
  • Paul Makepeace at Aug 17, 2009 at 3:29 pm
    On Mon, Aug 17, 2009 at 4:14 PM, Eden Cardimwrote:
    On Mon, Aug 17, 2009 at 10:57 AM, Bill Moseleywrote:
    I'm just after a bit more flexibility.? Perhaps that limitation could be
    based on what dispatch types are available (i.e. don't allow Private with
    any other dispatch types such as Path) which would allow user-defined
    attributes on Private methods.?? Perhaps a better question is if there is
    any thought about only creating actions if the method has one or more of a
    defined set of attributes instead of just any attribute?? I'm not clear if
    the intent is that any method with attributes becomes an action or if only a
    limited set of attributes should make a method an action.
    Sorry, I know this is not a very important issues.? At work we have been
    kicking around some ideas for a new ACL system that uses method attributes
    and this limiation came up again.? But, it's easy to work around it.
    I don't understand your obsession over :Private. A method tagged with
    :Action, or any other attribute that doesn't make it use one of the
    available dispatch types is effectively *the same thing* as a Private
    action, except it doesn't restrict the use of other attributes, is
    this not what you want? Personally, I've dumped most uses of method
    This appears to be a DRY violation, then.
    attributes altogether, in favor of the config-based scheme, except for
    a few cases of chaining, so I'd vouch for dumping :Private as well.

    --
    ? Eden Cardim ? ? ? Need help with your Catalyst or DBIx::Class project?
    ?Code Monkey ? ? ? ? ? ? ? ? ? ?http://www.shadowcat.co.uk/catalyst/
    ?Shadowcat Systems Ltd. ?Want a managed development or deployment platform?
    http://edenc.vox.com/ ? ? ? ? ? ?http://www.shadowcat.co.uk/servers/

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
  • Bill Moseley at Aug 17, 2009 at 4:20 pm

    On Mon, Aug 17, 2009 at 8:14 AM, Eden Cardim wrote:
    I don't understand your obsession over :Private. A method tagged with
    :Action, or any other attribute that doesn't make it use one of the
    available dispatch types is effectively *the same thing* as a Private
    action, except it doesn't restrict the use of other attributes, is
    this not what you want? Personally, I've dumped most uses of method
    attributes altogether, in favor of the config-based scheme, except for
    a few cases of chaining, so I'd vouch for dumping :Private as well.

    Sorry, it does sound like an obsession. And yes you are right there are
    other approaches. It's not a big deal.


    Obviously, the intent of Private is to have a forward-able action that
    cannot be dispatched directly. It's a pretty basic part of Catalyst to have
    actions that cannot be dispatched directly, so Private (or a way to express
    the same thing) is useful. The implementation enforces this by prohibiting
    any additional attributes instead of just prohibiting attributes handled by
    different dispatch types. :Action just takes advantage of the
    implementation details -- it's not a real action attribute at this time I
    believe.

    The issue that came up was I knew I could simply avoid using :Private to use
    additional attributes, but then I didn't want to create an action for every
    method that had attributes, either.

    We are just investigating different approaches at this time, so it may turn
    out that we go for the config-based approach as you noted. The people with
    java experience seem to favor the config-based approach.

    Anyway, I've moved on to obsessing about other things.


    --
    Bill Moseley
    moseley@hank.org
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090817/6c3070c7/attachment.htm
  • Tomas Doran at Aug 17, 2009 at 9:15 pm

    On 15 Aug 2009, at 19:44, Bill Moseley wrote:
    Is there a specific reason that Private actions may not have
    additional attributes?
    No, there is not.

    At the time when that code was written, additional attributes (for
    example, those used by Catalyst::Controller::ActionRole) weren't
    supported / recommended.

    They are now.

    Removing that code, and replacing it with an error if you mixed
    Private with dispatch attributes (e.g. : Private Local should go bang)
    would be a very welcome patch.

    Well volunteered.

    Cheers
    t0m

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedAug 15, '09 at 6:44p
activeAug 17, '09 at 9:57p
posts12
users5
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase