I have pserve --reload working with any python changes, but I still have to manually reload when I change a template.
I made this little script that monitors my templates folder for any changes, but what is the command to reload pserve? If I need to call a pserve method from within my Pyramids project, like in init.py or something, what is the method I would call to reload pserve?
#!/usr/bin/env python
import sys
import pyinotify
from subprocess import call
import time
wm = pyinotify.WatchManager()
mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE | pyinotify.IN_MODIFY
class EventHandler(pyinotify.ProcessEvent):
def process_IN_MODIFY(self, event):
print "Modified: ", event.pathname
# This is where my reload call would go...
# call(["pserve", "reload"])
handler = EventHandler()
notifier = pyinotify.Notifier(wm, handler)
wdd = wm.add_watch("/path/to/my/pyramid/templates/", mask, rec=True, auto_add=True)
notifier.loop()
Pyramid already provides a method to reload templates without restarting pserve
by putting such configuration in a PasteDeploy development.ini
file or using environment variables. See Environment Variables and .ini File Settings. Of course, do not enable template reloading in production as it slows down your application.