[Pulp-dev] [pulp 3] cast() method for casting from a Master to Detail model instance

Sean Myers sean.myers at redhat.com
Fri May 26 21:15:37 UTC 2017

On 05/26/2017 11:41 AM, Dennis Kliban wrote:
> 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.

You don't always know if you're dealing with a master model instance
or its related cast detail model instance. This method makes calling
cast on a detail instance a no-op, so it costs when you need to pay
the price, and is free when you don't. It also has the effect that
"instance is instance.cast()" when casting detail instances. As
Michael pointed out, raising an exception here would be an expection
antipattern (raising exceptions in non-exceptional cases).

On 05/26/2017 04:27 PM, Dennis Kliban wrote:
> The problem occurs when a worker receives a task to perform a publish, but
> it doesn't have the plugin installed.

The problem is that the plugin is not installed on the worker, so fix
*that* problem. Install the plugin on the worker. If anything should
raise an exception, it should be a warning on worker start that
unknown content types exist in the db, including what the master type
is and what the unknown content types are.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 866 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/pulp-dev/attachments/20170526/aaf6f9bd/attachment.sig>

More information about the Pulp-dev mailing list