Search code examples
pythondjangoattributeerror

Django XMMS2: 'module' object has no attribute 'XMMS'


I just started to use Python so the following might be a really REALLY dumb question but I searched the web for a long time and didn't find anything.

I'm trying to use the XMMS2 client from a Django View. Here is what I have in my views.py:

import xmmsclient
import os
import sys

def list(request):
    xmms = xmmsclient.XMMS("tutorial1")
    xmms.connect(os.getenv("XMMS_PATH"))
    result = xmms.playlist_list_entries()
    result.wait()
    ...

And here is the error I get:

AttributeError at /xmms2/list/
'module' object has no attribute 'XMMS'

And the line in question is this:

 xmms = xmmsclient.XMMS("tutorial1") 

The view works fine if I remove all the code and replace it with (for example):

return HttpResponse("list")

I first thought there was a problem with the xmmsclient library but it works fine when I run this xmms2-tutorial example

So I guess there is some sort of incompatibility between Django and xmmsclient but I really don't have a clue.

I'm running Ubuntu 12.04, Python 2.7.3, Django 1.4.1 and XMMS2 0.8

Any help will be really appreciated!


Solution

  • The problem was a name conflict. My Django app name was "xmmsclient".

    So when I did

    xmmsclient.XMMS("tut1")
    

    I was referring to my app module, not the one from the XMMS2 client library.

    Thanks a lot to Erik Massop from the xmms2-devel list!