Kaydet (Commit) b69b4008 authored tarafından Aymeric Augustin's avatar Aymeric Augustin

Removed usage of a global variable.

üst f88ad710
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import os
import datetime import datetime
import itertools
import os
import tempfile import tempfile
from django.core.files.storage import FileSystemStorage from django.core.files.storage import FileSystemStorage
...@@ -10,6 +11,10 @@ from django.db import models ...@@ -10,6 +11,10 @@ from django.db import models
from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import python_2_unicode_compatible
callable_default_counter = itertools.count()
callable_default = lambda: next(callable_default_counter)
temp_storage_location = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR']) temp_storage_location = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
temp_storage = FileSystemStorage(location=temp_storage_location) temp_storage = FileSystemStorage(location=temp_storage_location)
...@@ -18,15 +23,6 @@ class BoundaryModel(models.Model): ...@@ -18,15 +23,6 @@ class BoundaryModel(models.Model):
positive_integer = models.PositiveIntegerField(null=True, blank=True) positive_integer = models.PositiveIntegerField(null=True, blank=True)
callable_default_value = 0
def callable_default():
global callable_default_value
callable_default_value = callable_default_value + 1
return callable_default_value
class Defaults(models.Model): class Defaults(models.Model):
name = models.CharField(max_length=255, default='class default value') name = models.CharField(max_length=255, default='class default value')
def_date = models.DateField(default=datetime.date(1980, 1, 1)) def_date = models.DateField(default=datetime.date(1980, 1, 1))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment