http://qs321.pair.com?node_id=562107

Nkuvu has asked for the wisdom of the Perl Monks concerning the following question:

I have an idea for a very small, simple tool that myself and a few others have expressed interest in. The basic concept for the tool is to display a table of character progress in a game. Implementing this in a spreadsheet takes about five minutes, and export to HTML is relatively simple (depending on the spreadsheet application). This is just to give the scope of the tool. It's really simplistic.

But I'd like to be able to do this on the web, even though I've never created any sort of web applicaton before. I have the hosting space, which will allow some friends to display their progress simply without having to worry about web hosting or setup or HTML export, or... The problem I'm having is coming up with a decent development strategy.

As mentioned, I've never done web application development. I have a few simple web pages, but that's about it. So I asked in the chatterbox for some places to start. Two good suggestions were Catalyst and/or CGI::Application.

I spent much of the weekend reading over the Catalyst documentation. I already had an idea of the MVC approach, but read further into it, and decided that it's definitely the approach I like (I should also note that a friend has offered to help with design, so separating that to a View is beneficial). I did a quick test on installation on my home machine. As root I was unable to get Catalyst installed. Too many dependencies, and the CPAN shell cried every time I tried to install Module::Build.

So I went with an alternate approach, Catalyst in a Box. Installation was super quick and painless. I started working through the tutorial last night. I got about to the spot where you add in authentication, only to find that the CatInABox does not include the required Catalyst plugin. Attempts to install this met with significant issues (more of the same issues I've noted above).

Another thing to keep in mind is that I'm not root on my webhost. I have hosting through Speakeasy, so it's possible that I could have them install Catalyst. At the moment, though, it is not set up. Neither is CGI::Application. And if CatInABox doesn't have the plugins/modules I need, I'm not going to be able to set up Catalyst for use on my webhost.

At this point I started to realize that the development of the tool is significantly more involved than the tool itself. In about an hour's work, I wrote a simplistic script to generate the HTML I want. It has a non-user-friendly input scheme, but the script works.

What I'd really like is to find something simple to add in all of the extra features I want. Without the painful installation of Catalyst. I'm looking to add user creation/authentication. Export of some basic information to an HTML table. Possibly a form to contact individual users (like the /msg feature). And preferably using some very basic modules.

I don't mind learning new things at all. But for this tool, I just want an "add water and create instant website" sort of simplicity. Suggestions greatly appreciated.

Replies are listed 'Best First'.
Re: Web application development
by eric256 (Parson) on Jul 18, 2006 at 20:36 UTC

    Not Directly an answer, but a muse: It would seem that this question is asked fairly often. In fact i think we've all dealt with the "creating a user management system from scratch for every new prject" issue. I wonder we could generalize on solution to at least make an easy jump off. For instance provide a database schema (in the form of a setup script that logins in to your database and creates the needed tables) a set of default templates and a set of default code. I for one would love something that handled user creation/mangament/ and authentication right out of the box without then handling anything else. Is there something like this already out there? Is it something everyone has wanted and no one has made? How hard would this be and what would be the best way to keep it somewhere public that could be maintained by the community? I think perhaps I've gone a little OT and so will quite for now, but expect a Meditaion on just this soon! I think a general toolkit for using (CGI::Application + HTML::Template = User Administration) could go a long way towards jump starting some projects. I know that I for one could realy use such a thing!

    BTW Thats my answer, use CGI::Application + HTML::Template, both can be installed pretty much anywhere in my experience which is exactly why i'd use them for my little project ;)


    ___________
    Eric Hodges

      I don't think you're OT at all. That's exactly the sort of thing I'm looking for. An out-of-the-box user authentication system.

      For this particular project I don't expect to be using a database at all. The amount of information I intend to store is only a few lines per user. So having this stored in a simple text file should be perfectly sufficient.

      The brief bit I did with Catalyst seems like it's the type of thing I want. But getting it installed on my webhost... eesh.

        I think you missed the point. I want something simple and done. I don't want to worry about getting Catalyst to work which should have had Authorization/Authentication as its very first ability anyway ;) I'm working on a meditation with my ideal interface, and then i can work backwards to an implementation. Basicaly I just want a working Authentication/Authorization system plus a ready built User management system that can be bolted onto existing scrips simple and used in a more core fashion on extensive programs. Picture a work setting where we already have 10-20 scripts running and want to add security to them better than "you don't know the right URL so i don't need to worry about you running this!" ;) I don't mean to knock Catalyst but i've tried using it in the past and it never realy felt like a module to add to your program, more like an entire framework that you had to work inside and understand before it could be of much use. It probably fits its niche well, i'm just not a member of said niche.


        ___________
        Eric Hodges
Re: Web application development
by CountZero (Bishop) on Jul 19, 2006 at 05:49 UTC
    If you are in a pinch and do not need very sophisticated user-management, you could probably settle for the very simple and basic ".htaccess" authentication / authorization system. The web-server will provide you with all user-data through environment-variables and of course you will have to "manage" your users yourself, which in Catalyst you would typically do through some auto routines.

    PS: That being said, I installed Catalyst both on Windows and Linux ("Mandrake") and had no real problems in doing so. Yes it took several runs of CPAN to get everything in (carefully noting the dependencies it needed and sometimes installing these separately; and on Windows switching between CPAN and ppm as needed), but nothing unsurmountable. I did have root-access on both machines and that certainly helped

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Web application development
by mikasue (Friar) on Jul 18, 2006 at 19:38 UTC
    Have you looked into Template::Toolkit?
Re: Web application development
by diotalevi (Canon) on Jul 18, 2006 at 20:27 UTC

    I understand Catalyst is a sort of "assemble lots of parts" kind of kit. I also hear Jifty is kind of pre-assembled. You'll need to get your Module::Build installed though. There was an issue yesterday with it an version which was resolved by late afternoon (US time). You should try again.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re: Web application development
by Rhandom (Curate) on Jul 19, 2006 at 15:03 UTC
    Two modules that seem to still be in obscurity (probably intended) are CGI::Ex::Auth and CGI::Ex::App. Both are part of the CGI::Ex suite of tools. The Auth module can be used to add customizable cookie based authentication to any application, and App is a hook based base-layer to build applications on top of (it is a framework - but not in the same sense that Catalyst is a framework). CGI::Application often doesn't go far enough and Catalyst often goes too far.

    For example, if you use CGI::Ex::App as your base layer - then you can add authentication to all of your applications with the following code:

    sub require_auth { 1 } sub get_pass_by_user { my $self = shift; my $user = shift; my $pass = $self->lookup_and_cache_the_pass($user); return $pass; }


    Using CGI::Ex::Auth alone isn't much more complicated.

    my @a=qw(random brilliant braindead); print $a[rand(@a)];
Re: Web application development
by techcode (Hermit) on Jul 20, 2006 at 22:17 UTC
    Since you are just starting out I would suggest CGI::Application as better choice. It doesn't abstract as much things as Catalyst does. Sure, it has magic, but it's easier to understand - you can start faster.

    The other option is HTML::Template or TemplateTolkit. I was using H::T but moved to TT as I needed some stuff that were pain to make in H::T and already supported by TT ... And TT also has caching support out of the box, that even under plain CGI gets you x2 more requests while testing with Apache/bin/ab.

    Anyway, you should be able to just copy these in some folder on your server and add that folder to the @INC (use lib 'relative/or/full/path';). There is an option while installing TT (on your local/dev computer) not to use XS (C) code ...


    Have you tried freelancing? Check out Scriptlance - I work there. For more info about Scriptlance and freelancing in general check out my home node.

      You're the second person to mention TT. And I'm not sure I understand.

      I have used Template::Toolkit before. I made a bunch of web pages based on a template, and altered individual content to suit. But I don't see how TT would help with user authentication. Unless you're not recommending TT for user authentication, that is.

        We were mentioning TT because it's good and some of template modules was ment to be used with CGI::App (or other MVC frameworks). So obviosly it doesn't help much with authentication. Closest thing would be to display one thing (perhaps menu) to auth. user, and another thing (login form) to non-auth. users.

        Anyway TT can be used for generating lot's of pages from one template. But it's more usefull if you use it to separate perl code (Model in Mvc) and html (View in mVc) ...


        Have you tried freelancing? Check out Scriptlance - I work there. For more info about Scriptlance and freelancing in general check out my home node.
Re: Web application development
by Trix606 (Monk) on Jul 20, 2006 at 14:19 UTC

      Thanks for pointing this out. Although I was confused at first, I could have sworn I mentioned this. But I guess that was in the Chatterbox.

      I've read through Ovid's tutorial. I did the examples he had listed, and got some basic authentication going. But there were some holes in the tutorial that didn't quite answer my initial issues.

      For example, generation of a session ID. Ovid kind of glossed over this. From a few searches I've determined that the session ID is just a randomly generated unique string. Guaranteeing a unique value sounds pretty easy with a module like Data::GUID, which I'll have to look into getting installed on my webhost.

      Also the tutorial is very light on cookies and session info. I can set up a login, but keeping track of who is logged in and who isn't... not really addressed. I'm still working on that one.

      So really what I need is something to bridge from Ovid's basic course to the CGI documentation (which also seems to leave a lot of things unanswered). But in any case, thanks for the suggestion.