authored by Wayne Witzel III

Scheduling Posts with Blogofile

On August 28, 2011 In python Permalink

I wanted to be able to schedule posts with blogofile and this was the quickest way I could think of to do it. If someone knows of a better way, than please comment cause I would love to read about.

My change is pretty simple, if the date in the YAML header is > than now, throw a PostProcessing exception and continue on with the next post. I added a cronjob that runs blogofile build every hour, so this solution sucks for blogs that take a long time to build or if you want precision scheduling, but my site builds fast and I am ok with an hour delay.

diff -r e370cb5a903f blog/_controllers/blog/
--- a/blog/_controllers/blog/    Tue Aug 23 23:16:37 2011 -0400
+++ b/blog/_controllers/blog/    Sun Aug 28 19:03:28 2011 -0400
@@ -70,7 +70,14 @@
     def __str__(self):
         return repr(self.value)

+class PostProcessException(Exception):

+    def __init__(self, value):
+        self.value = value
+    def __str__(self):
+        return repr(self.value)
 class Post(object):
     Class to describe a blog post and associated metadata
@@ -179,7 +186,11 @@
             self.slug = slug

if not
-   =
+         =
+        else:
+            if >
+                raise PostProcessException('Post date is in the future.')
         if not self.updated:
             self.updated =

@@ -367,7 +378,7 @@
             p = Post(src, filename=post_fn)
-        except PostParseException as e:
+        except (PostParseException,PostProcessException) as e:
             logger.warning(u"{0} : Skipping this post.".format(e.value))
         #Exclude some posts

Read and Post Comments
blog comments powered by Disqus