Skip to content

More xblock.save() calls to handle fields set during inits - #505

Merged
dmitchell merged 2 commits into
masterfrom
dhm/xblock_save
Jul 29, 2013
Merged

More xblock.save() calls to handle fields set during inits#505
dmitchell merged 2 commits into
masterfrom
dhm/xblock_save

Conversation

@dmitchell

Copy link
Copy Markdown
Contributor

and other possible side effecting calls

@cpennington @chrisndodge Please review.

I need to think of tests which will fail w/o these changes and then prove they pass, but hopefully otherwise this is done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, does seem like overkill. Can you explain why you think you might need this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only an abundance of caution. The problem is that init on some of our
descriptors set fields. I think I ensured that get_item will call .save()
but preview had an odd pattern which I vacillated on.

On Thu, Jul 25, 2013 at 9:57 PM, chrisndodge notifications@github.comwrote:

In cms/djangoapps/contentstore/views/preview.py:

@@ -43,6 +43,8 @@ def preview_dispatch(request, preview_id, location, dispatch=None):
"""

 descriptor = modulestore().get_item(location)
  • decache any pending field settings -- this one may be overkill

  • descriptor.save()

IMO, does seem like overkill. Can you explain why you think you might need
this?


Reply to this email directly or view it on GitHubhttps://github.com/edx/edx-platform/pull/505/files#r5414625
.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to remove that one. I put the comment there particularly to see
if anyone thought it was necessary to keep.

On Fri, Jul 26, 2013 at 8:51 AM, Don-edX Mitchell dmitchell@edx.org wrote:

Only an abundance of caution. The problem is that init on some of our
descriptors set fields. I think I ensured that get_item will call .save()
but preview had an odd pattern which I vacillated on.

On Thu, Jul 25, 2013 at 9:57 PM, chrisndodge notifications@github.comwrote:

In cms/djangoapps/contentstore/views/preview.py:

@@ -43,6 +43,8 @@ def preview_dispatch(request, preview_id, location, dispatch=None):
"""

 descriptor = modulestore().get_item(location)
  • decache any pending field settings -- this one may be overkill

  • descriptor.save()

IMO, does seem like overkill. Can you explain why you think you might
need this?


Reply to this email directly or view it on GitHubhttps://github.com/edx/edx-platform/pull/505/files#r5414625
.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, given that load_item has the call to .save(), I don't think we should add it here.

@chrisndodge

Copy link
Copy Markdown
Contributor

I can't VPN into jenkins, any ideas why the build is failing?

@dmitchell

Copy link
Copy Markdown
Contributor Author

@dianakhuang @sarina Here's the PR I put in for the missing save calls.

@dmitchell

Copy link
Copy Markdown
Contributor Author

Build failure was git or gcli. That is, never even made it to the build.

Comment thread common/lib/xmodule/xmodule/x_module.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should call .save on parent_xblock as well, since its children have been edited.

However, I think that xblock_from_json is probably the thing that should be responsible for calling .save() on the new_block

@dmitchell

Copy link
Copy Markdown
Contributor Author

All comments verified and addressed, thank you all. Still no unit tests, but can I get approval to merge?

@cpennington

Copy link
Copy Markdown
Contributor

Have you/could you verify that it fixes the issue w/ saw last week on edge?

@dmitchell

Copy link
Copy Markdown
Contributor Author

I never saw the problem on any env other than edge. Setting up for
reproduction would be onerous. I'd have to roll back my system to before
Peter Fogg's and possibly the xblock save() changes, create a course w/
video pointing to something other than Lyla, and then roll forward. Knowing
my luck, I wouldn't be able to reproduce the bug; so, I wouldn't be able to
verify the fix. As I didn't cause the bug, that seems more than heroic
counter measures and a skill set better suited to a QA engineer.

On Mon, Jul 29, 2013 at 9:23 AM, Calen Pennington
notifications@github.comwrote:

Have you/could you verify that it fixes the issue w/ saw last week on edge?


Reply to this email directly or view it on GitHubhttps://github.com/edx/edx-platform/pull/505#issuecomment-21719175
.

@sarina

sarina commented Jul 29, 2013

Copy link
Copy Markdown
Contributor

I can repro the issue on edge (it's still on master). Checking out this branch appears to fix the issue (I see Gregory Nagy's beautiful floating head once again).

@dmitchell

Copy link
Copy Markdown
Contributor Author

Sarina, You're my star. Thank you.

Peter's writing a unit test (create video descriptor and then access field
via own_metadata() rather than field accessor to go around ModelType
retrieval logic).

On Mon, Jul 29, 2013 at 10:10 AM, Sarina Canelake
notifications@github.comwrote:

I can repro the issue on edge (it's still on master). Checking out this
branch appears to fix the issue (I see Gregory Nagy's beautiful floating
head once again).


Reply to this email directly or view it on GitHubhttps://github.com/edx/edx-platform/pull/505#issuecomment-21722226
.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These edits (PEP8?) appear unrelated to the bug fix. I'm fine with it, but it seems extraneous.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it had some changes which I removed. I thought about taking it out but thought it didn't matter.

@chrisndodge

Copy link
Copy Markdown
Contributor

+1. Just one comment that a changed file appears to be unrelated to the bug fix.

Comment thread common/lib/xmodule/xmodule/x_module.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things - what if parent_xblock is None? (this line will probably say, "Nonetype object has no attribute 'save'"

Second thing - until I'm done working on https://edx-wiki.atlassian.net/browse/LMS-769 , mutable types won't actually be persisted if you only call things like append. You'll need to do something like children.append(new_block); parent_xblock.children = children so that you actually hit a __set__ call, so that the save will actually persist the new list.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what happens when I just listen to comments and don't think. Thank you.

@sarina

sarina commented Jul 29, 2013

Copy link
Copy Markdown
Contributor

Looks good to me. Pretty sure this will build properly but may be worth running tests locally before merging, since Jenkins is down at the moment and we want to be safe!

@dmitchell

Copy link
Copy Markdown
Contributor Author

I ran the tests.

On Mon, Jul 29, 2013 at 12:27 PM, Sarina Canelake
notifications@github.comwrote:

Looks good to me. Pretty sure this will build properly but may be worth
running tests locally before merging, since Jenkins is down at the moment
and we want to be safe!


Reply to this email directly or view it on GitHubhttps://github.com/edx/edx-platform/pull/505#issuecomment-21732133
.

dmitchell added a commit that referenced this pull request Jul 29, 2013
More xblock.save() calls to handle fields set during inits
@dmitchell
dmitchell merged commit 0578175 into master Jul 29, 2013
@cpennington
cpennington deleted the dhm/xblock_save branch July 29, 2013 16:37
chrisrossi pushed a commit to jazkarta/edx-platform that referenced this pull request Mar 31, 2014
Kelketek referenced this pull request in open-craft/openedx-platform Sep 17, 2015
hachiyanagi-ks added a commit to nttks/edx-platform that referenced this pull request Nov 20, 2015
diegomillan pushed a commit to eduNEXT/edx-platform that referenced this pull request Sep 14, 2016
…ponent-id-overflow

Hide overflow of component ID in studio
yoann-mroz pushed a commit to weuplearning/edx-platform that referenced this pull request Nov 30, 2020
PR openedx#505 mistakenly omitted the microfrontend
services from the new `DEFAULT_SERVICES`
list, which determines what is brought up upon
`make dev.up`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants