Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
b2cd0d28
Commit
b2cd0d28
authored
Oct 08, 2013
by
Carlos Andrés Rocha
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1229 from rocha/cleanup-eventtracking-mongo-authentication
Cleanup mongodb authentication
parents
7a214344
e0fb94cc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
common/djangoapps/track/backends/mongodb.py
+10
-3
No files found.
common/djangoapps/track/backends/mongodb.py
View file @
b2cd0d28
...
@@ -11,7 +11,7 @@ from pymongo.errors import PyMongoError
...
@@ -11,7 +11,7 @@ from pymongo.errors import PyMongoError
from
track.backends
import
BaseBackend
from
track.backends
import
BaseBackend
log
=
logging
.
getLogger
(
'track.backends.mongodb'
)
log
=
logging
.
getLogger
(
__name__
)
class
MongoBackend
(
BaseBackend
):
class
MongoBackend
(
BaseBackend
):
...
@@ -64,14 +64,17 @@ class MongoBackend(BaseBackend):
...
@@ -64,14 +64,17 @@ class MongoBackend(BaseBackend):
**
extra
**
extra
)
)
self
.
collection
=
self
.
connection
[
db_name
][
collection
_name
]
database
=
self
.
connection
[
db
_name
]
if
user
or
password
:
if
user
or
password
:
self
.
collection
.
database
.
authenticate
(
user
,
password
)
database
.
authenticate
(
user
,
password
)
self
.
collection
=
database
[
collection_name
]
self
.
_create_indexes
()
self
.
_create_indexes
()
def
_create_indexes
(
self
):
def
_create_indexes
(
self
):
"""Ensures the proper fields are indexed"""
# WARNING: The collection will be locked during the index
# WARNING: The collection will be locked during the index
# creation. If the collection has a large number of
# creation. If the collection has a large number of
# documents in it, the operation can take a long time.
# documents in it, the operation can take a long time.
...
@@ -83,8 +86,12 @@ class MongoBackend(BaseBackend):
...
@@ -83,8 +86,12 @@ class MongoBackend(BaseBackend):
self
.
collection
.
ensure_index
(
'event_type'
)
self
.
collection
.
ensure_index
(
'event_type'
)
def
send
(
self
,
event
):
def
send
(
self
,
event
):
"""Insert the event in to the Mongo collection"""
try
:
try
:
self
.
collection
.
insert
(
event
,
manipulate
=
False
)
self
.
collection
.
insert
(
event
,
manipulate
=
False
)
except
PyMongoError
:
except
PyMongoError
:
# The event will be lost in case of a connection error.
# pymongo will re-connect/re-authenticate automatically
# during the next event.
msg
=
'Error inserting to MongoDB event tracker backend'
msg
=
'Error inserting to MongoDB event tracker backend'
log
.
exception
(
msg
)
log
.
exception
(
msg
)
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