I want to implement interface functionality in python. I wrote
following sample code
https://gist.github.com/1559689
Here I use an abc as an interface.
Couple of my models are implementing this interface and one of my
consumer model is using those models. In this implementation, I use my
abstract class to check if my models are implementing enough
functionality to make consumer model methods work (use_object method).
Since I used abc's here, I get an error as soon as I try to
instantiate a model object. (I do not need to invoke use_object method
for validation to work.)
Question 1) Is there a better way to implement this validation
functionality.
Question 2) In this implementation, Validation happens at object
instantiation time. Which means If I don't instantiate any object I
won't get any error, Is there a ( short ) way of getting this check on
code initialization? ( I am not dynamicly changing methods of my
models)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 comments:
Post a Comment