Re: [Catalyst] Asynch webservices with catalyst

2017-02-28 Thread Dmitry L.
Here John show some example
https://github.com/jjn1056/Perl-Catalyst-AsyncExample
But I think Catalyst is not the best tool to make async apps

On 28 February 2017 at 13:06, Aaron Trevena <aaron.trev...@gmail.com> wrote:
> Hi all,
>
> I know that catalyst provides some basic support for sending asynch
> responses to clients but the examples & documentation are a bit thin
> on the ground.  I was wondering if anybody has had much success with
> async catalyst request/responses and in particular for webservices.
>
> Cheers,
>
> A
>
> --
> Aaron J Trevena, BSc Hons
> http://www.aarontrevena.co.uk
> LAMP System Integration, Development and Consulting
>
> ___
> 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/



-- 
//wbr, Dmitry L.

___
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] question about authorization and roles

2015-02-10 Thread Dmitry L.
What do you get in debug console output?
By code (Catalyst::Plugin::Authorization::Roles) you have to see
something like this:
Role denied: @roles

Anyway, you should look into Catalyst::Plugin::Authorization::Roles
and try debug it, code is simple.

On 10 February 2015 at 11:01, Luca Ferrari fluca1...@infinito.it wrote:
 Ciao,
 this is what I did in order to get more info:

 # in the controller

 if ( ! $c-check_any_user_role( qw/Admin Manutentore/ ) ) {
 $c-stash-{ message } = User exists  . $c-user_exists() .
  - with username  . $c-user-username .  and roles \
  . $c-user-roles_to_string .  and the check is  .
 $c-check_any_user_role(  qw/Admin Manutentore/ );
 my @roles = $c-user-users_roles-all();
 @roles = map { $_-role-pk .  =  . $_-role-description }
 @roles;
 $c-stash-{ message } .= Roles [@roles];
  }


 and what is printed is:

 User exists 1 - with username fluca1978 and roles [Manutentore] and
 the check is 0Roles [12 = Manutentore]

 so:
 1) the user exists
 2) the username is correct
 3) the user has one role, the description of the role is matched
 4) the check_any_user_role reports false (0)
 5) the lookup of all the roles reports the right primary key and description.

 Any idea about what I'm missing?

 Thanks,
 Luca

 On Mon, Feb 9, 2015 at 9:43 PM, Luca Ferrari fluca1...@infinito.it wrote:
 Ciao,

 On Mon, Feb 9, 2015 at 6:12 PM, Jeff Black jeffrey.bl...@yahoo.com wrote:

 Perhaps it's a stupid question, but have you checked that the user exists?

 if ( $c-user_exists()  ...



 Apparently it exists because I print the username and its role list to
 check...and of course the role is there.

 Luca

 ___
 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/



-- 
//wbr, Dmitry L.

___
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] How to get default()-like behavior outside of the Root controller

2015-02-09 Thread Dmitry L.
I'd rather split one application into several (admin app, survey app,
etc) and join its via middleware.

But you can try this:

In MyApp::Admin:
sub default : Path('admin') {
# or
# sub default : Chained(base) PathPart('') Path {
my ( $self, $c ) = @_;
$c-response-body( 'Page not found in /admin/...' );
$c-response-status(404);
}


In MyApp::Survey;
sub default : Path('survey') {
# or
# sub default : Chained(base) PathPart('') Path {
my ( $self, $c ) = @_;
$c-response-body( 'Page not found in /survey/...' );
$c-response-status(404);
}

On 7 February 2015 at 01:51, Trevor Leffler tleff...@uw.edu wrote:
 Some of my top-level controllers represent different, er... major pieces
 of my application.  They have, among other things, different default views,
 which are mainly just for configuring different page wrappers.  These
 controllers have this action pattern:

 package MyApp::Admin;
 sub base : Chained('/') : PathPart('admin') : CaptureArgs(0) { ... }
 sub index : Chained('base') : PathPart('') : Args(0) { ... }

 package MyApp::Survey;
 sub base : Chained('/') : PathPart('survey') : CaptureArgs(0) { ... }
 ...etc...

 Requests for non-extant paths fall through to Root-default(), which gives
 the (undesired) default root view.  I tried giving my top-level controllers
 their own default() methods, but as others have found [1], 'default() :
 Path' has precedence over 'index : Chained'.  Otherwise, I get the
 appropriate view with 'Page Not Found' content for bad urls, e.g.
 /admin/blargh or /survey/123/nurgle

 I am looking for suggestions/solutions to get the desired behavior.

 Changing index() to 'index : Path' is not a viable option.


 Thanks,
 --Trevor

 [1] http://www.gossamer-threads.com/lists/catalyst/users/24883

 ___
 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/



-- 
//wbr, Dmitry L.

___
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] utf8 on c-res-write or c-res-print

2014-02-20 Thread Dmitry L.
use utf8;
my $fh = $c-res-write_fh;
my $test = \x{41f}\x{440}\x{43e}\x{431}\x{430};
utf8::encode($test);
$fh-write($test);

On 20 February 2014 17:45, Sergey Dmitriev sergey.program...@gmail.com wrote:
 Hello,

 I'm trying to put some utf8 strings as a part of Catalyst response as
 follows:

 $c-res-print ( ... )
  and
 $c-res-write( ... )

 line by line.

 However it dies with

Wide character in syswrite at . IO/Handle.pm line 474

 Any ideas how can utf8 be written to response?

 E.g. set binmode on output handle. Cannot find how.
 Using Catalyst Runtime 5.90042.

 Thanks.

 HtH, Sergey Dmitriev
 All that is necessary for evil to triumph is for good men to do nothing.
 -- Edmund Burke

 ___
 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/




-- 
//wbr, Dmitry L.

___
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] Advent 2013 launched !!!

2013-12-01 Thread Dmitry L.
Cool!
Just small thing: on the Articles List page all articles have title
Title lol:

Articles
Day 01: Title
Day 02: Title



On 2 December 2013 08:23, John Napiorkowski jjn1...@yahoo.com wrote:
 Hey all:

 I am pleased to announce that perl catalyst advent 2013 has launched!

 http://www.catalystframework.org/calendar/2013

 So far there are 15 articles in the queue and I have commits for a few more 
 days but there is still opportunity for someone else to step up.  So get 
 writing ( and reading )

 Sorry if there's some issue with article titles.  Small glitch which should 
 resolve shortly.

 Jnap

 Sent from my iPhone
 ___
 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/



-- 
//wbr, Dmitry L.

___
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] Catalyst and XMLRPC

2011-11-07 Thread Dmitry L.
Hi, Jose!

Clone::Fast fails on testing.
Here is a log http://pastebin.com/QPcbMEsi
I'm on Gentoo x86_64

I've tried to install via cpanm, but cpanm was trying to download
Clone-Fast-0.93, but there is only 0.92 on the CPAN server.

On 4 November 2011 17:30, Jose Luis Martinez 
jlmartinez-lists-catal...@capside.com wrote:


 If Clone::Fast fails, please report back to me. I'm the maint for
 Catalyst::Plugin::Server, and wouldn't want to be depending on a very
 broken module.



-- 
//wbr, Dmitry L.
___
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] Catalyst and XMLRPC

2011-11-04 Thread Dmitry L.
Hello!

Does anybody use Catalyst as XMLRPC service?

I want add new controller to existing Catalyst app, which will serve the
XMLRPC requests.

I've looked at Catalyst::Cookbook and found advice to use
Catalyst::Plugin::XMLRPC, but on Catalyst::Plugin::XMLRPC cpan page it is
marked as deprecated.

Could you give me an advice which module to use or how I can build this app?

Thank you!

-- 
//wbr, Dmitry L.
___
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] Serialized data with HTML::FormHandler and DBIx::Class::InflateColumn::Serializer

2011-10-17 Thread Dmitry L.
Hello!

May be http://www.catalystframework.org/calendar/2009/3 is what you need.
Look at the end of paragraph The Editing Form 

On 17 of October 2011 12:19:20 Het�nyi Csaba wrote:
 Dear Friends
 
 First of all, please forgive me for this newbie question! I know, that
 my problem is not too Catalyst specific,
 but i can't find help other ways, and i know that there is a lot of
 helpful person on this list :)
 
 I have a db table, which holds a lot of common data placed in individual
 columns,
 but in the same table i'd like to store some various specialized data,
 and don't want to
 create other tables to hold this data.
 The various datas coming from various forms.
 So i'd like to use a serialized table column with HTML::FormHandler.
 I found the excellent:
 DBIx::Class::InflateColumn::Serializer
 and i can use it for store perl hash datastructure to one table column.
 (with before 'update_model' )
 
 My problem is, that i need to get this data (or the de-serialized perl
 data struct) in the HFH form class,
 to make the default value to a form field, but i don't know how to
 access the original or de-serialized value in the form class.
 
 Thank You in advance!

-- 
//wbr, Dmitry L.

___
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] jquery autocomplete and JSON

2011-04-29 Thread Dmitry L.
Hi!

Your controller must return JSONP data (not just JSON)

jQuery send additional param to you controller (callback by default, I 
think)
my $cb = $c-req-param(callback);

So View::JSON should return something like this: $cb($data);
Where $data is [{value:1,label:betty},{value:2,label:jane},
{value:3,label:marge}]

And Content-type header probably should be application/javascript

Or look at jQuery.autocomplete manual to use JSON (instead of JSONP)

-- 
//wbr, Dmitry L.

___
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] jquery autocomplete and JSON

2011-04-29 Thread Dmitry L.
 Dmitry, you should return JSONP only for crossdomain requests.
 if you are on the same domain and port you can send JSON.
 
Oops... Really. My fault. Sorry

-- 
//wbr, Dmitry L.

___
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] Plugins Params::Nested and Unicode::Encoding

2011-02-28 Thread Dmitry L.
Hello!

Does anyone use these plugins together?

Catalyst::Plugin::Unicode::Encoding doesn't decode parameter when it is 
prepared by Catalyst::Plugin::Params::Nested (sub prepare_parameters)

I've made a simple patch for Catalyst::Plugin::Unicode::Encoding, so I think 
it should work properly.

PS: sorry for my English

-- 
//wbr, Dmitry L.
*** Encoding.pm	2011-02-28 14:36:59.0 +0300
--- /tmp/patched/Encoding.pm	2011-02-28 15:00:30.0 +0300
***
*** 72,77 
--- 72,111 
  $c-next::method(@_);
  }
  
+ sub _decode_param
+ {
+ 	my $c = shift;
+ 	my $param = shift;
+ 
+ 	my $enc = $c-encoding;
+ 
+ 	# N.B. Check if already a character string and if so do not try to double decode.
+ 	#  http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg02350.html
+ 	#  this avoids exception if we have already decoded content, and is _not_ the
+ 	#  same as not encoding on output which is bad news (as it does the wrong thing
+ 	#  for latin1 chars for example)..
+ 	return (Encode::is_utf8( $param ) ? $param : $enc-decode( $param, $CHECK ));
+ }
+ 
+ sub _prepare_hashed_parameters
+ {
+ 	my $c = shift;
+ 	my $value = shift;
+ 
+ 	foreach my $key (keys(%{$value}))
+ 	{
+ 		if ( ref $value-{$key}  ref $value-{$key} ne 'ARRAY' )
+ 		{
+ 			$c-_prepare_hashed_parameters($value-{$key});
+ 			next;
+ 		}
+ 		for ( ref($value-{$key}) ? @{$value-{$key}} : $value-{$key} )
+ 		{
+ 			$_ = $c-_decode_param($_);
+ 		}
+ 	}
+ }
+ 
  # Note we have to hook here as uploads also add to the request parameters
  sub prepare_uploads {
  my $c = shift;
***
*** 83,99 
  for my $key (qw/ parameters query_parameters body_parameters /) {
  for my $value ( values %{ $c-request-{$key} } ) {
  
! # TODO: Hash support from the Params::Nested
  if ( ref $value  ref $value ne 'ARRAY' ) {
  next;
  }
  for ( ref($value) ? @{$value} : $value ) {
! # N.B. Check if already a character string and if so do not try to double decode.
! #  http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg02350.html
! #  this avoids exception if we have already decoded content, and is _not_ the
! #  same as not encoding on output which is bad news (as it does the wrong thing
! #  for latin1 chars for example)..
! $_ = Encode::is_utf8( $_ ) ? $_ : $enc-decode( $_, $CHECK );
  }
  }
  }
--- 117,129 
  for my $key (qw/ parameters query_parameters body_parameters /) {
  for my $value ( values %{ $c-request-{$key} } ) {
  
! # Hash support from the Params::Nested
  if ( ref $value  ref $value ne 'ARRAY' ) {
+ $c-_prepare_hashed_parameters($value);
  next;
  }
  for ( ref($value) ? @{$value} : $value ) {
! $_ = $c-_decode_param($_);
  }
  }
  }
___
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/