Buildout and django-registration from repository for Django 1.5 - django

I'd like to use Buildout to get django-registration with Django 1.5, and I have a custom user using MyUser(AbstractUser). I used to get it from the recipe v0.8 and it was great. Since, I switched to 1.5, remove my UserProfile and use this custom MyUser.
django-registration no longer work. I've been told I should get it from the repository, and that's what I'm trying to do. I've in the past used mr.developer to get a newer version of django-tastypie, and I tried to reproduce the same with django-registration. I have an error while calling bin/buildout tho. Let's first check the buildout config:
[buildout]
extensions = mr.developer
parts = myquivers
eggs =
django-registration
include-site-packages = false
versions = versions
sources = sources
auto-checkout =
django-registration
[sources]
django-registration = hg https://bitbucket.org/ubernostrum/django-registration
[versions]
django = 1.5
[myquivers]
recipe = djangorecipe
settings = development
eggs = ${buildout:eggs}
project = myquivers
Pretty simple config. It used to work with tastypie like I said, and I'm trying to do the same steps:
- python2.7 bootstrap.py
- bin/buildout
- bin/develop activate django-registration
- bin/develop checkout django-registration
- bin/myquivers syncdb
- bin/myquivers runservser
But it fails at the bin/buildout steps:
$ bin/buildout
Getting distribution for 'mr.developer'.
Got mr.developer 1.25.
mr.developer: Creating missing sources dir /home/damien/Documents/projects/myquivers/src.
mr.developer: Queued 'django-registration' for checkout.
mr.developer: Cloned 'django-registration' with mercurial.
Develop: '/home/damien/Documents/projects/myquivers/src/django-registration'
Traceback (most recent call last):
File "/tmp/tmpzLDggG", line 13, in <module>
exec(compile(open('/home/damien/Documents/projects/myquivers/src/django-registration/setup.py').read(), '/home/damien/Documents/projects/myquivers/src/django-registration/setup.py', 'exec'))
File "/home/damien/Documents/projects/myquivers/src/django-registration/setup.py", line 30, in <module>
version=get_version().replace(' ', '-'),
File "/home/damien/Documents/projects/myquivers/src/django-registration/registration/__init__.py", line 5, in get_version
from django.utils.version import get_version as django_get_version
ImportError: No module named django.utils.version
While:
Installing.
Processing develop directory '/home/damien/Documents/projects/myquivers/src/django-registration'.
An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
File "/home/damien/Documents/projects/myquivers/eggs/zc.buildout-2.1.0-py2.7.egg/zc/buildout/buildout.py", line 1923, in main
getattr(buildout, command)(args)
File "/home/damien/Documents/projects/myquivers/eggs/zc.buildout-2.1.0-py2.7.egg/zc/buildout/buildout.py", line 466, in install
installed_develop_eggs = self._develop()
File "/home/damien/Documents/projects/myquivers/eggs/zc.buildout-2.1.0-py2.7.egg/zc/buildout/buildout.py", line 707, in _develop
zc.buildout.easy_install.develop(setup, dest)
File "/home/damien/Documents/projects/myquivers/eggs/zc.buildout-2.1.0-py2.7.egg/zc/buildout/easy_install.py", line 871, in develop
call_subprocess(args)
File "/home/damien/Documents/projects/myquivers/eggs/zc.buildout-2.1.0-py2.7.egg/zc/buildout/easy_install.py", line 129, in call_subprocess
% repr(args)[1:-1])
Exception: Failed to run command:
'/usr/bin/python2.7', '/tmp/tmpzLDggG', '-q', 'develop', '-mxN', '-d', '/home/damien/Documents/projects/myquivers/develop-eggs/tmpYM_dR9build'
Checking at the error, first Django seems not to be in the system, and that's right, when entering python2.7 and try >>> import django, it fails. But that's normal and that's why I'm using buildout, to not install system-wide Django, just locally for my project.
Any idea how to fix this? Is there a better alternative than taking this repo version? Please let me know, again, custom user/django 1.5/django-registration.
Thanks!

Related

'Wit' object has no attribute 'message'

Just trying to experiment with Wit.ai & Python but getting the following error. What am I doing wrong here??
Error:
Traceback (most recent call last):
File "C:/Python27/mx1.py", line 7, in <module>
resp = client.message(my_message)
AttributeError: 'Wit' object has no attribute 'message'
Code:
from wit import Wit
access_token='B3GHXHLTXIASO7S4KY7UC65LMSTCDEHK'
client = Wit(access_token)
my_message='who are you?'
resp = client.message(my_message)
print(resp)
So, it seems like you're using an older (actually unofficial) version of the Python pywit package, last updated on 2015-11-07 (version 0.4.0).
You should remove the pywit package and install wit, just like they say in the docs/install section:
pip uninstall pywit
pip install wit
Just for completeness, if you look inside the wit.py of your older pywit package, inside your python2.7/site-packages/wit/wit.py, you'll see the definition of old Wit class, with a get_message() method instead of the current message(). So, in the pywit, your code will run if you say:
resp = client.get_message(my_message)
instead of
resp = client.message(my_message)
But you should really switch to the current (official) version.

Missing environment variables in OpenShift

I am trying to set up a Python 2.7 project in Openshift. The goal is to use Tornado Websockets. I have tried a number of examples, but I keep getting stuck on a number of missing environment variables that are shown in the examples.
My current app.py:
import imp
import os
try:
zvirtenv = os.path.join(os.environ['OPENSHIFT_PYTHON_DIR'],
'virtenv', 'bin', 'activate_this.py')
execfile(zvirtenv, dict(__file__ = zvirtenv) )
except IOError:
pass
if __name__ == '__main__':
ip = os.environ['OPENSHIFT_PYTHON_IP']
port = int(os.environ['OPENSHIFT_PYTHON_PORT'])
app = imp.load_source('application', 'main.py')
app.application.listen(port , ip)
app.ioloop.IOLoop.instance().start()
My install requires:
install_requires=['tornado', 'requests', 'beautifulsoup4']
This results in the following error:
---> Running application from Python script (app.py) ...
Traceback (most recent call last):
File "app.py", line 14, in <module>
zvirtenv = os.path.join(os.environ['OPENSHIFT_PYTHON_DIR'],
File "/opt/app-root/lib64/python2.7/UserDict.py", line 40, in __getitem__
raise KeyError(key)
KeyError: 'OPENSHIFT_PYTHON_DIR'
Can anybody help me out?
You are looking for environment variables set when using OpenShift 2, but are using OpenShift 3. Under OpenShift 3 you do not need to activate the Python virtual environment, it is done for you. Your app.py should listen on all interfaces and on port 8080. That address doesn't change so long as using the default Python S2I builder, so environment variables not used to pass it in.

Error running Django tests

I'm trying to run Django tests ( version 1.8 )
But I get this error
from django.test import TestCase
class JobTypesResourceTest (TestCase):
def setUp(self):
TestCase.setUp(self)
def test_basicGet(self):
return True
Traceback (most recent call last):
File "C:\Users\user\.p2\pool\plugins\org.python.pydev_4.4.0.201510052309\pysrc\runfiles.py", line 234, in <module>
main()
File "C:\Users\user\.p2\pool\plugins\org.python.pydev_4.4.0.201510052309\pysrc\runfiles.py", line 78, in main
return pydev_runfiles.main(configuration) # Note: still doesn't return a proper value.
File "C:\Users\user\.p2\pool\plugins\org.python.pydev_4.4.0.201510052309\pysrc\pydev_runfiles.py", line 835, in main
PydevTestRunner(configuration).run_tests()
File "C:\Users\user\.p2\pool\plugins\org.python.pydev_4.4.0.201510052309\pysrc\pydev_runfiles.py", line 793, in run_tests
MyDjangoTestSuiteRunner(run_tests).run_tests([])
File "C:\Users\user\.p2\pool\plugins\org.python.pydev_4.4.0.201510052309\pysrc\pydev_runfiles.py", line 813, in run_tests
raise AssertionError("Unable to run suite with DjangoTestSuiteRunner because it couldn't be imported.")
AssertionError: Unable to run suite with DjangoTestSuiteRunner because it couldn't be imported.
Am I missing a python library ?
Don't use context menu 'Run as' -> 'Python unit-test'. Use project's context menu 'Django' -> 'Run Django Tests (manage.py test)' instead.
To create launch configuration for Django Tests copy launch configuration that runs your Django project (automatically created after 'Run as' -> 'PyDev: Django')
and change program arguments from 'runserver' to 'test'.
Your TEST_RUNNER setting is set to django.test.simple.DjangoTestSuiteRunner or a subclass of it.
django.test.simple.DjangoTestSuiteRunner was deprecated in Django 1.6 and removed in Django 1.8.
Since you are using Eclipse, I think this is accurate for you.
Thank you for the help. Looks like I was running the tests wrong. I was using Eclipse-> run as pyunit option which looks like was using older code. Was working when I ran using manage.py test

autodoc failing on django ImageField

I'm attempting to use sphinx to document the django app I'm writing. So far I have my code.rst setup to look at models.py, and when I run make html I get the automatic documentation, however I get a warning:
WARNING: autodoc can't import/find attribute 'myapp.models.MyModel.image', it reported error: "image", please check your spelling and sys.path
The entire tracelog is:
Traceback (most recent call last):
File "C:\blah\lib\site-packages\sphinx\ext\autodoc.py", line 326, in import_object
obj = self.get_attr(obj, part)
File "C:\blah\lib\site-packages\sphinx\ext\autodoc.py", line 232, in get_attr
return safe_getattr(obj, name, *defargs)
File "C:\blah\lib\site-packages\sphinx\util\inspect.py", line 70, in safe_getattr
raise AttributeError(name)
AttributeError: image
MyModel.image is an image field, simply on the model defined as:
#: image file location for ``MyModel``
image = models.ImageField(upload_to="images/")
If I change image to models.Charfield for example it runs fine. Is there any reason why an ImageField would cause sphinx issues?
my code.rst:
.. automodule:: dynamicbanners.models
:members:
So after reading the comments it seems this is a quirk of Django that messes with sphinx.ext.autodoc. Hopefully a fix will be dropped into Django 1.6 soon, or failing that I think the upcoming 1.2 version of Sphinx might provide a way around it, but for now I'll need to find some sort of workaround.
Looks like this was fixed in Django 1.8 - https://code.djangoproject.com/ticket/12568

django-filebrowser fails during testing

Error message:
Creating Test for the FileBrowser site: filebrowser
Creating test database for alias 'default'...
..................D:\blizzard\Projects\Python\Web\moz455\venv\lib\site-packages\
django\template\defaulttags.py:1235: DeprecationWarning: The syntax for the url
template tag is changing. Load the `url` tag from the `future` tag library to st
art using the new behavior.
category=DeprecationWarning)
('path:', 'uploads/tmp_test_0\\testimage_medium.jpg')
FRemoving left-over tmp dir: uploads/tmp_test_0
======================================================================
FAIL: runTest (filebrowser.tests.sites.TestSite_filebrowser)
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:\blizzard\Projects\Python\Web\moz455\venv\lib\site-packages\filebrowse
r\tests\sites.py", line 233, in runTest
test_detail(self)
File "D:\blizzard\Projects\Python\Web\moz455\venv\lib\site-packages\filebrowse
r\tests\sites.py", line 140, in test_detail
test.assertTrue(test.site.storage.exists(path))
AssertionError: False is not True
I wrote about it on filebrowser's github page, but maybe it's my own fault. Can this problem be solved without dealing with filebrowser source?
Note: path is equal to 'uploads/tmp_test_0\\testimage_medium.jpg', folder 'uploads' is in application 'media' folder
Versions: Django - 1.4.1, django-filebrowser - 3.5.0, django-grappelli - 2.4.0