Re: [Catalyst] Preventing simultaneous logins
1. checking whether there is an existing session associated this username Session::PerUser ? I looked briefly at this, but I'm a bit wary because C::P::Session::Store::Fastmmap warns against being used with it. What is PerUser doing that is special in that respect, and what is a good backend for it? REading the docs for it, it seems like something slightly different - keeping the same session in place, even if the user logs in in the middle of it, if I understand correctly? ___ 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/
Re: [Catalyst] deserializing key value pairs Catalyst::Controller::REST
Hi Hani, var postData = source_account=1destination_account=2ingestor_id=10source_id=1 I think this is where it fails. As far as I can tell from your code, postData should contain a JSON Object. Try something like: var postData = '{ source_account: 1, destination_account: 2, ingestor_id: 10, source_id: 1 }'; On another note, make sure that YAHOO.util.Connect.asyncRequest doesn't mess up your request somehow (is that YUI, btw?). I've just experienced the same annoyance with Dojo, whose dojo.xhrPost is not exactly fond of sending JSON-Objects. It helps to look at the request itself with some tool like e.g. wireshark. HTH, Jochen ___ 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/
Re: [Catalyst] auto re-load of application yaml config file?
On Jul 24, 2008, at 10:16 PM, Jonathan Rockway wrote: * On Thu, Jul 24 2008, Pedro Melo wrote: And yes, the tradeoff is mod_perl, which is more complex than FCGI. How does Perlbal require mod_perl? I would just run the application's own HTTP server behind Perlbal. Not very complex at all. It does not. If I implied otherwise it was not what I meant. The assertion is that mod_perl is slightly more complex than FCGI for some. I have no problem with that assertion, although I only use mod_perl myself because I prefer to use HTTP all the way, and I find apache2+mod_perl2 the most stable application environment for Perl. You can perfectly use Perlbal with Apache|Lighttpd|Nginx+FastCGI. Best regards, -- Pedro Melo Blog: http://www.simplicidade.org/notes/ XMPP ID: [EMAIL PROTECTED] Use XMPP! ___ 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/
Re: [Catalyst] Using a post argument in a template
On Fri, Jul 25, 2008 at 07:40:59AM -0500, James S. White wrote: I was trying to munge the paramaters in the controller, You said argument in your original post: sub foo : Local { my ( $self, $c, $myarg ) = @_; $c-stash-{myarg} = $self-munge( $myarg ); # or use chaining } I just can't figure out how to access the variables of a controller method in the template. Munged argument is [% myarg | html %] I'd be more than happy to pass the argument to a controller, and then have the view fetch it from the controller, and then the template read it from the view, If I had any idea how to dereference the variables in order to set them in new components. I was just trying to keep it walk before running and I keep tripping over my feet. It's that wording that is tripping me up. ;) On Fri, 25 Jul 2008, Eden Cardim wrote: On Fri, Jul 25, 2008 at 1:12 AM, James S. White [EMAIL PROTECTED] wrote: I'm passing an argument to the method via a post, and then catch it with my ( $self, $c, $myarg ) = @_; shouldn't there be a way to mine it without using [% c.req.arguments.0 %] in the template? like [% c.controller('Page').methodname.myarg %] or something... You want [% c.req.body_params.myarg %] if it's a post, [% c.req.params.myarg %] if you don't care. I would munge the parameters in the controller and try to formalize an API to interact with the view though. Also, avoid making your view-side code be controller-dependent, you'll surely regret it later. -- edenc.vox.com ___ 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 [EMAIL PROTECTED] Sent from my iMutt ___ 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/
Re: [Catalyst] Using a post argument in a template
On 25 Jul 2008, at 13:40, James S. White wrote: I was trying to munge the paramaters in the controller, I just can't figure out how to access the variables of a controller method in the template. I'd be more than happy to pass the argument to a controller, and then have the view fetch it from the controller, and then the template read it from the view, If I had any idea how to dereference the variables in order to set them in new components. I was just trying to keep it walk before running and I keep tripping over my feet. You want to put the data into the 'stash'. So in your controller you have: my ( $self, $c, $arg ) = @_; $arg =~ s/stuff/munge/; $c-stash-{somearg} = $arg; And in your view, you say: [% c.stash.somearg %] You don't really want the view to be able to see the controller's internal state / mechanics, and so you have to explicitly stash any data which you want to be able to see from the view. HTH t0m ___ 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/
Re: [Catalyst] Using a post argument in a template
I did. I want to use it as a variable even though it's passed in as an arg. I didn't mean to be unclear, sorry. Once it's stashed, can I use it like [% myarg %] in a template? or [% c.stash.myarg %]? On Fri, 25 Jul 2008, Bill Moseley wrote: On Fri, Jul 25, 2008 at 07:40:59AM -0500, James S. White wrote: I was trying to munge the paramaters in the controller, You said argument in your original post: sub foo : Local { my ( $self, $c, $myarg ) = @_; $c-stash-{myarg} = $self-munge( $myarg ); # or use chaining } I just can't figure out how to access the variables of a controller method in the template. Munged argument is [% myarg | html %] I'd be more than happy to pass the argument to a controller, and then have the view fetch it from the controller, and then the template read it from the view, If I had any idea how to dereference the variables in order to set them in new components. I was just trying to keep it walk before running and I keep tripping over my feet. It's that wording that is tripping me up. ;) On Fri, 25 Jul 2008, Eden Cardim wrote: On Fri, Jul 25, 2008 at 1:12 AM, James S. White [EMAIL PROTECTED] wrote: I'm passing an argument to the method via a post, and then catch it with my ( $self, $c, $myarg ) = @_; shouldn't there be a way to mine it without using [% c.req.arguments.0 %] in the template? like [% c.controller('Page').methodname.myarg %] or something... You want [% c.req.body_params.myarg %] if it's a post, [% c.req.params.myarg %] if you don't care. I would munge the parameters in the controller and try to formalize an API to interact with the view though. Also, avoid making your view-side code be controller-dependent, you'll surely regret it later. -- edenc.vox.com ___ 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 [EMAIL PROTECTED] Sent from my iMutt ___ 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/
Re: [Catalyst] Using a post argument in a template
Cool. I was unaware how the stash worked. I can see the benefit of encapsulating each component. Thanks! On Fri, 25 Jul 2008, Tomas Doran wrote: On 25 Jul 2008, at 13:40, James S. White wrote: I was trying to munge the paramaters in the controller, I just can't figure out how to access the variables of a controller method in the template. I'd be more than happy to pass the argument to a controller, and then have the view fetch it from the controller, and then the template read it from the view, If I had any idea how to dereference the variables in order to set them in new components. I was just trying to keep it walk before running and I keep tripping over my feet. You want to put the data into the 'stash'. So in your controller you have: my ( $self, $c, $arg ) = @_; $arg =~ s/stuff/munge/; $c-stash-{somearg} = $arg; And in your view, you say: [% c.stash.somearg %] You don't really want the view to be able to see the controller's internal state / mechanics, and so you have to explicitly stash any data which you want to be able to see from the view. HTH t0m ___ 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/
Re: [Catalyst] Using a post argument in a template
On 25 Jul 2008, at 14:50, James S. White wrote: I did. I want to use it as a variable even though it's passed in as an arg. I didn't mean to be unclear, sorry. Once it's stashed, can I use it like [% myarg %] in a template? or [% c.stash.myarg %]? Yes, either. Cheers t0m ___ 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/
[Catalyst] API Versioning for Web Services
I'm looking for suggestions how to best support multiple API versions in an application. The API and web share many controller actions. As is not uncommon, actions available for the API are defined with an attribute: sub foo : Local XMLRPC( 'foo.get' ) { This is great for sharing code as often the API just exposes the same functionality as the web interface. When a new version of the web application is released then all web users see the new version at the same time. If an action in the new version expects an additional new parameter then the form posting to that action is modified at the same time. But, the API access to an application typically needs to be backward compatible to allow API users time to update their client applications with the newer requirements. So, it seems I would need multiple controller actions that are dispatched based on some version. Here's one idea I was kicking around: Say I have an existing controller action that is used by the web users, but also available as an XMLRPC API method: sub widget : Local XMLRPC( 'widget.get' ) { So in a new application version that controller action is changed and now requires a new parameter and returns new data. In the new version I want to support the new action but remain backward compatible. # fetch widget for web and API sub widget : Local XMLRPC( 'widget.get' ) Version( 2 ) { # deprecated to support old version of API sub widget_old : XMLRPC( 'widget.get' ) Version( 1 ) { Then in my custom API dispatcher match method I take the version into consideration when matching actions. Any better suggestions? -- Bill Moseley [EMAIL PROTECTED] Sent from my iMutt ___ 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/
Re: [Catalyst] Using a post argument in a template
I can stash and array and when I use [% c.stash.mylist %] in the template, it prints 'ARRAY(0x94023b0)' but if I try: [% FOREACH element IN c.stash.mylist %] [% element %] [% END %] the output is null. I'm sure I'm missing something here, I just don't know what. On Fri, 25 Jul 2008, Tomas Doran wrote: On 25 Jul 2008, at 14:50, James S. White wrote: I did. I want to use it as a variable even though it's passed in as an arg. I didn't mean to be unclear, sorry. Once it's stashed, can I use it like [% myarg %] in a template? or [% c.stash.myarg %]? Yes, either. Cheers t0m ___ 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/
Re: [Catalyst] Using a post argument in a template
nevermind. this works. I am an idiot. It helps if the array isn't empty... On Fri, 25 Jul 2008, James S. White wrote: I can stash and array and when I use [% c.stash.mylist %] in the template, it prints 'ARRAY(0x94023b0)' but if I try: [% FOREACH element IN c.stash.mylist %] [% element %] [% END %] the output is null. I'm sure I'm missing something here, I just don't know what. On Fri, 25 Jul 2008, Tomas Doran wrote: On 25 Jul 2008, at 14:50, James S. White wrote: I did. I want to use it as a variable even though it's passed in as an arg. I didn't mean to be unclear, sorry. Once it's stashed, can I use it like [% myarg %] in a template? or [% c.stash.myarg %]? Yes, either. Cheers t0m ___ 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/ ___ 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/
Re: [Catalyst] Using a post argument in a template
On Fri, Jul 25, 2008 at 8:02 AM, James S. White [EMAIL PROTECTED] wrote: nevermind. this works. I am an idiot. It helps if the array isn't empty... On Fri, 25 Jul 2008, James S. White wrote: I can stash and array and when I use [% c.stash.mylist %] in the template, it prints 'ARRAY(0x94023b0)' but if I try: [% FOREACH element IN c.stash.mylist %] [% element %] [% END %] the output is null. I'm sure I'm missing something here, I just don't know what. You also don't need to use the c.stash prefix, [% mylist %] should work for you. ___ 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/
Re: [Catalyst] Preventing simultaneous logins
Am 25.07.2008 um 10:27 schrieb Daniel McBrearty: 1. checking whether there is an existing session associated this username Session::PerUser ? I looked briefly at this, but I'm a bit wary because C::P::Session::Store::Fastmmap warns against being used with it. What is PerUser doing that is special in that respect, and what is a good backend for it? REading the docs for it, it seems like something slightly different - keeping the same session in place, even if the user logs in in the middle of it, if I understand correctly? You shouldn't store a session in a store which might lose the session because it runs out of memory. Use a store which stores the session permanently like DBIC. cheers ___ 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/
Re: [Catalyst] Preventing simultaneous logins
On Fri, Jul 25, 2008 at 10:27:34AM +0200, Daniel McBrearty wrote: 1. checking whether there is an existing session associated this username Session::PerUser ? I looked briefly at this, but I'm a bit wary because C::P::Session::Store::Fastmmap warns against being used with it. What is PerUser doing that is special in that respect, and what is a good backend for it? REading the docs for it, it seems like something slightly different - keeping the same session in place, even if the user logs in in the middle of it, if I understand correctly? You want: login from elsewhere to log out the same user anywhere else It wants: any login by the same user claims the user's session so, if you add in your root auto if ($c-user_exists) { unless ($c-user_session-{sid} eq $c-sessionid) { $c-logout; $c-forward('/auth/logged_out'); return 0; } } and in MyApp sub set_authenticated { my $self = shift; $self-next::method(@_); $self-user_session-{sid} = $self-sessionid; } then you should pretty much be done. So far as I can tell, this is perfect for you. You just sometimes get persistent session data as well (it warns against fastmmap because in the persistent session use case fastmmap is lossy - in yours the lossyness is irrelevant, you don't care about the persistence feature) -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Directorhttp://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://chainsawblues.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/
Re: [Catalyst] API Versioning for Web Services
On Fri, Jul 25, 2008 at 07:09:58AM -0700, Bill Moseley wrote: I'm looking for suggestions how to best support multiple API versions in an application. The API and web share many controller actions. As is not uncommon, actions available for the API are defined with an attribute: sub foo : Local XMLRPC( 'foo.get' ) { This is great for sharing code as often the API just exposes the same functionality as the web interface. When a new version of the web application is released then all web users see the new version at the same time. If an action in the new version expects an additional new parameter then the form posting to that action is modified at the same time. But, the API access to an application typically needs to be backward compatible to allow API users time to update their client applications with the newer requirements. So, it seems I would need multiple controller actions that are dispatched based on some version. Here's one idea I was kicking around: Say I have an existing controller action that is used by the web users, but also available as an XMLRPC API method: sub widget : Local XMLRPC( 'widget.get' ) { So in a new application version that controller action is changed and now requires a new parameter and returns new data. In the new version I want to support the new action but remain backward compatible. # fetch widget for web and API sub widget : Local XMLRPC( 'widget.get' ) Version( 2 ) { # deprecated to support old version of API sub widget_old : XMLRPC( 'widget.get' ) Version( 1 ) { sub widget :Local VersionedXMLRPC('widget.get') { sub widget_xmlrpc_v1 { have VersionedXMLRPC apply a custom a ction class that does -can based dispatch, same way Catalyst::Action::REST does. Could even make XMLRPC always do that in your app, you'll need a controller base class to provide the _parse_AttrName method iether way. Seems like a bit less typing without any real loss of precision - the main action should likely fire for any version not explicitly handled for compat so no version given or a compatible newer version just happen. If you're going to assume integer versions (or some method name valid encoding of a more complex version number) you could probably instead have the action class scan the controller's entire namespace on creation with a view to making _v9 handle anything below v9 as well until it finds a more specific, lower versioned compat handler (_v3 or similar). -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Directorhttp://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://chainsawblues.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/