I am looking towards building a class interface in Python but finds that Python lacks interface constructs.
What I need is that if a programmer tries to add new properties in one class without adding properties with the same name in another class, an exception to be raised (at compile time or run time)
An example:
class MongoCompany:
company_name = MongoField()
class ESCompany:
company_name = ESField()
an exception will be raised if a programmer tries to add a field to MongoCompany without changing ESCompany.
class MongoCompany:
company_name = MongoField()
company_phone = MongoField()
class ESCompany:
company_name = ESField()
MongoCompany.init()
Edit:
Background
This is to prevent programmers from modifying MongoDB's schema declared with Mongoengine's Document class without adding the corresponding modification to Elasticsearch's schema declared in another file with elasticsearch-dsl's DocType class.