Re: [Catalyst] Accessing $c from Model

2007-03-06 Thread Scott Thomson

Excellent, that works - Thank you!

On 3/5/07, Juan Miguel Paredes [EMAIL PROTECTED] wrote:

On 3/5/07, Scott Thomson [EMAIL PROTECTED] wrote:
 Ok, I think I'm close...

 My main schema class:

 package DB;

 use base qw/DBIx::Class::Schema  DBIx::Class::AccessorGroup/;

 __PACKAGE__-mk_group_accessors(simple = 'context');
 __PACKAGE__-load_classes(qw//);
 1;


 My model class...

 package WCN::Model::DB;

 use strict;
 use base qw/Catalyst::Model::DBIC::Schema::WCN/;

 __PACKAGE__-config(
 schema_class = 'DB',
 );

 sub ACCEPT_CONTEXT {
   my ($self, $c, @args) = @_;

   $c-log-debug(  *** class:  . ref($self));

   my $new = bless({%$self}, ref $self);
   $new-schema(bless({%{$self-schema}}, ref($self-schema)));
   $new-schema-context($c);

   # Outputs 'WCN' which is correct
   $c-log-debug(  *** ref of context in self: ,
 ref($new-schema-context()));

   return $new;
 }

 The debug prints the correct class of $c when ACCEPT_CONTEXT is
 called, however $self-result_source-schema-context is not present
 in the model objects.

 Have I got the wrong end of the stick somewhere?

 Many Thanks,

 Scott.

That looks very similar to what we did, but in the model class:

sub ACCEPT_CONTEXT {
  my ($self, $c, @args) = @_;

  my $new = bless({ %$self }, ref $self);
  $new-schema-_context($c);
  return $new;
}

(we used _context for accesor)

Also, I don't know if the DB namespace is reserved for debug, and
could lead to complications... I think I read that in a nearby thread
a while ago, but can't locate it right now...

Regards,
Juan.

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/



___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Chained, slashes, and escaping

2007-03-06 Thread Matt Lawrence

Jim Spath wrote:
I'm implementing tagging under Catalyst and want to be as 
unrestrictive as possible on the tag text.  As such, I allow slashes 
in the tag text.


To view information on a given tag, you hit the following path:

/tag/URI_ESCAPED_TAG

Which uses the following action in the Tag controller:

sub view : PathPart('tag') Chained('/') Args {
  my ($self, $c, $tag) = @_;


How about:

my ($self, $c, @tag_parts) = @_;
my $tag = join('/', @tag_parts);

Matt



___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] Again: Lighttpd deployment problems as non root

2007-03-06 Thread Kieren Diment

When I deploy my application at /fastcgi with lighttpd, the url
http://my.site.com/fastcgi gives a 404 error, and
http://my.site.com/fastcgi/ returns an internal server error handled by
catalyst (with unknown resource fastcgi).  This happens for every url
without a trailing slash.

If I try http://my.site.com/fastcgi/content/, it  redirects to
http://my.site.com/fastcgi/content/content/ which outputs what should be at
the first /fastcgi/content

Reading around this subject, the environment variables $SCRIPT_NAME and
$PATH_INFO seem to be important.  However for my lighttpd installation
neither of these variables are set.  However, PATH_INFO is set using the
developemnt server.
___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] Re: Chained, slashes, and escaping

2007-03-06 Thread A. Pagaltzis
* Jonathan Rockway [EMAIL PROTECTED] [2007-03-06 06:20]:
 Apparently back in the early days of the web, a URL like that
 caused problems with poorly written CGI scripts that blindly
 opened the PATH_INFO variable. Instead of fixing the scripts,
 the apache / NCSA HTTPD authors decided to break the URL spec
 for the rest of forever.
 
 http://mail-archives.apache.org/mod_mbox/httpd-dev/199612.mbox/[EMAIL 
 PROTECTED]
 
 11 years later, the web is still broken (for backwards
 compatibility, of course).

http://httpd.apache.org/docs/2.0/mod/core.html#allowencodedslashes

Regards,
-- 
Aristotle Pagaltzis // http://plasmasturm.org/

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Chained, slashes, and escaping

2007-03-06 Thread Carl Johnstone

When I access the following URI:

/tag/sl%2Fashes

$tag gets set to sl instead of sl/ashes.


Apparently back in the early days of the web, a URL like that caused 
problems


I ran into this a couple of weeks ago. As far as I could the development 
myapp_server actually deals with everything correctly.


In Apache:

You can now allow encoded slashes in Apache  2.0.46 with:

 AllowEncodedSlashes On


If you're using mod_perl though, when Catalyst fetches the URI from apache 
it requests the parsed vesion so for your example would get back 
/tag/sl/ashes


You can customise Catalyst::Engine::Apache to use unparsed_uri and split off 
the query string - which seems to work OK for my simple case, but I didn't 
test any further.


See:

http://lists.scsys.co.uk/pipermail/catalyst-dev/2007-February/000578.html

Carl





___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Chained, slashes, and escaping

2007-03-06 Thread Jim Spath
Hi Matt, I had considered that.  I just wanted to check with the list 
before I went that route.


Thanks!
- Jim

Matt Lawrence wrote:

Jim Spath wrote:
I'm implementing tagging under Catalyst and want to be as 
unrestrictive as possible on the tag text.  As such, I allow slashes 
in the tag text.


To view information on a given tag, you hit the following path:

/tag/URI_ESCAPED_TAG

Which uses the following action in the Tag controller:

sub view : PathPart('tag') Chained('/') Args {
  my ($self, $c, $tag) = @_;


How about:

my ($self, $c, @tag_parts) = @_;
my $tag = join('/', @tag_parts);

Matt



--
Jim Spath
Lead Developer
Pangea Media
Em: [EMAIL PROTECTED]
Ph: 617.314.6687
Fx: 617.390.7824
IM: panJimS (AIM)

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Chained, slashes, and escaping

2007-03-06 Thread Jim Spath

Unfortunately I'm using lighttpd.

Carl Johnstone wrote:

When I access the following URI:

/tag/sl%2Fashes

$tag gets set to sl instead of sl/ashes.


Apparently back in the early days of the web, a URL like that caused 
problems


I ran into this a couple of weeks ago. As far as I could the development 
myapp_server actually deals with everything correctly.


In Apache:

You can now allow encoded slashes in Apache  2.0.46 with:

 AllowEncodedSlashes On


If you're using mod_perl though, when Catalyst fetches the URI from 
apache it requests the parsed vesion so for your example would get back 
/tag/sl/ashes


You can customise Catalyst::Engine::Apache to use unparsed_uri and split 
off the query string - which seems to work OK for my simple case, but I 
didn't test any further.


See:

http://lists.scsys.co.uk/pipermail/catalyst-dev/2007-February/000578.html

Carl


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] reserved words

2007-03-06 Thread Octavian Rasnita

Hi,

Please tell me how can I find the list of reserved words that cannot be used 
as names for views, controllers, models, $c-stash elements...


For example I have seen that the name of the application is also found in 
$c-stash-{name}. $c-stash-{template} is also special.


I have also tried to create a view with the name Show, and I have received 
the following error in the browser:


Caught exception in TranzactiiBursiere::View::Show-process 
TranzactiiBursiere::View::Show directly inherits from Catalyst::View. You 
need to

inherit from a subclass like Catalyst::View::TT instead.

If I changed the name of that view to Html, it worked fine, with no 
errors...


Thank you.

Octavian


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] reserved words

2007-03-06 Thread John Napiorkowski


- Original Message 
From: Octavian Rasnita [EMAIL PROTECTED]
To: catalyst@lists.rawmode.org
Sent: Tuesday, March 6, 2007 12:02:39 PM
Subject: [Catalyst] reserved words

Hi,

Please tell me how can I find the list of reserved words that cannot be used 
as names for views, controllers, models, $c-stash elements...

For example I have seen that the name of the application is also found in 
$c-stash-{name}. $c-stash-{template} is also special.

I have also tried to create a view with the name Show, and I have received 
the following error in the browser:

Caught exception in TranzactiiBursiere::View::Show-process 
TranzactiiBursiere::View::Show directly inherits from Catalyst::View. You 
need to
inherit from a subclass like Catalyst::View::TT instead.

If I changed the name of that view to Html, it worked fine, with no 
errors...

Thank you.

Octavian

I didn't know about the Show issue that you mentioned but AFAIK there are not 
really global reserved stuff.  'template' is used by the TT view to set the 
path to the template so you have to be careful with that.  I think the 
'template' think bit me once as well.  That's really the only stash key I can 
think of that's special, but if you use something other than TT you should 
check the docs.

--john


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/





 

Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Accessing $c from Model

2007-03-06 Thread Jason Kohles

On Mar 5, 2007, at 7:02 AM, Scott Thomson wrote:


Ok, I think I'm close...

My main schema class:

package DB;

use base qw/DBIx::Class::Schema  DBIx::Class::AccessorGroup/;

__PACKAGE__-mk_group_accessors(simple = 'context');
__PACKAGE__-load_classes(qw//);
1;

Very Bad Things are likely to happen if you ever attempt to run your  
application under the debugger when you have a package named 'DB'.   
I'd recommend using a different name...


--
Jason Kohles
[EMAIL PROTECTED]
http://www.jasonkohles.com/
A witty saying proves nothing.  -- Voltaire


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Accessing $c from Model

2007-03-06 Thread Scott Thomson

Noted and actioned,  Cheers.

Very Bad Things are likely to happen if you ever attempt to run your

application under the debugger when you have a package named 'DB'.  I'd
recommend using a different name...

--
Jason Kohles
[EMAIL PROTECTED]
http://www.jasonkohles.com/
A witty saying proves nothing.  -- Voltaire



___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive:
http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Some bits missing/wrong in the docs for the dev version of C::P::Authentication

2007-03-06 Thread Jay K

Hi Dave,

Thanks for the feedback.  You are definitely right about the
session / supports issue, I'll add some wording to make that clear.

Regarding supported_features, supports, and user_supports, you are
partially correct and it is definitely confusing.  Let me try to shed
some light.

First, $user-supports and $storagebackend-user_supports are the
official interfaces for the application developer.   $user-supports
is obviously the correct call to make if you have a user object  to
work with.  There are situations, such as when working within a
credential, store, or other internal auth module, however, when you
may not have a user yet.   You may still want to know what features
the user will support.  This is where the $store-user_supports comes
in - as it allows you to check what features the user class will have.

$user-supports is a class method - but it is possible that the same
store could return multiple different classes representing a user -
so having the storage module handle this is the only course that
really makes sense.  In many cases $store-user_supports will just
call the user class supports method anyway - but there is no rule
that says this must be the case for every storage module.

Finally - supported_features.  Catalyst::Plugin::Authentication::User
implements supports() - and calls supported_features to retrieve a
hashref of features supported by the user object, and then supports()
does the necessary work to compare this hashref to the features
passed to supports();   In other words, the base user class lets you
be lazy in your user class by simply implementing
supported_features.  There is no rule that says you can't implement
'supports' yourself in your user class, though.

Does this all make sense to you?

Thanks again for the feedback.  I know this is all a little confusing
and I will work on explaining this better in the docs.

JayK

On Mar 4, 2007, at 10:34 AM, Dave Rolsky wrote:


I was trying to figure out why the authen/session integration bits
weren't working and I realized there's a couple problems in the
docs here.

First, AFAICT, there's no mention that beyond setting use_session
to true in your config, you have to indicate that your user class
supports sessions.

Second, the method documentation in C::P::A::Internals suggests
that you should provide a method named supports_features in your
user class. However, looking at the code, it seems like this method
is expected to be named support.

Finally, those same internals docs mention a Store class method
user_supports, which AFAICT is kind of redundant, and not really
used anyway.


-dave

/*===
VegGuide.Orgwww.BookIRead.com
Your guide to all that's veg.   My book blog
===*/

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/
catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


---
America will never be destroyed from the outside. If we falter and
lose our freedoms, it will be because we destroyed ourselves. --
Abraham Lincoln



___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/