Using twod.wsgi with TRAC

78 views
Skip to first unread message

sain...@gmail.com

unread,
Jul 4, 2013, 5:45:05 PM7/4/13
to 2degree...@googlegroups.com
Hello !

I am trying to use your library 2.0b1 to interface Django with Trac.
I have started with a standalone web server for Django and standalone web server for Trac and I used your library to interface them (through views):

from twod.wsgi.embedded_wsgi import call_wsgi_app
from trac.web.main import dispatch_request as trac

def run_trac(request, path_info):
    request.environ['trac.env_path'] = "path/to/trac/env"
    return call_wsgi_app(trac, request, path_info)

However as soon as I import the views.py I got this error:
'WSGIRequest' object has no attribute 'copy'

Indeed it seems that Django class WSGIRequest doesn't have a copy method (I use Djano 1.5.1).
Is that a bug or have I done something wrong ?

Thanks for this useful library !


Euan Goddard

unread,
Jul 5, 2013, 10:07:32 AM7/5/13
to sain...@gmail.com, 2degree...@googlegroups.com
Hi,

We'll take a look at this issue as we're planning to upgrade to Django 1.5 at some point in the near future.

Glad you are enjoying using twod.wsgi!

Euan



--
You received this message because you are subscribed to the Google Groups "2degrees FLOSS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 2degrees-flos...@googlegroups.com.
To post to this group, send email to 2degree...@googlegroups.com.
Visit this group at http://groups.google.com/group/2degrees-floss.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gustavo Narea

unread,
Jul 5, 2013, 10:22:39 AM7/5/13
to 2degree...@googlegroups.com
Hello, saintger.

You seem to be using Django's request class directly. As mentioned in the documentation, you need to use twod.wsgi's request (TwodWSGIRequest) in order for the embeded WSGI apps to work.

Here's how you get Django to use our request class instead of its built-in one:

Does that solve this issue?

Glad you like the library! :)

 - Gustavo.


--
You received this message because you are subscribed to the Google Groups "2degrees FLOSS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 2degrees-flos...@googlegroups.com.
To post to this group, send email to 2degree...@googlegroups.com.
Visit this group at http://groups.google.com/group/2degrees-floss.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Gustavo Narea.
Software Developer.

Saint Germain

unread,
Jul 5, 2013, 10:37:28 AM7/5/13
to 2degree...@googlegroups.com
Hello !

I didn't configure anything about the request, I just followed the
documentation and defined my view.
The urls.py have "/trac" mapped to the view method run_trac, and
run_trac is defined in the views.py. I don't know how to manipulate
'request' type between urls.py and views.py ?
It was written in the twod.wsgi documentation:
When you use this application, your views receive the request as an
instance of TwodWSGIRequest automatically.

Maybe that is because I am using standalone web server (127.0.0.1:8000
for Django and 127.0.0.1:9000 for Trac) ?
I don't have really understood how your application manage to find how
to connect to Trac instance (do I have to specify the port number
somewhere ?).

Thanks again !

sain...@gmail.com

unread,
Jul 7, 2013, 3:28:31 PM7/7/13
to 2degree...@googlegroups.com
Hello,

I finally understood my mistakes and managed to make it work with Django 1.5.
I got the identified problem with the missing "POST" parameter and I had to downgrade to webob 0.9.8.
Other than that I also got a Unicode error with Trac 1.0.1, but it was easy to fix (I just changed unicode to to_unicode).
Now when I logon to Django, I don't have to logon to Trac anymore. Nice ! ;-)

Very useful library, thanks !

Gustavo Narea

unread,
Jul 8, 2013, 4:08:11 AM7/8/13
to 2degree...@googlegroups.com
Thanks! Glad you got it to work.


--
You received this message because you are subscribed to the Google Groups "2degrees FLOSS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 2degrees-flos...@googlegroups.com.
To post to this group, send email to 2degree...@googlegroups.com.
Visit this group at http://groups.google.com/group/2degrees-floss.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Saint Germain

unread,
Jul 10, 2013, 5:53:09 PM7/10/13
to 2degree...@googlegroups.com, gustav...@2degreesnetwork.com
Ah ! I declared victory too soon.
It seems that I run into CSRF protection each time I try to create a
new ticket (or change anything with POST) in Trac.

What is the recommended way to manage CSRF with such an installation ?
Here is my current very simple views.py

def run_trac(request, path_info):
request.environ['trac.env_path'] = 'path/to/env'
return call_wsgi_app(trac, request, path_info)

Should we just deactivate CSRF for this view ?
I feel somehow naked without CSRF protection...

Thanks !

On Mon, 8 Jul 2013 09:08:11 +0100, Gustavo Narea
<gustav...@2degreesnetwork.com> wrote :

Gustavo Narea

unread,
Jul 11, 2013, 4:16:25 AM7/11/13
to 2degree...@googlegroups.com
Hi, Saint.

Yes, you'd have to disable CSRF on that view.

It should represent no vulnerability, since the embedded WSGI app (i.e., Trac) should have its own CSRF checks anyway.

HTH,

 - Gustavo.

Saint Germain

unread,
Jul 11, 2013, 6:40:45 AM7/11/13
to 2degree...@googlegroups.com
Ok thanks, your library is really working well !

Cheers !

Gustavo Narea

unread,
Jul 11, 2013, 7:16:26 AM7/11/13
to 2degree...@googlegroups.com
Cool, thanks!
Reply all
Reply to author
Forward
0 new messages