<div dir="ltr">Interesting question. It looks like in this implementation, even if you call cast() on a master model, the method itself will kind-of-recursively call cast() on detail models until it gets to the most detailed one, which will return itself. So every time cast() is called, eventually the most detailed model is expected to have its cast() method called and must return itself.<div><br></div><div>We could add a special case where the last one raises an exception, and the next-to-last one catches it, but I'm not sure that extra complication would be worth it. We'd be making the most common case "exceptional".</div><div><br></div><div>Having the call be idempotent is also potentially a perk, depending on how you look at it. Based on all that, plus the doc block confirming that the behavior is intentional, I don't see a problem with the current behavior.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 26, 2017 at 11:41 AM, Dennis Kliban <span dir="ltr"><<a href="mailto:dkliban@redhat.com" target="_blank">dkliban@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Looking at the cast() method[0] it looks like it's possible to call cast() on a detail model. I would like to figure out when we expect to call cast() on a detail model. Without fully knowing the motivation for this implementation, I am inclined to raise an exception when the code reaches line 113. The exception would inform the developer that calling cast() is only appropriate on a master model. What are your thoughts?<br><br><br>[0] <a href="https://github.com/pulp/pulp/blob/3.0-dev/platform/pulp/app/models/base.py#L113" target="_blank">https://github.com/pulp/pulp/<wbr>blob/3.0-dev/platform/pulp/<wbr>app/models/base.py#L113</a><span class="HOEnZb"><font color="#888888"><br><br><br></font></span></div><span class="HOEnZb"><font color="#888888">-Dennis<br></font></span></div>
<br>______________________________<wbr>_________________<br>
Pulp-dev mailing list<br>
<a href="mailto:Pulp-dev@redhat.com">Pulp-dev@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/pulp-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><p style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px!important;padding:0px!important"><span style="margin:0px!important;padding:0px!important">Michael</span> <span style="margin:0px!important;padding:0px!important">Hrivnak</span></p><p style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px!important;padding:0px!important"></p><span style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px!important;padding:0px!important"><span style="margin:0px!important;padding:0px!important">Principal Software Engineer</span><span style="margin:0px!important;padding:0px!important">, <span style="margin:0px!important;padding:0px!important">RHCE</span></span> </span><span style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px"></span><br style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px!important;padding:0px!important"><p style="color:rgb(0,0,0);font-family:overpass-mono,monospace;font-size:10px;margin:0px!important;padding:0px!important">Red Hat</p></div></div>
</div>