[Catalyst] user-specific static directories?

Kieren Diment diment at gmail.com
Fri May 26 06:35:45 CEST 2006


On 19/05/06, Caroline Johnston <johnston at biochemistry.ucl.ac.uk> wrote:
>
> Hi,
>
> Any suggestions on how to go about having user specific static
> directories?
>
> I've got an a catalyst application which generates various plots. I want
> only the logged-in user to be able to view their own plots and I'm using
> C::P::StaticSimple.


Well, I'm going to suggest something becasue your question hasn't been
answered yet, and if I'm wrong someone else should chime in.  I'm also
really interested in using Catalyst and the like in research environments -
my project du jour is http://totaldatasolution.com/colabr8 - so you are my
target market :) (not that I'm directly selling anything mind you).  I can
see molecular bioligists finding my tools particularly useful.

First, it looks like you're application is probably running in a reasonably
trusted environment (like a lab intranet) so actually implementing proper
access control for the image files might be overkill - you just want to
filter out images not belonging to the currently logged in user fro the
display.  So... you're storing the images on the filesystem, and the
ownership of each file in some kind of database.

so in the controller:

$c->stash->{images_list} = $c->model('UserModel')->get_owned_graphs(\%args);

with an appropriate function in MyApp::Model::UserModel to return a data
structure with owned images.

then in the template (I'm suggesting that get_owned_graphs returns an array
of hashes maybe sorted by date):

[% FOREACH image in c.stash.images_list %]
<img src='static/path/[% image.file %]' alt='[% image.alt %]' />
[% END %]

Then you serve up as normal with Static::Simple.


Like I say, I'd be grateful for someone else to sanity check this.  Get on
irc.perl.org#catalyst for some real time help if it doesn't happen through
the mailing list.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20060526/ab9f87d3/attachment-0001.htm 


More information about the Catalyst mailing list