saisasthaa / django-cron

Automatically exported from code.google.com/p/django-cron
MIT License
0 stars 0 forks source link

UnboundLocalError: local variable 'cron' referenced before assignment #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This error crops up when django_cron.autodiscover() (__init__.py) is executed. 
Specifically on this 
line:

 cronScheduler = cron

Turns out this line is inside the autodiscover() method, and cron is global. 
Simply adding

 global cron

before the line mentioned above solves the problem.

Original issue reported on code.google.com by pgbrandao@gmail.com on 19 Apr 2009 at 6:19

GoogleCodeExporter commented 9 years ago
I have the same problem

UnboundLocalError at /

local variable 'cron' referenced before assignment

Request Method:     GET
Request URL:    http://localhost:8000/
Exception Type:     UnboundLocalError
Exception Value:    

local variable 'cron' referenced before assignment

Exception Location:     ../django_cron/__init__.py in autodiscover, line 36
Python Executable:  /usr/bin/python
Python Version:     2.5.2
django_cron Version:    r15

Original comment by gnu...@gmail.com on 29 Apr 2009 at 1:51

GoogleCodeExporter commented 9 years ago
I reworked this and am now just using cronScheduler as the name for this object 
to
avoid all of these namespace problems (and confusion when reading the code)

the latest in svn has these changes but, please note that you will need to 
update
your cron.py files to use the new version

update being:
from django_cron import cron

changes to:
from django_cron import cronScheduler as cron

Original comment by Jim.mixt...@gmail.com on 2 Jun 2009 at 2:16

GoogleCodeExporter commented 9 years ago
marking this as fixed

Original comment by Jim.mixt...@gmail.com on 2 Jun 2009 at 2:16