1. Chris AtLee
  2. poster
  3. Issues
Issue #1 new

Remove the imports in poster/__init__.py

created an issue

Are the 2 imports in poster/init.py necessary? {{{ import poster.streaminghttp import poster.encode }}}

When I include poster's folder inside a project of mine, those imports fail: {{{ File "/home/emilien/devel/nautilus-image-manipulator/nautilus_image_manipulator/upload/z1fichiercom.py", line 20, in <module> from poster.encode import multipart_encode File "/home/emilien/devel/nautilus-image-manipulator/nautilus_image_manipulator/upload/poster/init.py", line 29, in <module> import poster.streaminghttp ImportError: No module named poster.streaminghttp }}}

I fix this by removing "poster." in the previously mentioned imports.

But maybe those imports are necessary for when this is installed from the egg file? Is there a reason to have them in poster/init.py?

Comments (5)

  1. Chris AtLee repo owner

    They were added for convenience so that you could import poster, and then access poster.encode methods directly.

    I don't understand how your usage case is failing...do you not have the streaminghttp file as well?

  2. e2jk reporter

    This is my layout. You can see it on Launchpad [1].


    If in z1fichiercom.py I call this:

    from poster.encode import multipart_encode
    from poster.streaminghttp import register_openers

    with your standard poster/init.py, I get the exceptions that are reported in the first post. I have thus removed the "poster." from the standard init.py, as you can see in [2].

    I guess this works fine if you install the module (as an egg), but I included it in my branch, since the ideal solution for me would be to make a Linux package for poster and make that a dependency of my application's package, so no manual egg install (see issue #2)

    [1] http://bazaar.launchpad.net/~emilien-klein/nautilus-image-manipulator/trunk/files

    [2] http://bazaar.launchpad.net/~emilien-klein/nautilus-image-manipulator/trunk/annotate/head%3A/nautilus_image_manipulator/upload/poster/__init__.py

  3. Éric Araujo

    e2jk: if you want to include poster in your project (which is going to cause issues with Debian/Ubuntu packaging btw), then you need to change the imports to be nautilus_image_manipulator.upload.poster.streaminghttp (etc.)

    Using “import streaminghttp” sort of works because of implicit relative imports, but is not recommended.

  4. Éric Araujo

    Debian packaging does not allow embedded copies of software, so they turn your local imports to regular ones.

    Solution 1 to fix your problem: depend on poster instead of copying it and use “from poster import encode”.

    Solution 2: keep the copy and use “from nautilus_etc.poster import encode”.

  5. Log in to comment