Menu

[r144]: / trunk / models.py  Maximize  Restore  History

Download this file

42 lines (32 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from django.db import models
# Start with models.Model
# examine all immediate subclasses using models.Model.__subclasses__()
# then examine each to see if it has a 'objects' attribute => data table
# if so, add to list of models we can plot with
# then examine its subclasses to see if we can find any more models
MODELS=[]
PLOT_TYPES=[]
class Dataplot(models.Model):
"""Plot of every instance in model.
"""
model=models.CharField(max_length=255,choices=MODELS)
type=models.CharField(max_length=255,choices=PLOT_TYPES)
class Admin:
pass
def get_plot(self):
pass
def save(self):
super(Dataplot,self).save()
P=self.get_plot()
kwargs=P.get_kwargs()
for k,v in kwargs:
A,C=self.argument_set.get_or_create(key=k)
if C:
A.value=v
A.save()
class Argument(models.Model):
"""Named argument to pass to dataplot function.
"""
dataplot=models.ForeignKey(Dataplot,edit_inline=True,num_in_admin=0)
key=models.CharField(max_length=255,null=False,default='',core=True)
value=models.CharField(max_length=255,null=False,default='',core=True)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.