SitePoint Sponsor

User Tag List

Results 1 to 15 of 15

Hybrid View

  1. #1
    ********* Articles ArticleBot's Avatar
    Join Date
    Apr 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Article Discussion

    This is an article discussion thread for discussing the SitePoint article, "CGI::Application: A Simple, Extensible Web Framework"

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, Catalyst is a strong alternative. It has a steep learning curve for those new to frameworks IMHO, and is trying to occupy the same space as Ruby on Rails. But it is nice to use, and some of the team has been working on DBIx::Class - an alternative ORM to Class:BI which of played with briefly and like.

    CGI::Application works well for those who need a simple, lite framework. It doesn't require the huge dependency list of pre-requisite modules. So it's horses for courses, I guess.
    Last edited by redbone; Feb 28, 2006 at 11:19. Reason: fixed typo

  3. #3
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Can someone show me how to integrate the "Extending CGI::Application"-Part?

    I have changed:
    Code Perl:
    package MyApp::User;
    use strict;
    use base 'MyApp::Base';
    ...

    and i have made

    Code Perl:
    package MyApp::Base;
    use base 'CGI::Application';
    use CGI::Application::Plugin::DBH        (qw/dbh_config dbh/);
    use CGI::Application::Plugin::ConfigAuto (qw/cfg cfg_file/);
    use CGI::Application::Plugin::Session;
     
    sub cgiapp_prerun {
    my $self = shift;
    $self->prerun_mode('login');
    }
     
    1;
    ...

    But:
    $self->prerun_mode('login');
    is ignored.


    regards
    este

  4. #4
    SitePoint Wizard bronze trophy KevinR's Avatar
    Join Date
    Nov 2004
    Location
    Moon Base Alpha
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you calling the sub from some where? Subroutines have to be called in order to evaulate whats inside of them.

  5. #5
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    multible constraints

    Dear all,

    Based on this article I made a webapplication.
    For that a have to examine a DNA Sequence for validity.

    Code Perl:
    sub _primer_profile {
    	my $self = shift;
    	use Bio::Seq;
     
    	return {
    		required => [qw( sequence id)],	
    		filters           => ['trim'],
     
    		constraints       => {
     
    			sequence => [				
    			{
    				name       => 'dirty_sequence',
    				constraint => sub {
    					my $self = shift;
    					my $seq = shift;
    					return !($seq =~ m/([^ATCG\n\r\s])/i);
    				},
    				params => [$self, 'sequence']
    			}
     
    			{
    				name       => 'open_sequence',
    				constraint => sub {
    					my $self = shift;
    					my $sequence = shift;
    					$sequence =~s/\s//sg;
    					my $seq = Bio::Seq->new(-id => 'seq', -seq => $sequence,
    					-alphabet => 'dna' );
    					my $l = $seq->length();
    					my $erg = $l % 3;
    					return ($erg == 0);
    				},
    				params => [$self, 'sequence']
    			}
    			],
    		},
     
     
    		msgs => {
    			prefix      => 'err_',
    			missing    => 'No Value entered!',
    			constraints => {	'dirty_sequence' => 'Input is not valid!',
    			'open_sequence' => 'Discontinuous reading-frame',
    			}
    		}
    	};
    }
     
     
     
    #------------------------------------------------------------------------------
    # Process the submitted sequnce
    #------------------------------------------------------------------------------
    sub maintain_sequence {
        my $self = shift;
        my $q    = $self->query;
     
        # validate the input
        use CGI::Application::Plugin::ValidateRM (qw/check_rm/);
        my ($results, $err_page) =
            $self->check_rm('display_primer_form', '_primer_profile');
        return $err_page if $err_page;
     
        $self->display_result_form();
    }

    I want to have more the one error message for one form field.
    So I use multible constraints.

    First, the alphabet is checked. Allowed is only "A,T,G,C".
    Second, the nubmer of characters has to be divided per 3.

    The Problem is, that only the second subroutine is working.
    Maybe the second overwrites the first.

    Please have a look in the code.
    It would be very nice if you can help me.

    best regards
    stephan


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •