Re: [Catalyst] Can't seem to use forward or detach. Any special requirements?

2009-04-29 Thread kakimoto
 Yes.  If you detach(), you're basically saying 'do nothing more on
 this request'.  That plus the redirect mean that template processing
 is not done, as I understand it.  This is no doubt dealt with in the
 action


  Hi, Ian,
  The app works fine except that I have set up an eval block within my
controller.
  My detach call comes right after the redirect call.

  It looks like this:

$c-res-redirect($c-uri_for('/users/subscriptions/added '));
$c-detach ();

   What's weird is that on my terminal, the catalyst debug messages
extract reads:

[debug] User subscription (id, 1278) updated in database.
[debug]  update: trapped exception - catalyst_detach
 
   Any idea as to what this means?
 



 And please, please pay attention to what people are saying about
 your
 quoting style.  You're *still* leaving the whole source message in
 your reply, and this is annoying a wide proportion of the list whose
 help you want.

  Yep, I am working on it. Sorry, everyone. Will improve:)

Good night, all :)


___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-29 Thread Tomas Doran

kakim...@tpg.com.au wrote:

  The app works fine except that I have set up an eval block within my
controller.
  My detach call comes right after the redirect call.

  It looks like this:

$c-res-redirect($c-uri_for('/users/subscriptions/added '));
$c-detach ();

   What's weird is that on my terminal, the catalyst debug messages
extract reads:

[debug] User subscription (id, 1278) updated in database.
[debug]  update: trapped exception - catalyst_detach
 
   Any idea as to what this means?


$c-detach works by throwing an exception, whos contents are 
$Catalyst::DETACH (which is the string 'catalyst_detach').


Therefore, if you call $c-detach inside an eval block of your own, then 
you'll end up catching the exception, which is, I guess, what is 
happening here.


Don't do that :)

Call $c-detach outside of your eval block and Catalyst will catch the 
exception, and everything will be fine.


Another thought - what does $c-detach() do / what do you expect it to 
do? If you aren't detaching _to somewhere_, then why not just return?


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] Can't seem to use forward or detach. Any special requirements?

2009-04-29 Thread kakimoto

 Another thought - what does $c-detach() do / what do you expect it
 to 
 do? If you aren't detaching _to somewhere_, then why not just
 return?

hello, tom,

  Good arvo. From what I have read in some of the docs (sorry, I dont
have my bookmarks handy),
they did mention that after a redirection, if one wishes to stop further
processing, just issue a detach statement.

   that's how I got it.

  thank you for your help!

k. akimoto

___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread Matt S Trout
On Mon, Apr 27, 2009 at 11:09:19AM +1000, kakim...@tpg.com.au wrote:
 Hello, Oliver,
 
  Good morning.
  Referring to
 http://kobesearch.cpan.org/htdocs/Catalyst-Runtime/Catalyst.html#c_gt_detach_class_method_arguments,
 under $c-detach(),
 it says that detach is the same as forward, but doesn't return to the
 previous action when processing is finished. 

And forward() takes a private path, not a URL, too.

Look at the debug output on myapp_server.pl startup - it shows the URLs
and the private paths.

-- 
  Matt S Trout   Catalyst and DBIx::Class consultancy with a clue:
   Technical Directorhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Any questions? Mail mst at shadowcat.co.uk
My blog: http://www.shadowcat.co.uk/blog/matt-s-trout/ (warning: profanity)

___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread kakimoto
Hi, everyone,
I know that most people here would understand redirect, forward and
detach well.
Unfortunately, there are people like myself who don't understand it that
well and hence, after looking at the CPAN catalyst docs and J.Rockway's
book, still fail to find a page that defines these methods and
differentiates them clearly.

 i hope someone can help shed some light here. Here it goes:

Looking at the doc for Catalyst::Response-redirect (
http://search.cpan.org/~flora/Catalyst-Runtime-5.80002/lib/Catalyst/Response.pm#$res-%3Eredirect(_$url,_$status_)
 ),

can anyone tell me

- do the request parameters still stay when redirected?
- how about the stash values? do they persist after the redirection? I
do not think so but it's good to have some confirmation.
- This is a convenience method that sets the Location header to the
redirect destination, and then sets the response status. You will want
to  return;  or  $c-detach()  to interrupt the normal processing flow
if you want the redirect to occur straight away  - Could anyone please
give some examples of this?

 do we do something like:

$c-res-redirect ($c-uri_for('subscriptions/confimation'));
return 0;

or something?



thanks!

k. akimoto

___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread J. Shirley
On Mon, Apr 27, 2009 at 9:07 PM, kakim...@tpg.com.au wrote:

 Hi, everyone,
 I know that most people here would understand redirect, forward and
 detach well.
 Unfortunately, there are people like myself who don't understand it that
 well and hence, after looking at the CPAN catalyst docs and J.Rockway's
 book, still fail to find a page that defines these methods and
 differentiates them clearly.

  i hope someone can help shed some light here. Here it goes:

 Looking at the doc for Catalyst::Response-redirect (

 http://search.cpan.org/~flora/Catalyst-Runtime-5.80002/lib/Catalyst/Response.pm#$res-%3Eredirect(_$url,_$status_)http://search.cpan.org/%7Eflora/Catalyst-Runtime-5.80002/lib/Catalyst/Response.pm#$res-%3Eredirect%28_$url,_$status_%29
  ),

 can anyone tell me

 - do the request parameters still stay when redirected?
 - how about the stash values? do they persist after the redirection? I
 do not think so but it's good to have some confirmation.
 - This is a convenience method that sets the Location header to the
 redirect destination, and then sets the response status. You will want
 to  return;  or  $c-detach()  to interrupt the normal processing flow
 if you want the redirect to occur straight away  - Could anyone please
 give some examples of this?

  do we do something like:

 $c-res-redirect ($c-uri_for('subscriptions/confimation'));
 return 0;

 or something?



 thanks!

 k. akimoto

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



STOP.  TOP. POSTING.

Put your reply BELOW.  Like everybody else here, and is the documented list
standard.

forward and detach have absolutely nothing in common with a redirect.

forward and detach are internal Catalyst actions.  It tells Catalyst, Go
here.

Redirect is an HTTP *Response*.  It tells the browser, Look over here.

A redirect is to a URI, composed of however you make it.  If you preserve
the request parameters, they will be there.  All you are doing is sending a
string to the web browser, that the web browser will then go to next.

Calling $c-res-redirect does not stop processing.  To stop processing, you
have to call $c-detach.

This code example:
$c-res-redirect('http://google.com');
$c-log-debug('Hello');

will print Hello to the log.  If you have something important after the
redirect call, it will be executed.  That is the point of the warning in the
documentation.

And please...

STOP.  TOP. POSTING.

Put your reply BELOW.  Like everybody else here, and is the documented list
standard.

-J
___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread Simon Wilcox

On 27/4/09 13:35, J. Shirley wrote:

STOP.  TOP. POSTING.


He didn't. It was a whole message without any previous content. Arguably 
this might have been a new thread but it seems to continue the thread so 
I think it was OK.


Since you're whining about posting etiquette, can I ask you to trim your 
posts properly, including just the relevant context to your reply.


Bottom posting without trimming is just as bloody annoying as top posting.

Thx.

S.

___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread J. Shirley
On Mon, Apr 27, 2009 at 9:57 PM, Simon Wilcox
sim...@digitalcraftsmen.netwrote:

 On 27/4/09 13:35, J. Shirley wrote:

 STOP.  TOP. POSTING.


 He didn't. It was a whole message without any previous content. Arguably
 this might have been a new thread but it seems to continue the thread so I
 think it was OK.

 Since you're whining about posting etiquette, can I ask you to trim your
 posts properly, including just the relevant context to your reply.

 Bottom posting without trimming is just as bloody annoying as top posting.

 Thx.

 S.



Trimming is highly subjective and contextual, top posting is simply bad
form.

Replying to respond to a single line said as an aside is also bad form,
doubly so without even responding to the original point.

I'm sure if you want to start a new thread to establish full protocol for
the Catalyst mailing list nobody would mind.

-J
___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread J. Shirley
On Mon, Apr 27, 2009 at 9:55 PM, kakim...@tpg.com.au wrote:

 Hello, J. Shirley,

  Thank you for your explaination. It made things much clearer and
 confirmed a lotta things.

  One last trivial question:


  A redirect is to a URI, composed of however you make it.  If you
  preserve
  the request parameters, they will be there.  All you are doing is
  sending a
  string to the web browser, that the web browser will then go to
  next.

  How do you mean by 'preserve the request parameters'?  Does it mean by
 not having source code that would mutate the request parameter arguments?


 I 'd like to add another piece of information which I read from J
 Rockway's book.
 When executing a redirection, stash values do not persist. To make that
 happen, we have to

 1) store the stash intended values to the flash
 2) make sure flash_to_stash enabled (ie __PACKAGE__-config(session = {
 flash_to_stash = 1} );

 If I have missed something here, kindly let me know.

 Thank you guys (esp J Shirley).



 K. akimoto



Please respond just at the bottom of the message!

1) Preserve request parameters, you can access all the parameters through
$c-req-params and then append them when creating a new URL.  $c-uri_for(
'somewhere', $params ).
2) Yes, you have to copy any values you want to live longer than one request
to the flash.  You can access them via $c-flash or $c-stash.  I honestly
didn't know about the flash_to_stash config parameter, so try it and see.

You won't get better until you just try this stuff out.  Create a simple
Catalyst application you can use just to experiment.  Learn how the redirect
cycle affects the browser (especially after POST,
http://en.wikipedia.org/wiki/Post/Redirect/Get)

Throw away Catalyst apps are very useful for learning how HTTP works.
Catalyst's debug output is really fantastic.  Combine that with Firefox +
Firebug and the Network panel, you get a huge amount of information.

-J
___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread Ian Wells
2009/4/27  kakim...@tpg.com.au:
 Hello, J. Shirley,

  Thank you for your explaination. It made things much clearer and
 confirmed a lotta things.

Akimoto-san,

people have been answering the questions that you've asked, but I
wanted to check up what it is that you're trying to do.

Tell me if I have this right:

1. the problem you're trying to avoid:

Web browser asks for /user/subscriptions/add, posting parameters, in
order to create a new row in the DB.
= On the server, your website code creates a new row in the DB
= Server outputs a list of objects.

Guy using web browser presses refresh, to show the list again
= On the server, your website code creates a new row in the DB (which
the user didn't want).
= Server outputs a list of objects.

2. the way you're trying to avoid it

I'm not quite sure *what* you're trying to do, but it's a bit
confused, so let's sklip to


3. the way you *should* be doing it

Web browser asks for /user/subscriptions/add, posting parameters, in
order to create a new row in the DB.
= On the server, your website code creates a new row in the DB
= Server outputs a redirect to a page that lists the objects, let's
say /user/subscriptions/list and calls detach() without outputting a
page at all.   (No template is called.)

Web browser receives redirect, asks for the page that lists the
objects. at /user/subscriptions/list
= Server outputs a list of objects.

Guy using web browser presses refresh, to show the list again (and
note that because of the redirect this now loads
/user/subscriptions/list)
= Server outputs a list of objects.


People are steadily trying to steer you towards (3) above.  In (3) you
shouldn't be passing all the parameters to the create operation to the
list page (e.g. the new object name doesn't need to go to the list
page), so they shouldn't be on the redirect.  However, you might have
filters and sort arguments for the list that should be passed on -
typically these are added to the redirect URL rather than passed on in
the stash.  You might also have a message you want to print, reporting
on the *immediately preceding* operation that created the object,
there.  *That* would go in the flash.

Does that help?

Cheers,
-- 
Ian.

___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread Jonathan Rockway
* On Mon, Apr 27 2009, Simon Wilcox wrote:
 On 27/4/09 13:35, J. Shirley wrote:
 STOP.  TOP. POSTING.
 Bottom posting without trimming is just as bloody annoying as top posting.

YES, thank you.  Top posting is much better than bottom-posting ok
after a 10-page email.  Let's avoid both, eh?

Regards,
Jonathan Rockway

--
print just = another = perl = hacker = if $,=$

___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread Jonathan Rockway
* On Mon, Apr 27 2009, J. Shirley wrote:
 On Mon, Apr 27, 2009 at 9:57 PM, Simon Wilcox sim...@digitalcraftsmen.net 
 wrote:
 Trimming is highly subjective and contextual, top posting is simply bad form.

FWIW, my mail client can convert top-posting to bottom-posting
automatically, but it can't trim unnecessary context.  So it would
really be more beneficial if people concentrated on doing the work that
the computer can't, like not including unnecessary context.  Top-posting
is merely an annoyance that can be fixed by pressing a few keys.  (Same
goes for long lines.. I *hate hate hate* them, but they are fixed with a
quick press of W w, so there's no need to complain about them.)

Regards,
Jonathan Rockway

--
print just = another = perl = hacker = if $,=$

___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread kakimoto
hello, J.Shirley,

 Good morning. Sorry if this post is being replied to at the top of the
message
in light of not further causing some disastifactions in the mailing list
(majority).

 Firstly, a big thank you for your response and confirmations.

 Yep, I did try experimenting with my current app and it's taken some time.
 I then hit the documentation and found that it would be better for me
to enquire
with the mailing list. Of course, the facts documented here in the
mailing list would
certainly benefit others (especially those who are starting to get their
feet into the
 Catalyst pool).

  thank you.

K. akimoto


 
 Please respond just at the bottom of the message!
 
 1) Preserve request parameters, you can access all the parameters
 through
 $c-req-params and then append them when creating a new URL. 
 $c-uri_for(
 'somewhere', $params ).
 2) Yes, you have to copy any values you want to live longer than one
 request
 to the flash.  You can access them via $c-flash or $c-stash.  I
 honestly
 didn't know about the flash_to_stash config parameter, so try it and
 see.
 
 You won't get better until you just try this stuff out.  Create a
 simple
 Catalyst application you can use just to experiment.  Learn how the
 redirect
 cycle affects the browser (especially after POST,
 http://en.wikipedia.org/wiki/Post/Redirect/Get)
 
 Throw away Catalyst apps are very useful for learning how HTTP
 works.
 Catalyst's debug output is really fantastic.  Combine that with
 Firefox +
 Firebug and the Network panel, you get a huge amount of information.
 
 -J
 




___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread kakimoto
Hello, Mr Wells,

   Good morning and a big thank you for your reply.
It was pretty accurate. Last night, I managed to get my problem fixed by
using a redirect
prior to receiving your reply.

 Basically, my solution was conceptually on the same lines as the
proposed solution
which you had given.

1) Web browser requests for /user/subscriptions/add,
2) Catalyst controller (sub add) finds that it's just an initialisation
hence
works out some required hidden ids and stores them into the stash.
3) A template, add.tt2 gets used to render a web form for input
4) Approapriate input gets entered by the user and user clicks on the
submit button.
5) Catalyst controller (sub add) finds that it's a submission (by means
of the request method
   being a POST) and performs data validation and creates new database
table entry if
   validation was successful.
6) The new entry's database ID (primary key) and a predefined mesage of
success then gets placed in  the flash along.
7) Catalyst controller then performs a redirect to 
/user/subscriptions/added.
8) A call to detach (ie. $c-detach ();) appears right after the
redirect statement.
 My code looks like this:

$c-log-debug(q{   Entry processed.});
$c-res-redirect($c-uri_for('/users/subscriptions/added '));
$c-detach ();


9) As soon as the redirect takes place, another catalyst controller,
'sub added :Local '
gets called and yes, a template , added.tt2 gets used for rendering.

It works and I have regression tests made when  I was developing the
controller to
make sure it acts as it should. All good there:)


Problem I was trying to solve:


 - To use one controller as much as possible for adding a new entry.
- Problem is that if anyone should hit the F5 key or refresh button on their
browser after a successful entry into the database ( where a message
of success
   gets shown and request parameters are still active), an unintended
new entry gets 
   created on the database table.
 -  I tried many ways (ie setting flags in the flash upon successful
creation of
   a database entry) but they have seem to fail . I have also tried
forwarding
   and detaching to no success.


A question on your proposed solution
---


 Web browser asks for /user/subscriptions/add, posting parameters, in
 order to create a new row in the DB.
 = On the server, your website code creates a new row in the DB
 = Server outputs a redirect to a page that lists the objects, let's
 say /user/subscriptions/list and calls detach() without outputting a
 page at all.   (No template is called.)


Assuming that when the browser asks for /user/subscriptions/add
 (along with the necessary posting parameters), the controller called is
sub add. I would assume that when you mention that 'No template is called',
that's on the same controller (ie sub add). Am I correct?



 Thank you again for your time and patience, everyone.


K. akimoto.










Quoting Ian Wells i...@cack.org.uk:

 2009/4/27  kakim...@tpg.com.au:
  Hello, J. Shirley,
 
   Thank you for your explaination. It made things much clearer and
  confirmed a lotta things.
 
 Akimoto-san,
 
 people have been answering the questions that you've asked, but I
 wanted to check up what it is that you're trying to do.
 
 Tell me if I have this right:
 
 1. the problem you're trying to avoid:
 
 Web browser asks for /user/subscriptions/add, posting parameters, in
 order to create a new row in the DB.
 = On the server, your website code creates a new row in the DB
 = Server outputs a list of objects.
 
 Guy using web browser presses refresh, to show the list again
 = On the server, your website code creates a new row in the DB
 (which
 the user didn't want).
 = Server outputs a list of objects.
 
 2. the way you're trying to avoid it
 
 I'm not quite sure *what* you're trying to do, but it's a bit
 confused, so let's sklip to
 
 
 3. the way you *should* be doing it
 
 Web browser asks for /user/subscriptions/add, posting parameters, in
 order to create a new row in the DB.
 = On the server, your website code creates a new row in the DB
 = Server outputs a redirect to a page that lists the objects, let's
 say /user/subscriptions/list and calls detach() without outputting a
 page at all.   (No template is called.)
 
 Web browser receives redirect, asks for the page that lists the
 objects. at /user/subscriptions/list
 = Server outputs a list of objects.
 
 Guy using web browser presses refresh, to show the list again (and
 note that because of the redirect this now loads
 /user/subscriptions/list)
 = Server outputs a list of objects.
 
 
 People are steadily trying to steer you towards (3) above.  In (3)
 you
 shouldn't be passing all the parameters to the create operation to
 the
 list page (e.g. the new object name doesn't need to go to the list
 page), so they shouldn't be on the redirect.  However, you might
 have
 filters and 

Re: [Catalyst] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread J. Shirley
On Tue, Apr 28, 2009 at 4:12 AM, Jonathan Rockway j...@jrock.us wrote:

 * On Mon, Apr 27 2009, J. Shirley wrote:
  On Mon, Apr 27, 2009 at 9:57 PM, Simon Wilcox 
 sim...@digitalcraftsmen.net wrote:
  Trimming is highly subjective and contextual, top posting is simply bad
 form.

 FWIW, my mail client can convert top-posting to bottom-posting
 automatically, but it can't trim unnecessary context.  So it would
 really be more beneficial if people concentrated on doing the work that
 the computer can't, like not including unnecessary context.  Top-posting
 is merely an annoyance that can be fixed by pressing a few keys.  (Same
 goes for long lines.. I *hate hate hate* them, but they are fixed with a
 quick press of W w, so there's no need to complain about them.)

 Regards,
 Jonathan Rockway

 --
 print just = another = perl = hacker = if $,=$

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


Hijacking threads for stupid banter is totally cool!

Really, though, I'm sure your mail client can hide quoted text... If it
can't, you are having an email thread.

As far as trimming context, I leave that for the person I'm replying to.  If
I'm the one asking for help and initiating the conversation then I usually
do trim, but if they're the ones initiating I leave it for them to determine
what context they want to preserve.

I'm glad you guys have an opinion, but like I said already, how about why
start a new thread?

-J
___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-27 Thread J. Shirley
On Tue, Apr 28, 2009 at 7:10 AM, kakim...@tpg.com.au wrote:

 hello, J.Shirley,

  Good morning. Sorry if this post is being replied to at the top of the
 message
 in light of not further causing some disastifactions in the mailing list
 (majority).

  Firstly, a big thank you for your response and confirmations.

  Yep, I did try experimenting with my current app and it's taken some time.
  I then hit the documentation and found that it would be better for me
 to enquire
 with the mailing list. Of course, the facts documented here in the
 mailing list would
 certainly benefit others (especially those who are starting to get their
 feet into the
  Catalyst pool).

  thank you.

 K. akimoto


  
  Please respond just at the bottom of the message!
 
  1) Preserve request parameters, you can access all the parameters
  through
  $c-req-params and then append them when creating a new URL.
  $c-uri_for(
  'somewhere', $params ).
  2) Yes, you have to copy any values you want to live longer than one
  request
  to the flash.  You can access them via $c-flash or $c-stash.  I
  honestly
  didn't know about the flash_to_stash config parameter, so try it and
  see.
 
  You won't get better until you just try this stuff out.  Create a
  simple
  Catalyst application you can use just to experiment.  Learn how the
  redirect
  cycle affects the browser (especially after POST,
  http://en.wikipedia.org/wiki/Post/Redirect/Get)
 
  Throw away Catalyst apps are very useful for learning how HTTP
  works.
  Catalyst's debug output is really fantastic.  Combine that with
  Firefox +
  Firebug and the Network panel, you get a huge amount of information.
 
  -J
 


Acknowledging you are top posting and apologizing is not the right answer.
Posting at the bottom is.  You failed it.
___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-26 Thread kakimoto
Hello, Oliver,

 Good morning.
 Referring to
http://kobesearch.cpan.org/htdocs/Catalyst-Runtime/Catalyst.html#c_gt_detach_class_method_arguments,
under $c-detach(),
it says that detach is the same as forward, but doesn't return to the
previous action when processing is finished. 

 Comments?

thank you

k. akimoto



Quoting oliver.g.char...@googlemail.com:

 kakim...@tpg.com.au wrote:
  hello, all,
 
   I have a method in my controller which adds entries.
 
   The method is setup to match the path of
 'users/subscriptions/add'.
 
   Upon successfully adding entries, I want the same method to be
 executed
  again (only that the method will know which template (view) to
 call. I
  tried using a detach (and even a forward) and I keep getting an
 error of
  , 'Couldn't forward to command /users/subscriptions/add: Invalid
  action or component.'
 
 This is because the  path you specified is not the internal path
 name to the action (that is whatever you named your controller
 /create),
 but it is the external path. Detach works on internal path names.
 
  Reason why I am issuing a detach - To prohibit users from pressing
  Refresh on the browser which will cause the application to readd
 the
  entry again into the database (this happens because I suspect that
 the
  request object is not flushed. I could easily kill off the
 parameters in
  the request object but I figured I use a detach and have another
 (view)
  template show up.
 
 Detach will simply cause another action to be executed before
 returning
 to the browser, so this won't solve your problem. You need to cause
 a
 redirect to solve your problem, so the correct code would be:
 
 $c-res-redirect($c-uri_for_action('/controller/create')
 
 Where controller is the name of the controller that contains the
 action
 you provided in your email.
 
 Hope that helps
 
 --
 Oliver Charles / aCiD2
 
 ___
 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] Can't seem to use forward or detach. Any special requirements?

2009-04-26 Thread J. Shirley
On Mon, Apr 27, 2009 at 10:09 AM, kakim...@tpg.com.au wrote:

 Hello, Oliver,

  Good morning.
  Referring to

 http://kobesearch.cpan.org/htdocs/Catalyst-Runtime/Catalyst.html#c_gt_detach_class_method_arguments
 ,
 under $c-detach(),
 it says that detach is the same as forward, but doesn't return to the
 previous action when processing is finished.

  Comments?

 thank you

 k. akimoto



 Quoting oliver.g.char...@googlemail.com:

  kakim...@tpg.com.au wrote:
   hello, all,
 
I have a method in my controller which adds entries.
 
The method is setup to match the path of
  'users/subscriptions/add'.
 
Upon successfully adding entries, I want the same method to be
  executed
   again (only that the method will know which template (view) to
  call. I
   tried using a detach (and even a forward) and I keep getting an
  error of
   , 'Couldn't forward to command /users/subscriptions/add: Invalid
   action or component.'
 
  This is because the  path you specified is not the internal path
  name to the action (that is whatever you named your controller
  /create),
  but it is the external path. Detach works on internal path names.
 
   Reason why I am issuing a detach - To prohibit users from pressing
   Refresh on the browser which will cause the application to readd
  the
   entry again into the database (this happens because I suspect that
  the
   request object is not flushed. I could easily kill off the
  parameters in
   the request object but I figured I use a detach and have another
  (view)
   template show up.
 
  Detach will simply cause another action to be executed before
  returning
  to the browser, so this won't solve your problem. You need to cause
  a
  redirect to solve your problem, so the correct code would be:
 
  $c-res-redirect($c-uri_for_action('/controller/create')
 
  Where controller is the name of the controller that contains the
  action
  you provided in your email.
 
  Hope that helps
 
  --
  Oliver Charles / aCiD2
 
  ___
  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/
 
 
 





Please don't top-post, put your reply at the bottom of the thread.

$c-detach is basically $c-forward, and stop running.

If you have code:
sub some_action : Private {
  $c-forward('foo');
  $c-log-debug(Hello);
}
The debug message is printed.

However, with this code:
sub some_action : Private {
 $c-detach('foo');
 $c-log-debug(Hello);
}
The debug message is NOT printed.

$c-detach stops the path of execution right then, it doesn't continue at
all.

But, on the original subject, neither $c-forward or $c-detach do what you
are asking them to.  You want $c-res-redirect, and probably right after
-redirect add in $c-detach to stop the action's execution.

-J
___
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] Can't seem to use forward or detach. Any special requirements?

2009-04-25 Thread oliver . g . charles
kakim...@tpg.com.au wrote:
 hello, all,

  I have a method in my controller which adds entries.

  The method is setup to match the path of 'users/subscriptions/add'.

  Upon successfully adding entries, I want the same method to be executed
 again (only that the method will know which template (view) to call. I
 tried using a detach (and even a forward) and I keep getting an error of
 , 'Couldn't forward to command /users/subscriptions/add: Invalid
 action or component.'

This is because the  path you specified is not the internal path
name to the action (that is whatever you named your controller /create),
but it is the external path. Detach works on internal path names.

 Reason why I am issuing a detach - To prohibit users from pressing
 Refresh on the browser which will cause the application to readd the
 entry again into the database (this happens because I suspect that the
 request object is not flushed. I could easily kill off the parameters in
 the request object but I figured I use a detach and have another (view)
 template show up.

Detach will simply cause another action to be executed before returning
to the browser, so this won't solve your problem. You need to cause a
redirect to solve your problem, so the correct code would be:

$c-res-redirect($c-uri_for_action('/controller/create')

Where controller is the name of the controller that contains the action
you provided in your email.

Hope that helps

--
Oliver Charles / aCiD2

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