> > > I think there is still an improvement to be made with cast() when it fails > to cast. The cast method itself can't know if you're dealing with the > master or most detailed object, but the code author calling cast() always > knows and if they don't need it cast() they shouldn't call cast(). For > example the publish code here [0]. The publish code calls cast() because it > needs the type to be the detail version of models.Publisher. Anytime the > plugin writer (or core) looks up a master instance and calls cast() and it > returns the exact same object that was requested to be cast() that should > cause an error instead of failing silently. What do you all think about > this? >
Rather than adding an argument to cast we could just catch the `AttributeError`. >From the publish example [0]: try: publisher.publish() # publish is defined on the detail model, never the master model. except AttributeError as e: raise SomePulpCodedException > > > [0]: https://github.com/pulp/pulp/commit/bf7433236c5cf5203808341c74715a > d257d69718#diff-5e2d175476716cc65d5d2d61b7eb5efdR35 > > > >
_______________________________________________ Pulp-dev mailing list Pulp-dev@redhat.com https://www.redhat.com/mailman/listinfo/pulp-dev