Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-debug-toolbar-mongo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-debug-toolbar-mongo
Commits
8d4c1265
Commit
8d4c1265
authored
May 25, 2011
by
Harry Marr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the query more readable
parent
a2d77317
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
4 deletions
+54
-4
debug_toolbar_mongo/operation_tracker.py
+0
-1
debug_toolbar_mongo/templates/mongo-panel.html
+14
-2
debug_toolbar_mongo/templatetags/__init__.py
+0
-0
debug_toolbar_mongo/templatetags/mongo_debug_tags.py
+23
-0
example/settings.py
+4
-0
example/views.py
+13
-1
No files found.
debug_toolbar_mongo/operation_tracker.py
View file @
8d4c1265
...
@@ -61,7 +61,6 @@ class MongoOperationTracker(object):
...
@@ -61,7 +61,6 @@ class MongoOperationTracker(object):
query_data
[
'skip'
]
=
query_son
.
get
(
'skip'
)
query_data
[
'skip'
]
=
query_son
.
get
(
'skip'
)
query_data
[
'limit'
]
=
query_son
.
get
(
'limit'
)
query_data
[
'limit'
]
=
query_son
.
get
(
'limit'
)
query_data
[
'query'
]
=
query_son
[
'query'
]
query_data
[
'query'
]
=
query_son
[
'query'
]
del
query_son
[
'count'
]
else
:
else
:
# Normal Query
# Normal Query
query_data
[
'skip'
]
=
privar
(
'skip'
)
query_data
[
'skip'
]
=
privar
(
'skip'
)
...
...
debug_toolbar_mongo/templates/mongo-panel.html
View file @
8d4c1265
{% load mongo_debug_tags %}
<style
type=
"text/css"
>
pre
.mongo-highlight
,
pre
.mongo-highlight
span
{
font-family
:
'Consolas'
,
'Deja Vu Sans Mono'
,
'Bitstream Vera Sans Mono'
,
'Monaco'
,
'Courier New'
,
monospace
!important
;
font-size
:
1.05em
!important
;
}
</style>
<table>
<table>
<thead>
<thead>
...
@@ -17,8 +25,12 @@
...
@@ -17,8 +25,12 @@
<td>
{{ query.time|floatformat:"4" }}
</td>
<td>
{{ query.time|floatformat:"4" }}
</td>
<td>
{{ query.operation|title }}
</td>
<td>
{{ query.operation|title }}
</td>
<td>
{{ query.collection }}
</td>
<td>
{{ query.collection }}
</td>
<td><code>
{{ query.query|pprint }}
</code></td>
<td>
<td>
{% if query.ordering %}{{ query.ordering }}{% endif %}
</td>
{% if query.query %}
<pre
class=
"mongo-highlight"
>
{{ query.query|format_dict|highlight_json|safe }}
</pre>
{% endif %}
</td>
<td><pre
class=
"mongo-highlight"
>
{% if query.ordering %}{{ query.ordering }}{% endif %}
</pre></td>
<td>
{% if query.skip %}{{ query.skip }}{% endif %}
</td>
<td>
{% if query.skip %}{{ query.skip }}{% endif %}
</td>
<td>
{% if query.limit %}{{ query.limit }}{% endif %}
</td>
<td>
{% if query.limit %}{{ query.limit }}{% endif %}
</td>
</tr>
</tr>
...
...
debug_toolbar_mongo/templatetags/__init__.py
0 → 100644
View file @
8d4c1265
debug_toolbar_mongo/templatetags/mongo_debug_tags.py
0 → 100644
View file @
8d4c1265
from
django
import
template
import
pprint
register
=
template
.
Library
()
@register.filter
def
format_dict
(
value
,
width
=
60
):
print
width
return
pprint
.
pformat
(
value
,
width
=
int
(
width
))
@register.filter
def
highlight_json
(
value
):
try
:
from
pygments
import
highlight
from
pygments.lexers
import
JavascriptLexer
from
pygments.formatters
import
HtmlFormatter
except
ImportError
:
return
value
# Can't use class-based colouring because the debug toolbar's css rules
# are more specific so take precedence
formatter
=
HtmlFormatter
(
style
=
'friendly'
,
nowrap
=
True
,
noclasses
=
True
)
return
highlight
(
value
,
JavascriptLexer
(),
formatter
)
example/settings.py
View file @
8d4c1265
...
@@ -45,4 +45,8 @@ DEBUG_TOOLBAR_PANELS = (
...
@@ -45,4 +45,8 @@ DEBUG_TOOLBAR_PANELS = (
ROOT_URLCONF
=
'example.urls'
ROOT_URLCONF
=
'example.urls'
DEBUG_TOOLBAR_CONFIG
=
{
'SHOW_TOOLBAR_CALLBACK'
:
lambda
request
:
True
,
}
INTERNAL_IPS
=
(
'127.0.0.1'
,)
INTERNAL_IPS
=
(
'127.0.0.1'
,)
example/views.py
View file @
8d4c1265
...
@@ -9,11 +9,23 @@ db = conn.debug_test
...
@@ -9,11 +9,23 @@ db = conn.debug_test
def
index
(
request
):
def
index
(
request
):
list
(
db
.
test
.
find
({
'name'
:
'test'
}))
list
(
db
.
test
.
find
({
'name'
:
'test'
}))
list
(
db
.
test
.
find
({
'name'
:
'test'
})
.
skip
(
1
))
list
(
db
.
test
.
find
({
'name'
:
'test'
,
'age'
:
{
'$lt'
:
134234
}
})
.
skip
(
1
))
db
.
test
.
find
({
'name'
:
'test'
})
.
count
()
db
.
test
.
find
({
'name'
:
'test'
})
.
count
()
db
.
test
.
find
({
'name'
:
'test'
})
.
skip
(
1
)
.
count
(
with_limit_and_skip
=
True
)
db
.
test
.
find
({
'name'
:
'test'
})
.
skip
(
1
)
.
count
(
with_limit_and_skip
=
True
)
list
(
db
.
test
.
find
({
'name'
:
'test'
})
.
sort
(
'name'
))
list
(
db
.
test
.
find
({
'name'
:
'test'
})
.
sort
(
'name'
))
sort_fields
=
[(
'name'
,
pymongo
.
DESCENDING
),
(
'date'
,
pymongo
.
ASCENDING
)]
sort_fields
=
[(
'name'
,
pymongo
.
DESCENDING
),
(
'date'
,
pymongo
.
ASCENDING
)]
list
(
db
.
test
.
find
({
'name'
:
'test'
})
.
sort
(
sort_fields
))
list
(
db
.
test
.
find
({
'name'
:
'test'
})
.
sort
(
sort_fields
))
list
(
db
.
test
.
find
({
'$or'
:
[
{
'age'
:
{
'$lt'
:
50
,
'$gt'
:
18
},
'paying'
:
True
,
},
{
'name'
:
'King of the world'
,
'paying'
:
False
,
}
]
}))
return
render_to_response
(
'index.html'
)
return
render_to_response
(
'index.html'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment