translate / pootle

Online translation tool
http://pootle.translatehouse.org
GNU General Public License v3.0
1.48k stars 287 forks source link

Can not request REST API #6774

Open MajPay opened 7 years ago

MajPay commented 7 years ago

Hello,

i am sorry if i missed the documentation part but i would not ask if i was not sure, that i read it all...

I am completely new to pootle and have very little experience with python. I wanted to setup a pootle server to manage translations for different projects. My goal is a build task (in another project), that pulls the current translations from the pootle server i am planning to have. Now - getting started - was not as easy as expected, the installation instructions turned out to be not so straight-forward as i hoped it to be but still - i managed to have a working pootle installation via a vagrant setup.

Now to my actual problem:

I want to access translations via a http api, pootle seems to have that built-in (more or less), so i installed the required "django-tastypie" package (pip install django-tastypie), added the configuration options to my pootle.conf

POOTLE_ENABLE_API = True
INSTALLED_APPS += ['tastypie']

and restarted everything.

Now - when accessing the api via httpie

http -a 'user:pass' 'http://pootle.dev:8084/api/v1/'

it will only return the 404 page of pootle.

My setup is powered by MySQL and nginx.

I dont think the MySQL part is of any importance but my nginx config is like:

server {
    listen  80;
    server_name  pootle.dev;
    gzip on;
    charset utf-8;

    location /assets {
        alias /vagrant/env/lib/python2.7/site-packages/pootle/assets/;
        expires 14d;
        access_log off;
    }

    location / {
        proxy_pass http://localhost:8000;
        proxy_redirect off;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

(the port 8084 is tunneled via Vagrant/VirtualBox)

pip freeze says:

Babel==2.5.0
bleach==2.0.0
certifi==2017.7.27.1
chardet==3.0.4
click==6.7
cssmin==0.2.0
diff-match-patch==20121119
dirsync==2.2.2
Django==1.10.8
django-allauth==0.33.0
django-appconf==1.0.2
django-assets==0.12
django-bulk-update==2.2.0
django-contact-form==1.4.2
django-contrib-comments==1.7.3
django-overextends==0.4.3
django-redis==4.8.0
django-rq==0.9.6
django-sortedm2m==1.5.0
django-statici18n==1.4.0
django-tastypie==0.14.0
html5lib==1.0b10
idna==2.6
jsonfield==2.0.2
lxml==3.8.0
Markdown==2.6.9
MySQL-python==1.2.5
oauthlib==2.0.4
pathlib==1.0.1
pkg-resources==0.0.0
Pootle==2.9.0rc1
pycountry==17.5.14
python-dateutil==2.6.1
python-Levenshtein==0.12.0
python-mimeparse==1.6.0
python-openid==2.2.5
pytz==2017.2
redis==2.10.6
requests==2.18.4
requests-oauthlib==0.8.0
rq==0.8.2
scandir==1.5
six==1.11.0
stemming==1.0.1
translate-toolkit==2.2.5
urllib3==1.22
webassets==0.12.1
webencodings==0.5.1

There must be one point that i missed...

Thank you in advance

phlax commented 7 years ago

hi @MajPay

i think there are quite a few more steps required to use tastypie.

Firstly you would need to specify resources - see here https://django-tastypie.readthedocs.io/en/latest/tutorial.html#creating-resources

You would also need to add a url config https://django-tastypie.readthedocs.io/en/latest/tutorial.html#hooking-up-the-resource-s

Pootle has a minimal api already - but only for managing certain types of resources

Feel free to ping us on https://gitter.im/translate/dev if you wish to discuss further