Need help fixing application_python to work with Django 1.4+


#1

Hi –

I needed to get the application_python cookbook working with a recent
version of Django, which uses a different layout than what is supported
by application_python.

I forked it and made a few changes that should make it do what I
want. Unfortunately, I’ve run into an error I don’t understand. I
basically tried to create a string value “django_project” that could be
set in the django block, similar to collectstatic.

So, in application_python/resource I added
attribute :django_project, :kind_of => [TrueClass, FalseClass, String],
:default => nil
In application_python/providers I referenced it similarly to the way
collectstatic is referenced, new_resource.django_project

I thought that was all I’d have to do, but I now find that it throws an
exception because it can’t find the django_proj method. This is
probably obvious to some of you but… where do I define django_proj as
a method?

Need some help here!

django do
requirements "config/requirements.txt"
django_proj "bartrendr"
settings_template "settings.py.erb"
debug app_node[:debug]
collectstatic true
settings django_settings
database do
host mongo_host
database mongo_db_name
mongo_replicaset mongo_replicaset
mongo_replicaset_name mongo_replicaset_name
username "mongo_user"
password "mongo_password"
end

Recipe Compile Error in
/srv/chef/file_store/cookbooks/bti_api/recipes/default.rb

================================================================================

NoMethodError


undefined method `django_proj’ for Chef::Resource::ApplicationPythonDjango

Cookbook Trace:

/srv/chef/file_store/cookbooks/application/libraries/default.rb:72:in
method_missing' /srv/chef/file_store/cookbooks/bti_api/recipes/default.rb:69:inblock (2 levels) in from_file’

/srv/chef/file_store/cookbooks/application/resources/default.rb:115:in
`block in method_missing’

/srv/chef/file_store/cookbooks/application/resources/default.rb:112:in
`each’

/srv/chef/file_store/cookbooks/application/resources/default.rb:112:in
method_missing' /srv/chef/file_store/cookbooks/bti_api/recipes/default.rb:67:inblock in from_file’
/srv/chef/file_store/cookbooks/bti_api/recipes/default.rb:44:in
`from_file’

Relevant File Content:

/srv/chef/file_store/cookbooks/application/libraries/default.rb:

65: @restart_command
66: end
67:
68: def method_missing(name, *args)
69: if application.respond_to? name
70: application.send(name, *args)
71: else
72>> super
73: end
74: end
75:
76: class OptionsBlock
77: include Chef::Resource::Application::OptionsCollector
78: end
79:
80: def options_block(options=nil, &block)
81: options ||= {}

[2013-06-10T23:42:59+00:00] ERROR: Running exception handlers
[2013-06-10T23:42:59+00:00] FATAL: Saving node information to
/srv/chef/file_store/failed-run-data.json
[2013-06-10T23:42:59+00:00] ERROR: Exception handlers complete
[2013-06-10T23:42:59+00:00] FATAL: Stacktrace dumped to
/srv/chef/file_store/chef-stacktrace.out
[2013-06-10T23:42:59+00:00] FATAL: NoMethodError: undefined method
`django_proj’ for Chef::Resource::ApplicationPythonDjango


Liam Kirsher
PGP: http://liam.numenet.com/pgp/