Code

Opened 3 years ago

Closed 3 years ago

#16573 closed Bug (fixed)

admindocs "views" view returns no urls

Reported by: lopopolo Owned by: nobody
Component: contrib.admindocs Version: master
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The conditions in the if in extract_views_from_url patterns are in the wrong order. This results in all of my root level urls matching a nil view function. Swapping the if and elif conditions fixes the problem

Diff is attached.

Attachments (1)

extract_views_from_urlpatterns_diff.txt (1.1 KB) - added by lopopolo 3 years ago.
git diff of proposed fix

Download all attachments as: .zip

Change History (7)

Changed 3 years ago by lopopolo

git diff of proposed fix

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

You lost me at:

This results in all of my root level urls matching a nil view function.

What's a "nil view function"?

More generally, what's the problem and how do I reproduce it? What's the expected result, and the actual result?

comment:2 Changed 3 years ago by lopopolo

  • Resolution needsinfo deleted
  • Status changed from closed to reopened

When visiting /admin/doc/views
Instead of building a list of all of the functions defined in my apps' views and their associated urls,
the function extract_views_from_url_patterns returns a list of tuples of the form
(None, <url from root level urls.py>)

For example:
(None, "admin/doc/"),
(None, "admin/"),
(None, "myapp/")

To reproduce, visit http://somedjangosite.com/admin/doc/views

comment:3 Changed 3 years ago by aaugustin

  • Resolution set to worksforme
  • Status changed from reopened to closed

When I visit that URL on my projects, I get a listing of my URLs and views, as expected.

We need more information to reproduce your problem. For instance, could you build a minimal project that exhibits the issue?

comment:4 Changed 3 years ago by lopopolo

  • Resolution worksforme deleted
  • Status changed from closed to reopened

This django project, which uses a recent version of trunk exhibits the error: https://github.com/lopopolo/hyperbola

Visiting http://localhost/ssb/doc/views when running the development server should exhibit the problem

comment:5 Changed 3 years ago by aaugustin

  • Needs tests set
  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

Good catch. This is a regression introduced at r16405.

With a checkout of your project (but that project has nothing special, the result would be the same with any Django site), and r16404 of Django, it works.

With r16405, I get this exception:

Environment:


Request Method: GET
Request URL: http://localhost:8000/ssb/doc/views/

Django Version: 1.4 pre-alpha SVN-16405
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.markup',
 'hyperbola.contact',
 'hyperbola.frontpage',
 'hyperbola.lifestream',
 'hyperbola.helpers']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/Users/myk/Desktop/hyperbola/hyperbola/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/myk/Desktop/hyperbola/hyperbola/django/contrib/admin/views/decorators.py" in _checklogin
  16.             return view_func(request, *args, **kwargs)
File "/Users/myk/Desktop/hyperbola/hyperbola/django/contrib/admindocs/views.py" in view_index
  137.                 'module': func.__module__,

Exception Type: AttributeError at /ssb/doc/views/
Exception Value: 'NoneType' object has no attribute '__module__'

comment:6 Changed 3 years ago by jezdez

  • Resolution set to fixed
  • Status changed from reopened to closed

In [16609]:

Fixed #16573 -- Corrected a regression in the admindocs app's view overview introduced in r16405. Thanks, lopopolo.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.