Menu

[r18]: / trunk / cache.py  Maximize  Restore  History

Download this file

43 lines (32 with data), 1.3 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
"""Auto-update cached images based on when related objects are saved.
Don't know how exactly this will be implemented yet, but the initial
idea is to use the PlotModel class in your models.py, which will
provide a wrapper around the usual save method. This doesn't work in
the current Django version for some reason, so another method may be
needed. This feature put on the backburner 2007-07-12.
"""
from django.db.models import Model
class PlotModel(Model):
"""Extends standard django Model to support figure autosave.
Specify which plots you want to remake after saving with the class
attribute DJANGO_RPY_REMAKE_ON_SAVE=['plot1','plot2'].
Currently does not work. Don't know how we will make it work.
"""
def __init__(self,*args,**kwargs):
super(PlotModel,self).__init__(*args,**kwargs)
self.init_django_rpy_plots()
def save(self):
"""Try to remake designated plots.
Fail silently if impossible to make.
"""
super(PlotModel,self).save()
try:
for attrname in dir(self):
try:
plot=getattr(self,attrname)
if plot.DJANGO_RPY_MAKEFILE_ON_SAVE:
plot.makefile()
except:
pass
except AttributeError:
pass
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.