configure Sumatra server without Docker

82 views
Skip to first unread message

Denis

unread,
Aug 27, 2015, 11:37:15 AM8/27/15
to sumatra-users
Hello,

I am very excited about sumatra and currently I am trying to integrate it my workflow. I would like to have shared records with people from different labs, and I found that I should use Sumatra server. I could install it, but when sumatra tries to store a record there I have a problem with CSRF cookie... I would highly appreciate if you could help! For now I am debugging everything on my localhost. Here there are the steps I did:

1) I cloned the code from https://bitbucket.org/apdavison/sumatra_server/wiki/Home and installed it using:

python setup.py install

2) I created a django project and included the app as it is done in the readme file. I can run the server on:

http://127.0.0.1:8000

If I follow the url: http://127.0.0.1:8000/records/ I can see the message: "You have no projects."

3) I created a sumatra project:

smt init --store=http://127.0.0.1:8000/records/

smt configure --executable=python --main=simulate.py


4) I run it with:

smt run default.param

I have an error:

<body>
<div id="summary">
  <h1>Forbidden <span>(403)</span></h1>
  <p>CSRF verification failed. Request aborted.</p>


  <p>You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons, to ensure that your browser is not being hijacked by third parties.</p>
  <p>If you have configured your browser to disable cookies, please re-enable them, at least for this site, or for &#39;same-origin&#39; requests.</p>

</div>

<div id="info">
  <h2>Help</h2>
    
    <p>Reason given for failure:</p>
    <pre>
    CSRF cookie not set.
    </pre>
    

  <p>In general, this can occur when there is a genuine Cross Site Request Forgery, or when
  <a
  CSRF mechanism</a> has not been used correctly.  For POST forms, you need to
  ensure:</p>

  <ul>
    <li>Your browser is accepting cookies.</li>

    <li>The view function passes a <code>request</code> to the template's <a
    method.</li>

    <li>In the template, there is a <code>{% csrf_token
    %}</code> template tag inside each POST form that
    targets an internal URL.</li>

    <li>If you are not using <code>CsrfViewMiddleware</code>, then you must use
    <code>csrf_protect</code> on any views that use the <code>csrf_token</code>
    template tag, as well as those that accept the POST data.</li>

  </ul>

  <p>You're seeing the help section of this page because you have <code>DEBUG =
  True</code> in your Django settings file. Change that to <code>False</code>,
  and only the initial error message will be displayed.  </p>

  <p>You can customize this page using the CSRF_FAILURE_VIEW setting.</p>
</div>

</body>

It seems that my browser is accepting cookies. All solutions from stackoverflow suggest doing something with django... and I have a very little experience with it. So I thought maybe someone from sumatra community already encountered this problem or could help with how to fix it?

Best regards,
Denis

Andrew Davison

unread,
Aug 31, 2015, 10:32:10 AM8/31/15
to sumatr...@googlegroups.com
Hi Denis,

> On 27 Aug 2015, at 17:37, Denis <denis.s...@gmail.com> wrote:
>
> I am very excited about sumatra and currently I am trying to integrate it my workflow. I would like to have shared records with people from different labs, and I found that I should use Sumatra server. I could install it, but when sumatra tries to store a record there I have a problem with CSRF cookie... I would highly appreciate if you could help! For now I am debugging everything on my localhost.

This is a problem with the README file, which is a bit out of date.

In your settings.py, in the MIDDLEWARE_CLASSES dict, delete or comment out the entry 'django.middleware.csrf.CsrfViewMiddleware'

Assuming this solves your problems, the next step is to set up user accounts, etc. For an example of how to do this, I suggest taking a look at https://bitbucket.org/apdavison/sumatra_server_example

Best regards,

Andrew


--
Dr Andrew Davison
Unité de Neurosciences, Information et Complexité (UNIC)
Centre National de la Recherche Scientifique
1, avenue de la Terrasse
91198 Gif sur Yvette
France

Tel: +33 1 69 82 34 51
http://www.andrewdavison.info/








Denis

unread,
Sep 1, 2015, 5:10:26 PM9/1/15
to sumatra-users
Dear Andrew,

Thank you a lot for your reply! The commenting out the string indeed helped me to solve the initial problem. 

Now, I am looking at the example you suggested, but I have some problem with using it. I can load the server using:

python manage.py runserver

I have a page with "Welcome to the Sumatra Server test site...." But if I go to any of links, e.g. "List of public projects" or "Login" I get an error "no such table: django_site".

Also, I tried to create a project using:

smt init --store=http://127.0.0.1:8000/records/ TestSumatra

And I get a long error message:


<div id="summary">
  <h1>OperationalError at /records/TestSumatra/</h1>
  <pre class="exception_value">no such table: django_store_project</pre>
  <table class="meta">

    <tr>
      <th>Request Method:</th>
      <td>GET</td>
    </tr>
    <tr>
      <th>Request URL:</th>
    </tr>

    <tr>
      <th>Django Version:</th>
      <td>1.8.4</td>
    </tr>

    <tr>
      <th>Exception Type:</th>
      <td>OperationalError</td>
    </tr>

Do you have any idea what did I miss? I guess I have to create an account on the server now... where should I do that?

Best regards,
Denis

Andrew Davison

unread,
Sep 2, 2015, 4:29:38 PM9/2/15
to sumatra-users
Dear Denis,


On Tuesday, 1 September 2015 23:10:26 UTC+2, Denis wrote:
Dear Andrew,

Thank you a lot for your reply! The commenting out the string indeed helped me to solve the initial problem. 

Now, I am looking at the example you suggested, but I have some problem with using it. I can load the server using:

python manage.py runserver

I have a page with "Welcome to the Sumatra Server test site...." But if I go to any of links, e.g. "List of public projects" or "Login" I get an error "no such table: django_site".

Also, I tried to create a project using:

smt init --store=http://127.0.0.1:8000/records/ TestSumatra

And I get a long error message:


<div id="summary">
  <h1>OperationalError at /records/TestSumatra/</h1>
  <pre class="exception_value">no such table: django_store_project</pre>
  
 
<snip> 

Do you have any idea what did I miss? I guess I have to create an account on the server now... where should I do that?

Best regards,
Denis


Did you run

  python manage.py migrate

or 

  python manage.py syncdb

?

It sounds as though the database tables haven’t been created. If you did, then please carefully list all the steps you took to install the code, as I cannot reproduce your errors.

Once you have things running, you should run 

  python manage.py collectstatic

and then create an admin user with

  python manage.py createsuperuser

You can then go to http://127.0.0.1:8000/admin/ and create other user accounts.

All the best,

Andrew
Reply all
Reply to author
Forward
0 new messages