Ticket #1300: housekeeping2.diff
File housekeeping2.diff, 15.6 KB (added by , 19 years ago) |
---|
-
django/contrib/admin/templatetags/log.py
13 13 def render(self, context): 14 14 if self.user is not None and not self.user.isdigit(): 15 15 self.user = context[self.user].id 16 context[self.varname] = LogEntry.objects.get_list(user__id__exact=self.user, 17 limit=self.limit, select_related=True) 16 context[self.varname] = LogEntry.objects.filter(user__id__exact=self.user).select_related()[:self.limit] 18 17 return '' 19 18 20 19 class DoGetAdminLog: -
django/contrib/admin/filterspecs.py
56 56 self.lookup_title = f.verbose_name 57 57 self.lookup_kwarg = '%s__%s__exact' % (f.name, f.rel.to._meta.pk.name) 58 58 self.lookup_val = request.GET.get(self.lookup_kwarg, None) 59 self.lookup_choices = f.rel.to._default_manager. get_list()59 self.lookup_choices = f.rel.to._default_manager.all() 60 60 61 61 def has_output(self): 62 62 return len(self.lookup_choices) > 1 -
django/contrib/admin/views/decorators.py
71 71 # Check the password. 72 72 username = request.POST.get('username', '') 73 73 try: 74 user = User.objects.get _object(username__exact=username, is_staff__exact=True)74 user = User.objects.get(username=username, is_staff=True) 75 75 except User.DoesNotExist: 76 76 message = ERROR_MESSAGE 77 77 if '@' in username: 78 78 # Mistakenly entered e-mail address instead of username? Look it up. 79 79 try: 80 user = User.objects.get _object(email__exact=username)80 user = User.objects.get(email=username) 81 81 except User.DoesNotExist: 82 82 message = _("Usernames cannot contain the '@' character.") 83 83 else: -
django/contrib/admin/views/doc.py
103 103 'name': func.__name__, 104 104 'module': func.__module__, 105 105 'site_id': settings_mod.SITE_ID, 106 'site': Site.objects.get _object(pk=settings_mod.SITE_ID),106 'site': Site.objects.get(pk=settings_mod.SITE_ID), 107 107 'url': simplify_regex(regex), 108 108 }) 109 109 return render_to_response('admin_doc/view_index', {'views': views}, context_instance=RequestContext(request)) … … 206 206 'exists': os.path.exists(template_file), 207 207 'contents': lambda: os.path.exists(template_file) and open(template_file).read() or '', 208 208 'site_id': settings_mod.SITE_ID, 209 'site': Site.objects.get _object(pk=settings_mod.SITE_ID),209 'site': Site.objects.get(pk=settings_mod.SITE_ID), 210 210 'order': list(settings_mod.TEMPLATE_DIRS).index(dir), 211 211 }) 212 212 return render_to_response('admin_doc/template_detail', { -
django/contrib/auth/handlers/modpython.py
21 21 superuser_only = _str_to_bool(options.get('DjangoRequireSuperuserStatus', "off")) 22 22 23 23 # check that the username is valid 24 kwargs = {'username __exact': req.user, 'is_active__exact': True}24 kwargs = {'username': req.user, 'is_active': True} 25 25 if staff_only: 26 kwargs['is_staff __exact'] = True26 kwargs['is_staff'] = True 27 27 if superuser_only: 28 kwargs['is_superuser __exact'] = True28 kwargs['is_superuser'] = True 29 29 try: 30 user = User.objects.get _object(**kwargs)30 user = User.objects.get(**kwargs) 31 31 except User.DoesNotExist: 32 32 return apache.HTTP_UNAUTHORIZED 33 33 -
django/contrib/auth/models.py
183 183 184 184 def get_and_delete_messages(self): 185 185 messages = [] 186 for m in self. get_message_list():186 for m in self.message_set.all(): 187 187 messages.append(m.message) 188 188 m.delete() 189 189 return messages … … 205 205 try: 206 206 app, mod = settings.AUTH_PROFILE_MODULE.split('.') 207 207 module = __import__('ellington.%s.apps.%s' % (app, mod), [], [], ['']) 208 self._profile_cache = module.get _object(user_id=self.id)208 self._profile_cache = module.get(user_id=self.id) 209 209 except ImportError: 210 210 try: 211 211 module = __import__('django.models.%s' % settings.AUTH_PROFILE_MODULE, [], [], ['']) 212 self._profile_cache = module.get _object(user__id__exact=self.id)212 self._profile_cache = module.get(user__id__exact=self.id) 213 213 except ImportError: 214 214 raise SiteProfileNotAvailable 215 215 return self._profile_cache -
django/core/handlers/wsgi.py
126 126 user_id = self.session[SESSION_KEY] 127 127 if not user_id: 128 128 raise ValueError 129 self._user = User.objects.get _object(pk=user_id)129 self._user = User.objects.get(pk=user_id) 130 130 except (AttributeError, KeyError, ValueError, User.DoesNotExist): 131 131 from django.parts.auth import anonymoususers 132 132 self._user = anonymoususers.AnonymousUser() -
django/core/handlers/modpython.py
105 105 user_id = self.session[SESSION_KEY] 106 106 if not user_id: 107 107 raise ValueError 108 self._user = User.objects.get _object(pk=user_id)108 self._user = User.objects.get(pk=user_id) 109 109 except (AttributeError, KeyError, ValueError, User.DoesNotExist): 110 110 from django.parts.auth import anonymoususers 111 111 self._user = anonymoususers.AnonymousUser() -
django/core/management.py
559 559 num_added = 0 560 560 app_models = get_models(app) 561 561 app_label = app_models[0]._meta.app_label 562 package = Package.objects.get _object(pk=app_label)562 package = Package.objects.get(pk=app_label) 563 563 for klass in app_models: 564 564 opts = klass._meta 565 565 for codename, name in _get_all_permissions(opts): 566 566 try: 567 Permission.objects.get _object(name__exact=name, codename__exact=codename, package__label__exact=package.label)567 Permission.objects.get(name=name, codename=codename, package__label__exact=package.label) 568 568 except Permission.DoesNotExist: 569 569 p = Permission(name=name, package=package, codename=codename) 570 570 p.save() … … 644 644 sys.stderr.write("Error: That username is invalid.\n") 645 645 username = None 646 646 try: 647 User.objects.get _object(username__exact=username)647 User.objects.get(username=username) 648 648 except User.DoesNotExist: 649 649 break 650 650 else: -
django/core/paginator.py
16 16 Finally, check if a page number has a next/prev page using 17 17 has_next_page(page_number) and has_previous_page(page_number). 18 18 """ 19 def __init__(self, manager_or_model, args, num_per_page, count_method=' get_count', list_method='get_list'):19 def __init__(self, manager_or_model, args, num_per_page, count_method='count', list_method='all'): 20 20 if hasattr(manager_or_model, '_default_manager'): 21 21 manager = manager_or_model._default_manager 22 22 else: -
django/db/models/fields/__init__.py
256 256 return first_choice + list(self.choices) 257 257 rel_model = self.rel.to 258 258 return first_choice + [(x._get_pk_val(), str(x)) 259 for x in rel_model._default_manager. get_list(**rel_model._meta.limit_choices_to)]259 for x in rel_model._default_manager.filter(**rel_model._meta.limit_choices_to)] 260 260 261 261 def get_choices_default(self): 262 262 if self.radio_admin: -
django/db/models/options.py
87 87 "Returns the content-type ID for this object type." 88 88 if not hasattr(self, '_content_type_id'): 89 89 from django.contrib.contenttypes.models import ContentType 90 self._content_type_id = ContentType.objects.get _object(90 self._content_type_id = ContentType.objects.get( 91 91 python_module_name__exact=self.module_name, 92 92 package__label__exact=self.app_label).id 93 93 return self._content_type_id -
django/db/models/manipulators.py
250 250 def __init__(self, obj_key, follow=None): 251 251 self.obj_key = obj_key 252 252 try: 253 self.original_object = self.manager.get _object(pk=obj_key)253 self.original_object = self.manager.get(pk=obj_key) 254 254 except ObjectDoesNotExist: 255 255 # If the object doesn't exist, this might be a manipulator for a 256 256 # one-to-one related object that hasn't created its subobject yet. -
django/parts/auth/formfields.py
29 29 30 30 def isValidUser(self, field_data, all_data): 31 31 try: 32 self.user_cache = User.objects.get _object(username__exact=field_data)32 self.user_cache = User.objects.get(username=field_data) 33 33 except User.DoesNotExist: 34 34 raise validators.ValidationError, _("Please enter a correct username and password. Note that both fields are case-sensitive.") 35 35 -
django/contrib/redirects/middleware.py
8 8 return response # No need to check for a redirect for non-404 responses. 9 9 path = request.get_full_path() 10 10 try: 11 r = Redirect.objects.get _object(site__id__exact=settings.SITE_ID, old_path__exact=path)11 r = Redirect.objects.get(site__id__exact=settings.SITE_ID, old_path__exact=path) 12 12 except Redirect.DoesNotExist: 13 13 r = None 14 14 if r is None and settings.APPEND_SLASH: 15 15 # Try removing the trailing slash. 16 16 try: 17 r = Redirect.objects.get _object(site__id__exact=settings.SITE_ID,18 old_path __exact=path[:path.rfind('/')]+path[path.rfind('/')+1:])17 r = Redirect.objects.get(site__id__exact=settings.SITE_ID, 18 old_path=path[:path.rfind('/')]+path[path.rfind('/')+1:]) 19 19 except Redirect.DoesNotExist: 20 20 pass 21 21 if r is not None: -
django/contrib/sessions/middleware.py
46 46 self._session_cache = {} 47 47 else: 48 48 try: 49 s = Session.objects.get _object(session_key__exact=self.session_key,49 s = Session.objects.get(session_key=self.session_key, 50 50 expire_date__gt=datetime.datetime.now()) 51 51 self._session_cache = s.get_decoded() 52 52 except Session.DoesNotExist: -
django/contrib/sessions/models.py
18 18 while 1: 19 19 session_key = md5.new(str(random.randint(0, sys.maxint - 1)) + str(random.randint(0, sys.maxint - 1)) + settings.SECRET_KEY).hexdigest() 20 20 try: 21 self.get _object(session_key__exact=session_key)22 except self. klass.DoesNotExist:21 self.get(session_key=session_key) 22 except self.model.DoesNotExist: 23 23 break 24 24 return session_key 25 25 26 26 def save(self, session_key, session_dict, expire_date): 27 s = self. klass(session_key, self.encode(session_dict), expire_date)27 s = self.model(session_key, self.encode(session_dict), expire_date) 28 28 if session_dict: 29 29 s.save() 30 30 else: -
django/shortcuts/__init__.py
12 12 13 13 def get_object_or_404(klass, **kwargs): 14 14 try: 15 return klass._default_manager.get _object(**kwargs)15 return klass._default_manager.get(**kwargs) 16 16 except klass.DoesNotExist: 17 17 raise Http404 18 18 -
django/contrib/sites/models.py
4 4 class SiteManager(models.Manager): 5 5 def get_current(self): 6 6 from django.conf import settings 7 return self.get _object(pk=settings.SITE_ID)7 return self.get(pk=settings.SITE_ID) 8 8 9 9 class Site(models.Model): 10 10 domain = models.CharField(_('domain name'), maxlength=100) -
django/contrib/syndication/feeds.py
46 46 """ 47 47 if url: 48 48 try: 49 obj = self.get _object(url.split('/'))49 obj = self.get(url.split('/')) 50 50 except (AttributeError, ObjectDoesNotExist): 51 51 raise FeedDoesNotExist 52 52 else: