django - python use different parent class for child class -


Using Python and Django, we are preparing a framework for running many scientific models. Python runs the model, and the Django is used to keep track of the situation and to create output on the webpage. This works fine in operational mode, because the whole platform (database, DJGenzo executable) is available. Although for offline production and testing of new models, my colleagues often work on code alone, no connection to the environment. Then the part of the degena is often a burden (environment, database should be established, computational overhead) so we are looking for a way to turn Django-Functions on and off.

We currently have a general class iModel, which has all the functionality to run any model in the frameboard, there are also some DNS calls. Childclasses are inherited, and model-specific functionality from this class.

I was thinking of dividing class iModel into two classes. An additional class iClassWithDjango (), which will be inherited from iModel and adds functionality to Django, class iModel as a wrapper around

first class

  class iModel ( thing):. Def run (self): self.prepareInputDate () self.runModel ()   

and Class II

  os.environ.setdefault ( "DJANGO_SETTINGS_MODULE", "framework.settings") import django.some.modules class IModelWithDjango (IModel): def run (self): some Dijengo call (eg. 'Running' changes dB position) super (Aimold with Dijengo, run) some Depending on the situation (operational or offline), DOGmodel and CATmodel resp in succession will be sued to IModelwithDjango () Received from iModel () therefore change dynamically as the script at runtime.  

In fact, my biggest problem is how to control the import of the Django module. How can I stop it from being in offline mode (because it will fail because the Django environment is not set). I thought iModelWithDjango () was placed above in a separate module file (as it has been done above), but there are probably better ways to do this.

Maybe I can turn it off with a lot of crapping coding, but I was hoping that some of you can inspire me to practice some clean coding any advice Welcome

If I understand your question well, then you are conditionally linked (import ) Want to link the module to your project? There are different ways to do this.

There is only one way:.

  If Standalone: ​​iModel import IModel = rest IModel Runner: iModelWithDjango import = IModelWithDjango runner (from IModelWithDjango runner) Karun ()    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -