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
d06e16d9
Commit
d06e16d9
authored
Aug 06, 2015
by
Davorin Sego
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initialize signal handler, so we can remove getattr
parent
a7f2b025
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
40 deletions
+17
-40
common/lib/xmodule/xmodule/modulestore/__init__.py
+17
-40
No files found.
common/lib/xmodule/xmodule/modulestore/__init__.py
View file @
d06e16d9
...
@@ -154,17 +154,6 @@ class ActiveBulkThread(threading.local):
...
@@ -154,17 +154,6 @@ class ActiveBulkThread(threading.local):
self
.
records
=
defaultdict
(
bulk_ops_record_type
)
self
.
records
=
defaultdict
(
bulk_ops_record_type
)
class
NullSignalHandler
(
object
):
"""
A null handler that does nothing
"""
def
send
(
self
,
*
args
,
**
kwargs
):
"""
No-op
"""
pass
class
BulkOperationsMixin
(
object
):
class
BulkOperationsMixin
(
object
):
"""
"""
This implements the :meth:`bulk_operations` modulestore semantics which handles nested invocations
This implements the :meth:`bulk_operations` modulestore semantics which handles nested invocations
...
@@ -180,23 +169,8 @@ class BulkOperationsMixin(object):
...
@@ -180,23 +169,8 @@ class BulkOperationsMixin(object):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
BulkOperationsMixin
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
BulkOperationsMixin
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
_active_bulk_ops
=
ActiveBulkThread
(
self
.
_bulk_ops_record_type
)
self
.
_active_bulk_ops
=
ActiveBulkThread
(
self
.
_bulk_ops_record_type
)
self
.
_
signal_handler
=
None
self
.
signal_handler
=
None
@property
def
signal_handler
(
self
):
"""
Return a signal handler, defaults to a null handler that does nothing.
"""
if
not
self
.
_signal_handler
:
self
.
_signal_handler
=
NullSignalHandler
()
return
self
.
_signal_handler
@signal_handler.setter
def
signal_handler
(
self
,
value
):
"""
Set the signal handler
"""
self
.
_signal_handler
=
value
@contextmanager
@contextmanager
def
bulk_operations
(
self
,
course_id
,
emit_signals
=
True
):
def
bulk_operations
(
self
,
course_id
,
emit_signals
=
True
):
...
@@ -324,7 +298,7 @@ class BulkOperationsMixin(object):
...
@@ -324,7 +298,7 @@ class BulkOperationsMixin(object):
"""
"""
Sends out the signal that items have been published from within this course.
Sends out the signal that items have been published from within this course.
"""
"""
if
bulk_ops_record
.
has_publish_item
:
if
self
.
signal_handler
and
bulk_ops_record
.
has_publish_item
:
self
.
signal_handler
.
send
(
"course_published"
,
course_key
=
course_id
)
self
.
signal_handler
.
send
(
"course_published"
,
course_key
=
course_id
)
bulk_ops_record
.
has_publish_item
=
False
bulk_ops_record
.
has_publish_item
=
False
...
@@ -332,7 +306,7 @@ class BulkOperationsMixin(object):
...
@@ -332,7 +306,7 @@ class BulkOperationsMixin(object):
"""
"""
Sends out the signal that library have been updated.
Sends out the signal that library have been updated.
"""
"""
if
bulk_ops_record
.
has_library_updated_item
:
if
self
.
signal_handler
and
bulk_ops_record
.
has_library_updated_item
:
self
.
signal_handler
.
send
(
"library_updated"
,
library_key
=
library_id
)
self
.
signal_handler
.
send
(
"library_updated"
,
library_key
=
library_id
)
bulk_ops_record
.
has_library_updated_item
=
False
bulk_ops_record
.
has_library_updated_item
=
False
...
@@ -1364,11 +1338,12 @@ class ModuleStoreWriteBase(ModuleStoreReadBase, ModuleStoreWrite):
...
@@ -1364,11 +1338,12 @@ class ModuleStoreWriteBase(ModuleStoreReadBase, ModuleStoreWrite):
Arguments:
Arguments:
course_key - course_key to which the signal applies
course_key - course_key to which the signal applies
"""
"""
bulk_record
=
self
.
_get_bulk_ops_record
(
course_key
)
if
isinstance
(
self
,
BulkOperationsMixin
)
else
None
if
self
.
signal_handler
:
if
bulk_record
and
bulk_record
.
active
:
bulk_record
=
self
.
_get_bulk_ops_record
(
course_key
)
if
isinstance
(
self
,
BulkOperationsMixin
)
else
None
bulk_record
.
has_publish_item
=
True
if
bulk_record
and
bulk_record
.
active
:
else
:
bulk_record
.
has_publish_item
=
True
self
.
signal_handler
.
send
(
"course_published"
,
course_key
=
course_key
)
else
:
self
.
signal_handler
.
send
(
"course_published"
,
course_key
=
course_key
)
def
_flag_library_updated_event
(
self
,
library_key
):
def
_flag_library_updated_event
(
self
,
library_key
):
"""
"""
...
@@ -1379,17 +1354,19 @@ class ModuleStoreWriteBase(ModuleStoreReadBase, ModuleStoreWrite):
...
@@ -1379,17 +1354,19 @@ class ModuleStoreWriteBase(ModuleStoreReadBase, ModuleStoreWrite):
Arguments:
Arguments:
library_key - library_key to which the signal applies
library_key - library_key to which the signal applies
"""
"""
bulk_record
=
self
.
_get_bulk_ops_record
(
library_key
)
if
isinstance
(
self
,
BulkOperationsMixin
)
else
None
if
self
.
signal_handler
:
if
bulk_record
and
bulk_record
.
active
:
bulk_record
=
self
.
_get_bulk_ops_record
(
library_key
)
if
isinstance
(
self
,
BulkOperationsMixin
)
else
None
bulk_record
.
has_library_updated_item
=
True
if
bulk_record
and
bulk_record
.
active
:
else
:
bulk_record
.
has_library_updated_item
=
True
self
.
signal_handler
.
send
(
"library_updated"
,
library_key
=
library_key
)
else
:
self
.
signal_handler
.
send
(
"library_updated"
,
library_key
=
library_key
)
def
_emit_course_deleted_signal
(
self
,
course_key
):
def
_emit_course_deleted_signal
(
self
,
course_key
):
"""
"""
Helper method used to emit the course_deleted signal.
Helper method used to emit the course_deleted signal.
"""
"""
self
.
signal_handler
.
send
(
"course_deleted"
,
course_key
=
course_key
)
if
self
.
signal_handler
:
self
.
signal_handler
.
send
(
"course_deleted"
,
course_key
=
course_key
)
def
only_xmodules
(
identifier
,
entry_points
):
def
only_xmodules
(
identifier
,
entry_points
):
...
...
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