Re: [cgi-prototype-users] CGI::Prototype::PathInfo resource tokenizing

2005-09-09 Thread A. Pagaltzis
* Terrence Brannon [EMAIL PROTECTED] [2005-09-09 21:05]:
 I think the resource id should be a reference to an anonymous
 array
  [ 283188, 43 ]

Then split the string into an array and save it in a slot in
`app_enter`?

It might be a good thing if this were the default behaviour, but
I have no basis on which to make that call, so I didn’t.

Regards,
-- 
#Aristotle
*AUTOLOAD=*_=sub{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1};
Just-another-Perl-hacker;


---
SF.Net email is Sponsored by the Better Software Conference  EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile  Plan-Driven Development * Managing Projects  Teams * Testing  QA
Security * Process Improvement  Measurement * http://www.sqe.com/bsce5sf
___
cgi-prototype-users mailing list
cgi-prototype-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cgi-prototype-users


[cgi-prototype-users] CGI::Prototype::PathInfo unified diff

2005-09-05 Thread Terrence Brannon

Here is my unified diff of the attachment you emailed earlier. I like
this module a lot and will be retooling my simple guestbook app to use
it. This is our first step towards a CGI::Prototype on Rails type
thing. Maybe we could publish a Perl Review article if everything is
clean and easy to follow. 

I am going to play with DBIx::SQLEngine for the database part of this
based on a recent discussion between Simon and Sebastien about their
interests in it.

[EMAIL PROTECTED]:~/perl/dl$ diff -u PathInfo.pm.orig PathInfo.pm
--- PathInfo.pm.orig2005-09-05 11:34:56.0 +
+++ PathInfo.pm 2005-09-05 12:46:14.0 +
@@ -57,38 +57,73 @@
 
 =head2 ENVIRONMENT INFORMATION SLOTS
 
+These slots provide access to information about the request loosely modelled
+on the REST architectural elements described in sectoin 5.2 of Fielding's
+seminal Ph.D disseration on the subject:
+
+http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_5_2
+
 =over 4
 
-=item resource_type
+=item resource_name
+
+The resource name is, to quote Fielding, the intended conceptual target of 
+a hypertext reference. This would imply that such a target is a noun but in
+practical terms it may not be. In practical terms, the Cresource_name is the
+first thing after the domain name and the cgi-script in the URL. Examples:
+
+http://metaperl.org/guestbook/sign has domain metaperl.org, cgi-script
+Cguestbook and Cresource_name sign
+Here we are providing a resource to sign the guestbook.
 
-FIXME
+=item resource_qualifiers
 
-=item resource_id
+path elements after the the resource name. Example:
 
-FIXME
+http://www.livingcosmos.org/meditation/ernest-wood/notes/
+
+would bind @resource_qualifiers to qw(ernest-wood notes)
+and of course resource_name would be 'meditation'
+
+This was initially a scalar named Cresource_id but it is clear that many
+websites use more than one element after the resource_name, Drupal for 
+instance:
+http://sequence.complete.org/node/add/blog
 
 =back
 
+It is important to note that some resources just use paths to logically
+categorize all of its information. Taking the livingcosmos.org URL above, 
+meditation is not a service or resource as much as it is just an area on a 
+website. However, having access the path info is useful for dynamically 
+rendering the look-and-feel of a website without resorting to things like
+HTML::Mason and its autohandler.
+
 =cut
 
 sub prototype_enter {
-   my $self = shift;
+  my $self = shift;
 
-   $self-SUPER::prototype_enter();
+  $self-SUPER::prototype_enter();
 
-   my ( $resource, $id ) = $self-parse_path( $self-CGI-path_info() );
-   $self-reflect-addSlot( resource_type = $resource, resource_id = $id 
);
+  my ( $resource, @qual ) = $self-parse_path( $self-CGI-path_info() );
+  $self-reflect-addSlot( 
+resource_name = $resource, 
+resource_qual = [EMAIL PROTECTED] 
+   );
 }
 
 =head2 MANAGEMENT SLOTS
 
-This is where the real changes over LCGI::Prototype::Hidden lie.
+This is where CGI::Prototype::PathInfo is quite different from 
+LCGI::Prototype::Hidden
 
 =over 4
 
-=item name_to_page
+=item resource_name_to_page
 
-Called with a page name, translates it to a package name, and returns a page
+Called with a resource name, translates it to a package name, and 
+returns a page
 object. Will also autoload the package.
 
 This module expects page names to look like relative URLs and will translate to
@@ -98,22 +133,23 @@
 =cut
 
 sub name_to_page {
-   my $self = shift;
-   my ( $name ) = @_;
+  my $self = shift;
+  my ( $name ) = @_;
 
-   my $pkg = join '::', (
-   $self-config_class_prefix,
-   split( m{/}, $self-validate_name( $name ) ),
-   );
+  my $pkg = join '::', (
+$self-config_class_prefix,
+split( m{/}, $self-validate_name( $name ) ),
+   );
+
+  if ( do { no strict 'refs'; not defined ${ $pkg . '::' } } ) {
+eval require $pkg;
+die $@ if $@;
+  }
 
-   if( do { no strict 'refs'; not defined ${ $pkg . '::' } } ) {
-   eval require $pkg;
-   die $@ if $@;
-   }
-
-   return $pkg-reflect-object;
+  return $pkg-reflect-object;
 }
 
+
 =item dispatch
 
 Overridden from LCGI::Prototype::Hidden. Selects either the page named
@@ -127,7 +163,7 @@
 
my $prefixes = join '|', map quotemeta, $self-config_valid_pages;
 
-   return $self-name_to_page( $self-resource_type || 
$self-config_default_page );
+   return $self-name_to_page( $self-resource_name || 
$self-config_default_page );
 }
 
 =item render_enter
@@ -186,17 +222,38 @@
 
 LCGI::Prototype::Hidden, LCGI::Prototype, LTemplate::Manual
 
+=over 4
+
+=item Paul Prescod's REST resources
+
+Lhttp://www.prescod.net/rest/
+
+=item the REST wiki
+
+Lhttp://rest.blueoxen.net/cgi-bin/wiki.pl?FrontPage
+
+=item The REST discussion email list
+
+Lhttp://groups.yahoo.com/group/rest-discuss/
+
+
+=back
+
+
+
 =head1 BUG REPORTS
 
-Please report any bugs or feature 

Re: [cgi-prototype-users] CGI::Prototype::PathInfo

2005-08-15 Thread Randal L. Schwartz
 A == A Pagaltzis [EMAIL PROTECTED] writes:

A Looks sensible enough, but the mapper must be more abstract than
A you propose. Abstraction on the level you have in mind is not
A tenable because ::State::Pathinfo needs knowledge from
A ::Mapper::StrictLookup to be able to tell that

A /edit/user/ap

A is supposed to mean

A state = 'My::App::edit::user',
A positional_param = ['ap'],

A rather than

A state = 'My::App::edit',
A positional_param = ['user,'ap'],

A or

A state = 'My::App::edit::user::ap',
A positional_param = [],

Ewww.  I'd never use code like that.  But if you want to do it,
I suppose you can replace all of -dispatch isntead.

A How would a generic protocol for ::State::* to ask ::Mapper::*
A for possible states look? Is it sensible to define one?
A ::Mapper::Prefix would have to crawl @INC or something like that,
A f.ex.

Yeah, hadn't envisioned that.  In my mind, state should come entirely
from the incoming environment.  Mapping that to a class should be a
separate responsibility for maximum pluggability.  Looks like the
best way is to leave -dispatch and call yours something like

CGIP::Dispatch::VariablePathinfo

or something like that, using ::Dispatch:: rather than ::State:: or
::Mapping:: to show that it's replacing both.

A After all is said and done, ::State::Pathinfo will have to be
A specific to ::Mapper::StrictLookup anyway, so that separation
A makes no sense. The only thing that does make sense to abstract
A is how a state is mapped to a class *after* it is fully looked up
A and validated.

A But that is so trivial a task that I don’t really see the point
A in a separate ::Mapper::* hierarchy. Putting a -get_class with a
A default `eval require ${prefix}::${state}` implementation into
A CGIP would suffice.

I'm presuming the default -get_class simply returns the prefixed
string classname, which is presumedly defined using some other means
(like all in one file).  The autoload override allows it to be
dynloaded if it doesn't exist, but there are CGIP instances where that
won't be necessary, and I'm trying to keep the core CGIP as lean as
possible.

Consider also something like Slashdot, where the templates are loaded
from a database... I can also see that here.  Maybe state-to-class is
dynamic based on current user ID or other security parameter?  Really,
there's policy there, and it's best to let that be plugged in.

But if you need to poke around in order to even know the state, you've
got a tight coupling there, so you're going to be overriding all of
-dispatch, it seems.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


---
SF.Net email is Sponsored by the Better Software Conference  EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile  Plan-Driven Development * Managing Projects  Teams * Testing  QA
Security * Process Improvement  Measurement * http://www.sqe.com/bsce5sf
___
cgi-prototype-users mailing list
cgi-prototype-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cgi-prototype-users


Re: [cgi-prototype-users] CGI::Prototype::PathInfo

2005-08-15 Thread Randal L. Schwartz
 Randal == Randal L Schwartz merlyn@stonehenge.com writes:

Randal Consider also something like Slashdot, where the templates are loaded
Randal from a database... I can also see that here.  Maybe state-to-class is
Randal dynamic based on current user ID or other security parameter?  Really,
Randal there's policy there, and it's best to let that be plugged in.

To further this, let's say I had a $big_client that needs to show a
login page if the user isn't logged in, regardless of whatever state
the -get_state returns.  They can override -get_class to simply
return the login page if not logged in, regardless of whatever state
it's asked to show, and yet the old state is preserved for a return
to FOO link.  And then the -get_state can be changed from hidden
fields to pathinfo without messing up the authorization section.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


---
SF.Net email is Sponsored by the Better Software Conference  EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile  Plan-Driven Development * Managing Projects  Teams * Testing  QA
Security * Process Improvement  Measurement * http://www.sqe.com/bsce5sf
___
cgi-prototype-users mailing list
cgi-prototype-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cgi-prototype-users


Re: [cgi-prototype-users] CGI::Prototype::PathInfo

2005-08-15 Thread A. Pagaltzis
* Randal L. Schwartz merlyn@stonehenge.com [2005-08-15 19:50]:
 Ewww.  I'd never use code like that.

At the HTTP level, it is cleaner design. Nobody on the other side
of the app interface will care whether it requires uglier
scaffolding under the hood, nor should they. Thus, neither do I.

 Yeah, hadn't envisioned that.  In my mind, state should come
 entirely from the incoming environment.  Mapping that to a
 class should be a separate responsibility for maximum
 pluggability.  Looks like the best way is to leave -dispatch
 and call yours something like
 
CGIP::Dispatch::VariablePathinfo
 
 or something like that, using ::Dispatch:: rather than
 ::State:: or ::Mapping:: to show that it's replacing both.

I suppose that I’ll stick with the current monolithic design and
mind my own business for the time being, then. Since ::PathInfo
builds onto CGIP itself it should be unaffected by stuff that
gets added on top of that. I will see how it can be merged with
the future CGIP design that materializes.

Regards,
-- 
#Aristotle
*AUTOLOAD=*_=sub{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1};
Just-another-Perl-hacker;


---
SF.Net email is Sponsored by the Better Software Conference  EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile  Plan-Driven Development * Managing Projects  Teams * Testing  QA
Security * Process Improvement  Measurement * http://www.sqe.com/bsce5sf
___
cgi-prototype-users mailing list
cgi-prototype-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cgi-prototype-users


Re: [cgi-prototype-users] CGI::Prototype::PathInfo

2005-08-11 Thread Randal L. Schwartz
 A == A Pagaltzis [EMAIL PROTECTED] writes:

A Ok, so I’d like to dive in there and get the bits moving right
A now, but I don’t want to step on any toes, particularly with
A architectural (more or less) decisions like this one. How are we
A going to be handling issues like this one?

I've checked in the current releases to dist/* in the CVS.  If you
are proposing a separate release, feel free to start another leg.  If
you are thinking that the release currently called CGI-Prototype
should be altered, we can talk about making the changes directly
there.

Let's settle on the naming first... :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


---
SF.Net email is Sponsored by the Better Software Conference  EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile  Plan-Driven Development * Managing Projects  Teams * Testing  QA
Security * Process Improvement  Measurement * http://www.sqe.com/bsce5sf
___
cgi-prototype-users mailing list
cgi-prototype-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cgi-prototype-users


Re: [cgi-prototype-users] CGI::Prototype::PathInfo

2005-08-11 Thread A. Pagaltzis
* Randal L. Schwartz merlyn@stonehenge.com [2005-08-11 17:20]:
 If you are thinking that the release currently called
 CGI-Prototype should be altered, we can talk about making the
 changes directly there.

Well, kinda; I was hoping to start refactoring ::Hidden into bits
that can be reused in ::PathInfo and others and those which
can’t. ::PathInfo could then be separate or be part of the
distro, but that’s a different issue.

I’d like to know your thoughts on this; see my previous, more
detailed mail.

 Let's settle on the naming first... :)

We need to sort out the structure first; do you agree with my
assessment that the state-to-class mapper can be reused by state
deductors, but vice versa does not work so well?

I used ::Simple for the mapper in ::Hidden which ::PathInfo would
reuse, but I’m not wedded to that name at all.

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


---
SF.Net email is Sponsored by the Better Software Conference  EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile  Plan-Driven Development * Managing Projects  Teams * Testing  QA
Security * Process Improvement  Measurement * http://www.sqe.com/bsce5sf
___
cgi-prototype-users mailing list
cgi-prototype-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cgi-prototype-users