<div dir="ltr"><div><div>I thought I would share a bash script since Barton mentioned mucking with the environment.  Thought in the context of this discussion it might not be appreciated.<br><br></div>To use the script just log into Koha on any computer, and use this script on the server to get into perl's debugging mode.  If the script is named Koha_cli.bash, then call it on the server like `bash Koha_cli.bash SESSION_ID_FROM_COOKIE perl -d SCRIPT_TO_DEBUG`<br><br></div>Anyway, here's the script:<br><div><br>#!/bin/bash<br><br># Environment variables to set before running Koha scripts or pages<br>#  from the command line<br><br>export KOHA_CONF=/usr/local/koha3.2/etc/koha-conf.xml<br>export PERL5LIB=/usr/local/koha3.2/lib<br><br># those two, of course, and<br><br>export HTTP_COOKIE="CGISESSID=$1"<br>export REMOTE_ADDR=205.126.61.239<br>#export REMOTE_ADDR=127.0.0.1<br><br># These make it look like I'm coming from my laptop<br>#  after I've logged into Koha from my laptop<br># Just have to check the CGISESSID cookie on my laptop, and pass it to this<br><br># Next, run the script<br>shift  # Drop session id<br>exec $*<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 30, 2015 at 10:28 AM, Barton Chittenden <span dir="ltr"><<a href="mailto:barton@bywatersolutions.com" target="_blank">barton@bywatersolutions.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Sep 30, 2015 at 10:18 AM, Tomas Cohen Arazi <span dir="ltr"><<a href="mailto:tomascohen@gmail.com" target="_blank">tomascohen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><span>2015-09-30 9:20 GMT-03:00 Philippe Blouin <span dir="ltr"><<a href="mailto:philippe.blouin@inlibro.com" target="_blank">philippe.blouin@inlibro.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div>Because the code would be extremely
      specific to a specific functionality, whereas the code in the
      libraries is there to be reused.<br>
      And let not go overboard with OO.<br></div></div></blockquote><div><br></div></span><div>We embrace the OO paradigm for most of the CRUD operations, but we also have libs containing functions that are used statically, like Koha::Util::MARC, that do specific things and are testable. And is only used in a couple places.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><div>
      A script is a script is a script.  Make it readable, add functions
      to make it cleaner, make your functions readable.<br></div></div></blockquote><div><br></div></span><div>We have two main kind of scripts: command line scripts, and controller scripts that got too complicated during Koha's life, and we are trying to simplify "as we go".</div><div><br></div><div>I think both should be testable.</div></div></div></div></blockquote><div><br></div></span><div>I would like to make a plea here from a support / trouble-shooting perspective:</div><div><br></div><div>The controller scripts are hard to trouble-shoot, because they're CGI -- it's theoretically possible to run the perl debugger across them, but that requires a fair amount of mucking with the environment... If I'm trying to figure out what's happening with some chunk of code, I'd like to write a command line wrapper around a library, and trigger the bits that I want in a controlled manner. I can't do that with any of the code inside the controllers.</div><div><br></div><div>Keeping the code in the controllers thin is important not only for test-ability from a unit testing perspective, but also from a trouble-shooting perspective, because they end up being black-boxes that only run inside of Apache.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>--Barton</div></font></span></div></div></div>
<br>_______________________________________________<br>
Koha-devel mailing list<br>
<a href="mailto:Koha-devel@lists.koha-community.org">Koha-devel@lists.koha-community.org</a><br>
<a href="http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer" target="_blank">http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br>
website : <a href="http://www.koha-community.org/" rel="noreferrer" target="_blank">http://www.koha-community.org/</a><br>
git : <a href="http://git.koha-community.org/" rel="noreferrer" target="_blank">http://git.koha-community.org/</a><br>
bugs : <a href="http://bugs.koha-community.org/" rel="noreferrer" target="_blank">http://bugs.koha-community.org/</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div>Michael Hafen<br></div>Washington County School District Technology Department<br></div>Systems Analyst<br><div><br><img src="http://logos.washk12.org/100year.png"><br></div></div></div>
</div>