Site Scene

Archive for the ‘General’ Category

GenericSetup and “mismatched” tags in ZCML

Ever the issue-magnet, I’ve spent the better part of my morning trying to debug a mistmatched tag error from within some ZCML (aka XML for the non-initiated).  Essentially, the issue boiled down to the system telling me that it was certain that I had a mistmatched tag within my configuration, and presented me with the problematic XML tag (complete with line numbers).  However, life’s not always that simple. (more…)

Deliver me from … Deliverance?

Always one for being on and beyond the bleeding edge of new technology, I’ve (with the help of colleagues) been setting up a new technology for applying themes to web sites.  In particular, I’m applying Deliverance to Plone and whilst I’m not the first one to venture out into the wilderness this way, I’ve got to be thinking that I could be one of the few people documenting their experience.  Ah, but where to begin? (more…)

Migration complete (mostly)

Well, that’s always a good reason to let out a sigh of relief: I’ve managed to migrate most of the content from my previous blog over at Wikidot (which wasn’t really a blog so much as it was a hacked wiki).  So, you’ll find a lot more content here than before, which is good, because it makes me look like I’m actually dedicated to creating content ;-)

I’ve also relaxed restrictions on comments (and added CAPTCHA security) so comment away people, if you’re reading this.  Just don’t expect much love if you spam though…

User-selectable Themes In Plone

It’s something I came across a while ago, but wasn’t exactly something that stayed in the fore-front of my mind: how to let users choose or select a theme (arbitrarily) on a Plone site.  Normally, I stick to having one theme per site for continuity but a new theme-test site for clients is an exception.

If you were to search Google for the right terms, you’ll find out how to let this happen, but I ended up having to go hunt it down myself.  Hopefully this entry will help people (if I go and include as many terms as I think I or someone else might look for!).

How

Head to the ZMI as an administrative user (/manage), and then to portal_skins.  Under the Properties tab, you’ll find a Boolean option called “Allow arbitrary skins to be selected”.  You guessed it; turn to it on and save.

Your users now have a drop-down menu in their personal preferences for changing the theme.  Install some additional themes and away you go.

Note: seems like this feature doesn’t work well or I’m not using it right.  Changing the theme for one user changes it for everyone..hmm.  Probably the reason the option’s hiding in the ZMI!

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.

You are currently browsing the archives for the General category.