Re: [Catalyst] Implementing a 'remember me on this computer' button

2011-04-05 Thread Sam Kaufman
http://search.cpan.org/~mstrout/Catalyst-Plugin-Session-State-Cookie-0.17/lib/Catalyst/Plugin/Session/State/Cookie.pm
cookie_expires

Number of seconds from now you want to elapse before cookie will
expire. Set to 0 to create a session cookie, ie one which will die
when the user's browser is shut down.
Sounds pretty simple to me.



On Tue, Apr 5, 2011 at 10:49 AM, Bill Moseley mose...@hank.org wrote:


 On Tue, Apr 5, 2011 at 7:16 AM, Edmund von der Burg e...@ecclestoad.co.uk 
 wrote:

 I want my sessions either to be long-lived (several months) or, at the
 user's discretion, only last for the current browser session.
 Achieving either of these is quite easy, but doing both in one app
 appears a little trickier.

 I have used a separate remember me cookie that effectively will auto-login 
 the user.  That's very simple to implement.  It doesn't save any session 
 state that way, but avoiding the login is often what users are after rather 
 than remembering the exact state of the session.  Not sure how useful that 
 would be for someone returning days later.

 --
 Bill Moseley
 mose...@hank.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/


___
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] Forcing scalar context in TT?

2010-12-23 Thread Sam Kaufman
You *could* do [% row.objects_rs.count %] to force resultset context.
However, the fact that it's such a pain in the ass should tell you that
you're doing something in the view that shouldn't be done there. Just stash
the count from the controller, and you won't have to worry about scalar
context ;)

On Thu, Dec 23, 2010 at 11:44 AM, Moritz Onken on...@houseofdesign.dewrote:

 Use Template::Alloy and do

 [% $(row.objects).count %]

 Am 23.12.2010 um 16:53 schrieb Alex Povolotsky:

  Hello!
 
  I'm writing an application that needs to count some related objects
 
  [% row.objects.count %] results in select * from objects
  [% row.objects.scalar.count %] yields an error
  [% row.search_related_rs('objects').count %] is UGLY
 
  Do I have any better solution?
 
  Alex.
 
 
  ___
  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/

___
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 calendar memcached article misleading or incorrect?

2010-12-21 Thread Sam Kaufman
Hey,
Sorry about the delay in responding, I was away most of the day.
I wrote the tutorial, and looking at it now it could certainly use
more explanation in regards to what module is doing what.
specifying traits = ['Caching'] in your schema applies
Catalyst::TraitFor::Model::DBIC::Schema::Caching
to your schema,
which sets the default_cursor_class for your schema to
DBIx::Class::Cursor::Cached
and also does this:

if (ref $self-schema-default_resultset_attributes) {
$self-schema-default_resultset_attributes-{cache_object} =
$c-cache;
} else {
$self-schema-default_resultset_attributes({
cache_object = $c-cache
});
}
ie sets cache_object ( needed by DBIx::Class::Cursor::Cached )
to  $c-cache, which is provided by Catalyst::Plugin::Cache.
Memcached comes into the picture via the configuration of
Catalyst::Plugin::Cache as you can see in the tutorial.


On Tue, Dec 21, 2010 at 12:01 PM, Tommy Butler a...@tommybutler.me wrote:
 On 12/21/2010 10:52 AM, Tommy Butler wrote:

 On 12/21/2010 10:43 AM, Bill Moseley wrote:

 You seem to have trimmed this link in your email:

 http://search.cpan.org/~rkitover/Catalyst-Model-DBIC-Schema-0.48/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm
 http://search.cpan.org/%7Erkitover/Catalyst-Model-DBIC-Schema-0.48/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm

 Yes!  Sweet Loot, there it is!  Moose magic.

 What's more, based on the documentation and the source code for that trait
 module, you don't even need to set your cursor class if you just specify a
 caching trait.  The code ||= it for you on line 63 -
 http://cpansearch.perl.org/src/RKITOVER/Catalyst-Model-DBIC-Schema-0.48/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm

 Awesome.

 *Thanks for the gentle guidance, Bill.*

 --
 Tommy

 ___
 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] Overriding Catalyst::View::TT WRAPPER

2010-11-29 Thread Sam Kaufman
I've found the easiest way is to have some logic in your wrapper:
something like this:
[%
 IF no_wrapper;
 content;
 ELSE;
 content WRAPPER site/html + site/layout;
END;
%]
so $c-stash(no_wrapper = 1) and it won't be wrapped.
-Sam

On Mon, Nov 29, 2010 at 8:16 PM, Mesdaq, Ali ames...@websense.com wrote:
 Hey Everyone,

 Got a question about how I can override my application's TT wrapper. The 
 closest thing I found was 
 http://search.cpan.org/~abraxxa/Catalyst-View-TT-0.36/lib/Catalyst/View/TT.pm#CONFIGURATION
  . But what I am trying to do is basically have the wrapper turned off for a 
 specific public method where I will create a new TT file that I want used 
 without it being wrapped.

 Thanks,
 ALI MESDAQ
 Sr. Security Researcher

 WEBSENSE, INC.
 ph: +1.858.320.9466
 fax: +1.858.784.4466
 www.websense.com

 Websense TRITON™
 For Essential Information Protection™
 Web Security | Data Security | Email Security




  Protected by Websense Hosted Email Security -- www.websense.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/



___
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] Re: Converting a GET request to a POST request

2010-11-25 Thread Sam Kaufman
I proposed a solution, the package Resty::Controller::API; example I
sent earlier. Trying to write your controller using
Catalyst::Action::Deserialize is a mistake, as it's not what
Deserialize does.
from 
http://search.cpan.org/~bobtfish/Catalyst-Action-REST-0.87/lib/Catalyst/Action/Deserialize.pm

This action will deserialize HTTP POST, PUT, and OPTIONS requests. It
assumes that the body of the HTTP Request is a serialized object. The
serializer is selected by introspecting the requests content-type
header.

You want to deserialize a GET request. GET requests have no body. GET
requests generated by script src tags request content-type */*. So
the correct way to code this would be handle it as what it is, a GET
request with a parameter that's JSON encoded, for which you can use
something like the example I provided earlier or just a regular
controller with a base that decodes the encoded parameter and does
what you want.
-Sam

On Tue, Nov 23, 2010 at 11:56 AM, Ronald J Kimball
rkimb...@pangeamedia.com wrote:
 On Mon, Nov 22, 2010 at 3:12 PM, Aristotle Pagaltzis pagalt...@gmx.de wrote:
 This is really, really, really bad. It’s roughly like modifying
 a file system to be allow file deletion as a side effect of
 opening a file. GET is supposed to be safe, that is, it should be
 free of side effects that the user cannot be held responsible
 for. It is very, very easy to get a browser to send GET requests
 incidentally, eg. by putting the link in a `img src` or
 a stylesheet `link` and getting a user to visit. Things like
 Google Web Accelerator and other automated user agents (like
 search engines of course) also generally assume that GET is safe.
 Much web infrastructure also assumes that GET requests are
 cacheable, so if there are any proxies between the app and the
 user, sending multiple pseudo-POST requests may not actually do
 anything.

 I completely understand the points you're making here.  As I said, one
 of the drawbacks of this solution is that it makes me feel really
 dirty.

 For what it's worth, the REST methods that I want to expose in this
 way are for posting responses to content.  There won't be any deletes.


 The same-origin policy is not there by mistake, but to keep your
 users safe from malicious 3rd party sites they may visit.

 REST principles dictate that I use POST, not GET, for these requests.
 The same-origin policy forces me to use JSONP, which can only make GET
 requests, not POST.  What's the solution?


 Ronald

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