Krang::FTP::Server - Virtual FTP Server for Krang Templates and Media
use Krang::ClassLoader 'FTP::Server'; pkg('FTP::Server')->run();
This module provides an FTP interface to Krang Templates and Media. The directory tree is the site/category tree created in Krang. At the top level (/) will be displayed all instances in which the user who has logged in has a valid login/password. Below each instance there are two directories: /template and /media. What appears to be directories below /template and /media actually correspond with Krang::Sites. Below the site dir appears that site's Krang::Category tree as a directory structure. Files within these directories are Krang::Template .tmpl files (in the /template tree),and media files associated with Krang::Media objects (in the /media tree). When a user downloads a .tmpl or media file with Krang::FTP::Server, they recieve the file from the most recent checked-in version of Template/Media object. When a file is uploaded it is automatically checked in and published/deployed.
Below is a sample directory tree as it might appear when logged in to Krang::FTP::Server-
/instance1/ media/ site1/ test.jpg category1/ test.png category2/ test.gif test2.gif site2/ category1/ template/ site1/ test.tmpl category1/ template2.tmpl category2/ site2/ category1/ /instance2/ media/ siteA/ whatever.jpg category1/ siteB/ category1/ graphic.gif category2/ template/ siteA/ category1/ template.tmpl siteB/ story.tmpl category1/ category2/ lastpage.tmpl
For installation and configuration instructions see Krang::Admin
Only GET, PUT and DELETE are implemented for templates and media. No modification of categories is supported.
This module inherits from Net::FTPServer and doesn't override any public methods. See Net::FTPServer for details.
pre_configuration_hook()
This is called by Net:FTPServer before configuration begins. It's used in this class to add our name and version to the version string displayed by the server.
post_accept_hook()
This method is called by Net::FTPServer after a connection is accepted and a child process has been forked. It's used by this class to change to uid/gid to KrangUser/KrangGroup.
$mode - Open mode on the File object (Either reading or writing) $file - File object as returned from DirHandle::open $sock - Data IO::Socket object used for transfering \$buffer - Reference to current buffer about to be written
The \$buffer is passed by reference to minimize the stack overhead for efficiency purposes only. It is not meant to be modified by the transfer_hook subroutine. (It can cause corruption if the length of $buffer is modified.)
Hook: This hook is called after reading $buffer and before writing $buffer to its destination. If arg1 is ``r'', $buffer was read from the File object and written to the Data socket. If arg1 is ``w'', $buffer will be written to the File object because it was read from the Data Socket. The return value is the error for not being able to perform the write. Return undef to avoid aborting the transfer process.
Status: optional.
When a user logs in authentication_hook()
is called to check their
username and password. This method calls
Krang::User->find()
using the given username and then
checks the password. Also stores the Krang::User object into
$self->{user_obj}. Returns -1 on login failure or 0 on success.
root_directory_hook()
Net::FTPServer calls this method to get a DirHandle for the root directory. This method just calls Krang::FTP::DirHandle->new().
system_error_hook()
This method is called when an error is signaled elsewhere in the server. It looks for a key called ``error'' in $self and returns that if it's available. This allows for an OO version of the ever-popular $! mechanism. (Or, at least, that's the idea. As far as I can tell it never really gets called!)