[Catalyst] Fetching URL Content

2009-09-02 Thread Trevor Phillips
I have a requirement to fetch URL content - this is currently mostly
to do with the View phase, to include chunks of HTML for core branding
in the templating. ie; Top header, footer, global nav, that sort of
thing.

Ideally, I'd like to do it directly from the Template Toolkit
templates, but TT either can't do this, or it's really hard to Google
for. ^_^
It would be nice to cache locally the content, even if for a short
period. Or ideally, to cache permanently unless there's a
Cache-Control: no-cache request header to force an update.

ie; something like:
   [% INCLUDE http://central.server.com/branding/header.html; cache=5 min %]

Can TT do anything like this? It doesn't need to be parsed by TT
(although having the option for TT to parse it would be useful).

The next idea would be to have a Controller fetch the content for the
remote URLs, and either shove them in the stash, or cache them to
disk, so that TT can then reference them. Would this just be a case of
doing a usual LWP UserAgent Request, or does Catalyst have built-in
handling or plugins to aid in this?

Hmmm. It could be implemented as a Model as well, I guess...

Any ideas/tips/best practices?

Thanks.

--
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] DB Functions in the Schema

2009-08-18 Thread Trevor Phillips
On Tue, Aug 18, 2009 at 5:24 PM, Matthias Dietrichmdietr...@cpan.org wrote:

 you could ask a single question on the irc channel like I do ;-):
 irc.perl.org#dbix-class

Ooh, I might give that a go when I have a minute! (And at the right time of day)

 Though I don't know the answer, maybe the deflate and inflate hooks can call
 SQL functions?  But for dates you can use Perl functions or define your
 column as datetime (see: DBIx::Class::InflateColumn::DateTime).

I was hoping to be able to do it as part of the query when it gets the
rest of the normal columns, since one of the reasons was to reduce
multiple calls to the DB (or other routines).

And DateTime was what got me pulling my hair out to investigate this
alternative in the first place! A simple query with a dozen lines was
taking around 2 seconds to return, and I'd put in an extra method,
which was doing some DateTime calls. Without calling that method, the
request took a much more reasonable 300ms.

In the end I found the culprit was because I set a timezone of local
- if I hard-coded it to my actual timezone, it was fast, but using
local, was slow-as, even though it translated to the same thing!

 Also good luck from me!

Thanks!

-- 
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] DB Functions in the Schema

2009-08-17 Thread Trevor Phillips
Is there an easy way to represent a DB function call as a named column
within a DBIx::Class schema?

eg;

If at the DB level I would do something like:
  select updated, from_unixtime(updated) as updated2 from mytable;
... can I have;

__PACKAGE__-add_columns(
   updated, { data_type = TIMESTAMP }
   updated2, { something = from_unixtime(updated), etc...}
...
);

Thanks.

-- 
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] DB Functions in the Schema

2009-08-17 Thread Trevor Phillips
On Mon, Aug 17, 2009 at 9:31 PM, fREW Schmidtfri...@gmail.com wrote:
 I don't know the answer to this off the top of my head, but I do know that
 you mailed it to the wrong people :-)  You are much more likey to get a good
 answer if you send this to the DBIC ML.

I considered that, but the Catalyst bunch are such a friendly helpful
mob, I thought I'd try here first. ^_^

It doesn't feel quite right to subscribe to a list (DBIC ML), ask a
question, then unsubscribe again.

 On Aug 17, 2009 3:13 AM, Trevor Phillips trevor.phill...@gmail.com
 wrote:

 Is there an easy way to represent a DB function call as a named column
 within a DBIx::Class schema?

 eg;

 If at the DB level I would do something like:
  select updated, from_unixtime(updated) as updated2 from mytable;
 ... can I have;

 __PACKAGE__-add_columns(
   updated, { data_type = TIMESTAMP }
   updated2, { something = from_unixtime(updated), etc...}
 ...
 );

 Thanks.

 --
 Trevor Phillips  - http://dortamur.livejournal.com/
 On nights such as this, evil deeds are done. And good deeds, of
 course. But mostly evil, on the whole.
      -- (Terry Pratchett, Wyrd Sisters)

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





-- 
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] OpenID and SREG

2009-07-05 Thread Trevor Phillips
On Sat, Jul 4, 2009 at 5:43 PM, Trevor
Phillipstrevor.phill...@gmail.com wrote:

 Disappointingly, it looks like many providers don't offer SREG details
 - Google, Yahoo, LiveJournal didn't return anything. MyOpenID did
 though.

Doing a bit more reading, it looks like Google won't support SREG, but
are supporting AX, which seems to be the way places are going. Does
the current Catalyst OpenID Auth support AX?

Fudging the format for the SREG query, I tried:

   extensions = {
  'http://openid.net/srv/ax/1.0' = 1
   },
   extension_args = [
  'http://openid.net/srv/ax/1.0',
  {
   required = 'email',
   'type.email' = 'http://schema.openid.net/contact/email'
  }
  ]

...but got nothing back from the providers I tried.

-- 
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] OpenID and SREG

2009-07-04 Thread Trevor Phillips
On Sat, Jul 4, 2009 at 2:02 PM, Ashleya...@sedition.com wrote:

 The configuration examples are bad. Menno Blom provided the patch to support
 the stuff and I documented it incorrectly. I'm really sorry about this; it's
 been this way for a long time. I've been trying just this week to get a new
 release but I was also trying to run deeper tests to make sure I don't make
 another faux pas and I've been having problems getting them together and
 LWPx::ParanoidAgent is still broken and my excuse machine is on the fritz.

Thanks. I'm surprised there isn't more interest in maturing the OpenID
support. I think it has a lot of potential for easing registration 
authentication for a lot of web apps.

Are you referring to LWPx::ParanoidAgent exploding when a bad Identity
URL is given? I tried using eval to get around it but that seems to
clash with the rest of the workings of your library.

 The snippet below (unedited, it's better to not use the config-{} =
 assignment idiom) is from a recent report from Orlando Vazquez who got it
 running in spite of the bad doc. There was also an issue with
 Config::General being a PITA regarding the data structure so you might want
 to start with a pure Perl config and if it runs, then put it into your
 favored config file format.

[snip]
             ### need this to get registration fields
             extensions = {
                'http://openid.net/extensions/sreg/1.1' = 1
             },

This was the missing link! I can now chuck this in my test app:
   $c-stash-{sreg} =
$c-user-extensions-{'http://openid.net/extensions/sreg/1.1'};
...and access sreg properties from the templates. Yay!

Disappointingly, it looks like many providers don't offer SREG details
- Google, Yahoo, LiveJournal didn't return anything. MyOpenID did
though.

Ideally, I'd like to store a local profile for a user, using OpenID
for Auth, and SREG for initial/default field population when
available. I'd rather use a ID and username created  tracked
internally, though, and just use the OpenID for auth.

--
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] OpenID and SREG

2009-07-03 Thread Trevor Phillips
I've only just started looking at OpenID, and would love to integrate
it with Catalyst apps. Using
Catalyst::Authentication::Credential::OpenID I've got the basics of
Authentication working, but I'm having problems with SREG.

The first problem is when using a .conf config, the docs say you can use:
 extension_args
http://openid.net/extensions/sreg/1.1
requiredemail
optionalfullname,nickname,timezone
 /extension_args

However, this fails, since this doesn't resolve into an Array, which
is what Net::OpenID::Consumer expects when
Catalyst::Authentication::Credential::OpenID calls set_extension_args.

Ok, so I can get around that by defining my Auth in my Perl module instead...

The next problem is I can't seem to get at the SREG hash. I'm trying
to get the hash using:

$sreg = $c-user-signed_extension_fields(
 'http://openid.net/extensions/sreg/1.1'
  );

...but this just assigns $sreg the string
'http://openid.net/extensions/sreg/1.1'.

Dumps of $c-user don't show anything useful either.

Am I missing something, or is OpenID Extensions for Catalyst currently broken?

-- 
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] Base URI breakdown

2009-03-06 Thread Trevor Phillips
In a Catalyst app, I need to break down the base request URL to
extract hostname, port, etc separately.

I could do this with a regexp on $c-request-base, or I could use the
URI perl lib, but is there already a way to access this within
Catalyst?

The docs say that $c-request-base is a string only, whereas I'd like
to access separately bits like $c-request-base-host and
$c-request-base-port.

-- 
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] Base URI breakdown

2009-03-06 Thread Trevor Phillips
On Sat, Mar 7, 2009 at 12:25 PM, Andrew Rodland arodl...@comcast.net wrote:

 $c-req-base is a URI object under all of the Engine types that I'm aware of.

Next time I should just try things before assuming the docs are absolute. ^_^

 The docs don't promise this, but they don't say it's not either. Anyway
 there's no reason you couldn't do URI-new($c-req-base) which will be a
 perfectly good URI object whether base is a URI or an unblessed string. :)

Sounds good to me. Thanks!

-- 
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] RFC: New to Catalyst questions

2009-02-19 Thread Trevor Phillips
On Fri, Feb 20, 2009 at 4:41 AM, Rodrigo rodrigol...@gmail.com wrote:

 Actually, I'd like to work also on a sassier getting-started page for the
 dev.catalystframework.org/wiki site. IMO, the Catalyst Wiki could get a
 makeover: some css styling (so that the wiki is aligned with the homepage),
 column separated content, more short description of links or sections, or
 anything that improves usability really, for beginners and experienced users
 alike.

I agree that the Wiki could do with some work, although I don't mind
the style so much. ^_^ I do think it could be a little better
organised, and promoted though. Also, I think having a prominent last
modified date on a Wiki page is a useful indication, and maybe even a
Catalyst Version reference for howtos  code snippets. (Again, a
specialist knowledge base could handle that sort of data  filtering
better than a Wiki I think).

What is the best practices for Wiki updates?

Should new articles be posted to this list first, for discussion, or
should they be just whacked into the Wiki, then posted here for
review/deletion?

Is there an alert/review process for Wiki edits? Is there a core team
that will be notified of changes/additions, so they can review/delete?

As someone fairly new to Catalyst, I'm happy to contribute, but I'm
hesitant to jump in  start making changes  additions... Perhaps
there should be a prominent page on the Wiki on how to best contribute
to the Wiki?

Here's some quick observations on things I think could be clearer on
the main Catalyst site too:
  *The main site Community link goes straight to the Wiki. How about
a Community page that summarises the Wiki, the mail list, the IRC
channel, etc...
  *The main site Documentation goes straight to the manual - yet
there's also documentation in the Wiki. Again, Docs page which deep
links into key pages in the official docs and parts of the Wiki would
be better IMHO.
  *The main site Developer jumps straight into the Catalyst
repository (hmmm, there's a theme here). How about clarifying
resources for Developers who work on Catalyst versus Developers who
use Catalyst to develop apps?

-- 
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] RFC: New to Catalyst questions

2009-02-17 Thread Trevor Phillips
On Tue, Feb 17, 2009 at 5:32 AM, Jay Kuri j...@ion0.com wrote:

 My working list is as follows (in no particular order.)

 1) 'Getting' DBIx::Class (starting from a straight SQL-users point of
 view)

I'm new to Catalyst, having started to look into it a few months back
(and now developing several apps in it). The auto-schema stuff on
DBIx::Class was great. All the has_many  many_to_many it took a while
to wrap my brain around, and I'm still a bit fuzzy on some of it, but
referring back to the docs, I can figure it out.

Trying to do a moderately complex SQL query in DBIx::Class is a
nightmare! Sometimes I wish I could just write out the SQL myself -
even if it's chunked up into fields, condition, join, etc...

 3) Walkthrough of creation of a simple app end to end.

I found the Tutorial walkthrough
(http://search.cpan.org/~hkclark/Catalyst-Manual-5.7016/lib/Catalyst/Manual/Tutorial.pod)
to be great as a kick-start. I just wish the Advanced CRUD was a bit
more fleshed out (or that FormFu was easily apt-gettable). Having a
branching tutorial with some alternatives (such as something other
than TT, for example) would be good.

I think what I miss most is:
 *A quick reference howto guide for common (and advanced) stuff. How
do I get a HTTP header? How do I set a response status? How do I have
a wrapper template, yet also support other forms of output like
AJAX/JSON/XML? What does this method or that method do and where
should they be used? How can I use two separate Authentication systems
for different parts of the app? Just brief FAQ-style code snippets
with good explanations... (Maybe someone could whip up a Catalyst FAQ
app to handle question submissions, community answers, categorisation,
searching, etc... Would be better IMHO than a single Wiki page... ^_^)
 *Clarification on the Path and Args (and others?) sub parameters,
with examples on advanced usage.
 *Best Practices - I guess this comes in to the earlier points as
well. Rather than munge something together that works, if I can easily
find a code snippet that does a similar thing, then I'll use that
snippet. For example; How do I provide a controller which handles both
a HTML and an AJAX response? How do I specify the AJAX qualifier in
the query string? Do I use a query parameter? Or append something like
:ajax to the URI? Or go to a completely separate URI? How do I set
out my Controller methods to most efficiently handle both situations
without code duplication?
 *Interactive Demo/Tuts would be really good. If there's so many CRUD
systems to choose from, then having a live demo of each next to the
relevant code snippet would really help quickly highlight the pros 
cons of each.
 *Better linking/cataloguing to documentation. For example, the Wiki
seems to have a Cookbook, with a handful of articles. There's also, it
seems, a quite extensive Cookbook in the CPAN documentation - yet the
Wiki doesn't link to it or mention it?

As I said, I found the Tutorial to be really good, but I find I'm
using the Tutorial as my documentation for my own app, rather than
looking straight in the manual, or in the wiki resources... The Manual
Cookbook seems good - I should use it more often.

I'm pretty new to the Catalyst community, and still very much a
Catalyst newbie. I don't know how open this list is to having the same
n00b questions asked over  over again. I'd be happy to write up a few
howto's myself, as I discover stuff, but I'm not confident I'm doing
things the right way anyway, or if people would care about the same
topics I struggle with, or where the best place to document this sort
of Cookbook/FAQ stuff is...

-- 
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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 confirm before deleting

2009-01-21 Thread Trevor Phillips
On Thu, Jan 22, 2009 at 3:12 PM, Toby Corkindale
toby.corkind...@strategicdata.com.au wrote:

 But what happens when your site gets spidered by a search engine, that
 follows all links?

 Whoops.

 There's a good reason state-modification-actions should be POST (or rather,
 non-GET, if you want to go with PUT, DELETE, etc)

Surely such an action would be behind some form of authentication,
ergo blocking any random web crawler? An app that allowed you to
delete records with no security checks has bigger issues. ^_^

-- 
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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: Production session issue - commercial supportinquiry?

2009-01-08 Thread Trevor Phillips
Are you sure that multiple sessions are pointing at the one cart_id?
Is it possible multiple users are being assigned the same session ID?

I'm very much the Catalyst n00b, but I have seen in other systems
(Apache/mod_perl) a while back a situation where random session
strings were assigning the same session ID to entirely different
users, causing session clashes.

The problem came down to lousy random number generation. I can't
remember the details - might've been seeding before the fork? Or
possibly it was using a time/pid seed that had the possibility of
seeding two apache daemons with the same seed... Messy stuff, that's
for sure!

-- 
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
  -- (Terry Pratchett, Wyrd Sisters)

___
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] Large static files behind Authorisation

2009-01-04 Thread Trevor Phillips
On Sun, Jan 4, 2009 at 7:48 PM, Tomas Doran bobtf...@bobtfish.net wrote:

 Just use a stash key to indicate that you have served a file yourself to stop 
 calling TT.. e.g.

 sub serve_stuff : Local {
my ( $self, $c ) = @_;
$c-serve_static_file('some_file');
$c-stash-{file_output} = 1;
 }

 sub end : Private {
my ( $self, $c ) = @_;
$c-detach('render') unless $c-stash-{file_output};
 }

 sub render : ActionClass('RenderView') {}

That sort of worked! It definitely turned off the template - but I was
getting no file output still, which agrees with what Nickolay said.

I stripped down my download action to the bare minimum and did get it
working - the problem was that I was using :Path :Args to define the
matching path. When I changed to using Local, it worked correctly.

Why should it matter to serve_static_file if I specify :Path :Args or
use Local? The routine was definitely being called either way - just
the file output wasn't working.

--
Trevor Phillips  - http://dortamur.livejournal.com/
On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole.
 -- (Terry Pratchett, Wyrd Sisters)

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