[Catalyst] From Development to Production.

Andrew catalystgroup at unitedgames.co.uk
Wed Mar 9 16:11:11 GMT 2016

  I'd suggest these files are the Model part of MVC and you should have a Class that you use to interact with files. This Class is independent of you Catalyst App and should be able to run in it's own right. Page 135 of the book discussing Database model because that's the common model but there are model class for working with files[1]. There are several references in the book to testing. Testing, along with software versioning are part of the tool-set you'll want to become familiar with if your going to be writing software. You could take a look at the advent calendar articles [2], they are not that up-to-date but useful none the less I'd say.

  ---> I have actually found a lot of the advent calendar articles really useful. I was shocked there weren't any for 2015 though, =P. Did we forget to do it last year / weren't there any volunteers? 

  Using a database would adios your permissions problems too. If you just want to sort out permissions problems, you could have the files/directories owned by the same user that runs you web server or do something fancy with suexec. 

  ---> UPDATE: Oh...do you mean the root user?
  ---> BEFORE-UPDATE: The trouble I experienced with having it owned by the user associated with the web domain was that there were two users needing to access it.
  However, what I've done for a quick fix until I can figure out a better solution, is thrown...
  umask 0000;
  ...into the appname.pm file, and now when I create directories with 0777 permissions, as in a line like: 
  mkdir $my_data_folder_path."new_directory_we_are_making/", 0777;
  ...they're accessible to both users,
  and to enable file reading and writing, I'm just using Path::Tiny's slurp and spew - spew solving the access/permission problem, where append would not.
  So now I've got a quick fix allowing me to get cracking with my work,
  and then I'll read and research on the side how to improve it / what the better ways of doing it are.

  I want to caution you, in the nicest possible way. Writing software requires a number of skills and a lot of research and learning. You can't avoid the latter. What may seem like a lot of unnecessary aggravation (testing and version control) have come about because it's no fun fixing problems after the event.

  ---> Yes, I apologise some of the way I wrote came across as impatient, =). I'm excited to learn, and to reap the long term benefits, =). 

  You could also look at Dancer2 [3] as that be good fit too.

  ---> Thanks for the tip!

  Good luck,

  ---> Many thanks for the page numbers I can flick to, and the links I can visit, =). Grateful!

  1) https://metacpan.org/pod/Catalyst::Model::File
  2) http://www.catalystframework.org/calendar/
  3) https://metacpan.org/pod/distribution/Dancer2/script/dancer2

  On 9 March 2016 at 13:26, Andrew <catalystgroup at unitedgames.co.uk> wrote:

      It sounds to me like you should treat these text files as the data model 

      ---> Are you suggesting I do something to them, or is this just a linguistic point about what to call or refer to the data as?
      I'm new to Catalyst and previously coded in procedural perl, where I always used a policy of: data - processing - layout.
      I equate that to Catalyst's Model - Controller - View. However, my data was always text files, my processing was cgi scripts, and my layout was always html templates.
      I now code with my processing as subroutines within *.pm files within Catalyst's Controller folder,
      however I haven't touched the View or Model folders - am still reading in html templates, substituting values, and spitting them out as the response to the browser - all within my controllers - it's processing after all.

      In short, I'm happy to call my text files the data model, where before I would have called them the data.
      However - are you suggesting I do anything?

      and yes, do not check it in to your repo.

      ---> I have no idea what repo is. Do you mean repository, for a versioning system? Atm, my versioning system is to download the lib folder from the dev server using Cyberduck, and put it in a folder on my computer hard drive - the folder having a version number. Then I can upload whatever version I want to the production server - normally the lib from the latest version folder created. 

       Rather create a model class to access it
      ---> I will have to research how to do this. My resources include google search, and the Definitive Guide to Catalyst book.

       and configure the path in you config file.
      ---> At present, I am reading the path in from a separate text file.

       When it comes to testing you are going to have to create a sample of those text files under the t/ directory.

      ---> Still learning Catalyst and haven't touched testing. I generally don't get it. Either a web app works, or is broken. I don't get writing code to test if code works. Comes across as some sort of coding narcissism.

      Having said that, you should probably find a way to use a database. It sounds to me like your data would fit nicely into a database and your permissions problems to be less significant.

      ---> Yes, I've painless experience of connecting to a MySQL database. I just hoped I could use Catalyst whilst working in the same simple way I worked before, where turn around was very fast. I just have one small task to accomplish, and some files seemed the easiest quickest way to do it, and I've hit all these permission problems, and I just thought it must be such a common problem, someone is bound to have solved it - so I thought to ask the group.

      ---> Right now my solution is super simple - just use spew, and avoid using append.

      ---> If there's any advice or tutorials on how to sort out permissions, or how to use text files as your model in Catalyst, I'd appreciate it. 

      Hope that helps,

      ---> It was insightful, and has given me something to research. Right now I don't understand enough about how Catalyst works to know what creating a model class involves, and if it will solve the permissions problem, or if it was just mentioned as a way of putting the data folder's path into the config file. I shall look into it, and hopefully won't be ignorant for too much longer.

      ---> And thanks for getting back to me! =D

      ---> Yours,
      ---> Andrew.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/catalyst/attachments/20160309/e4f88cba/attachment.htm>

More information about the Catalyst mailing list