Site Scene

Posts Tagged ‘date’

Plone/Zope: Truncating a Data.fs back to a certain date/time

Okay. So, anyone out here who’s listening — particularly those overly-enthusiastic users — don’t try to recursively wget your Plone site (or other CMS, for that matter) whilst you’re logged in with an account that can make edits. It will lead to a very bad situation where your site administrator and technical team need to step in and fix your mistakes. For the uninitiated, a loose recursive wget (when logged in with some degree of Edit rights) will hit every link that’s on your pages, and I mean in the (X)HTML source. For a Plone site, this means hitting every “Edit” link, every “Revert to this version” link, and every other link that might be dangerous when clicked randomly. Oh, and if the account you’ve got has admin rights, well, it’s not getting any better and requires the Data.fs to be undone back to before it happened. Here’s how to do that easily. (more…)

Good Morning World Plone Day!

Good morning from the land down under and welcome to World Plone Day 2010! It’s right on the hour (well, just after now) and 28 April 2010 — and yes, that’s World Plone Day to the uninitiated. To celebrate and to mark the occasion, I’ll be holding a bit of a discussion today about what Plone is, why it’s so useful, and what we, as users, are hanging out for in Plone 4 and above. But, what fun is that without sweets to eat?  And what’s potentially tastier than Plone?  Plone cupcakes!

Thanks to some great work by my lovely partner, she’s whipped up some cupcakes for WPD.  I didn’t do much save for helping with design and icing — woo!  Here’s the end results:

Okay, so the CMYK colour might be a little off and I’m thinking I’m not conforming to all Plone logo usage guidelines but they look good.  Haven’t tasted them yet but I’m sure they’ll be excellent.  I had thought of a line like “Open Source never tasted so sweet”, but I think I’ll let that go.

Viva la World Plone Day!

Git and checkouts by date

Cheers to this very handy post for posting details from Nabble on how to check out a git branch based upon the date it was commited.  If I haven’t modified WordPress to turn off the character replacement, then watch out because the double-quotes and double-dash will need to be checked before running the command.

git checkout `git rev-list -n 1 --before="2009-07-27 13:37" master`

A very easy way to flick back to a given revision.

DateTime in Python/Zope/Plone is painful

Alright, now for today’s problem:  why do two dates that look different when outputted actually end up being the same date?

Answer: I’m not sure, but I’m pretty sure it’s got something to do with the wacky support the above-mentioned 3 products have for timezones.

The background: Plone stores a DateTime object to record a user’s last login time.  It doesn’t really matter what’s purpose is, because Plone (this time) isn’t at fault.  The DateTime gets stored, no worries.  The problem arises when you try to put that value back into a DateTime object.  Now, I’d have thought it’d be as simple as doing this:

dt = DateTime(member.getProperty('login_time'))

And realistically, it is.  Except that printing/using that value – at least for me – results in a time that appears as UTC, but is reported as being in my timezone (aka a time that’s 10 hours behind since I’m GMT+10).

The fix: the time still knows its timezone correctly, so just give it a kick.

dt = DateTime(member.getProperty('login_time'))
dt = dt.toZone(dt.timezone())

Amazingly, doing a comparison (using cmp) between the original DateTime object and it’s ‘corrected’ version actually shows that they’re the same.  Uhuh.