note-to-myself
Mar 05, 2008
Skin dependent resources
How to enable/disable resources based on the currently active skin
For the soon-to-be-released Voting machines info site of the CCC I'm using the current trunk of NuPlone for both its public facing pages, as well as for the editors.
NuPlone has a neat new feature called multiresolution layout, which is great, especially for editors. Basically it means, if you have a bigger screen or wider window you get a three column layout, if not, the layout is based on two columns (you can test that feature here at tomster.org).
However, for the CCC site the feature proved to be more confusing than useful for public visitors, so I wanted to make sure that the JS resource, responsible for that feature was only rendered, if the NuPlone skin was used.
The initial idea, was to include an empty multi-resolution.js file with the Wahlcomputer skin but it turns out, it's possible to evaluate the name of the current skin in the conditional expression of a resource. In this case I used the following snippet inside jsregistry.xml:
<javascript cacheable="True"
compression="safe"
cookable="True"
enabled="True"
expression="python:portal.getCurrentSkinName()=='NuPlone'"
id="multi-resolution.js"
inline="False"/>
Instead of the default empty expression I used python:portal.getCurrentSkinName()=='NuPlone' and bingo!
Jan 22, 2008
Unexpiring content
Others got SQL. We've got the catalog.
Here's a quick snippet for quickly un-expiring content from a ./bin/instance debug session:
plone_site = app.foo
from transaction import commit
import DateTime
now = DateTime.now()
for brain in plone_site.portal_catalog({
'expires' : {'query' : now, 'range' : 'max'}}):
obj = brain.getObject()
obj.setExpirationDate(now + 30)
obj.reindexObject()
commit()
This sets the expiration date of all currently expired objects 30 days into the future. (You'll need to change app.foo to the id of your plone instance, of course.)
Aug 06, 2007
Convert XHTML to Google Code's Wiki Syntax
From the Note-to-Myself-Department
I've just created a Google Code project and wanted to put its Documentation (in the form of a RST-formatted DocTest, of course!) into the project's wiki and after lots of trial and error the best result seems to be achievable with a Perl script written by a wikipedia Author named Diberri.
Currently I'm just using the online converter but I might write a script that converts the RST source to HTML (which I do anyway alread) and then finally to WikiMarkup. Since Google exposes a project's wiki pages inside its subversion repository, all I would need to do is copy the result of the final conversion to something like ../../wiki/MainPage.And before I forget: I the best results using MoinMoin as target format and activating the "Show parsed HTML" option.
Feb 28, 2007
Negative Margins in Safari and IE
From the Quick-and-Dirty Department
Ah, what better way to end a multi-month-long blogging hiatus than with a brief 'note to myself'...
Here it goes: in order to properly use negative margins you must declare the object's position as relative for Safari and static for WinIE. (This was, admittedly for a special use case, where the div wrapping the element with the negative margin also was set to overflow: none and WinIE wouldn't honour that, if the contained item's position was set to relative.)
So there, the spell has been broken... see ya!
Oct 02, 2006
Ressource temporarily not available
From the Easy-to-solve-but-hard-to-Google-Department
"Ressource temporarily not available" -- if you've ever been confronted with this message on Mac OS X and found that a particular program would no longer be able to run until you restarted, you've probably reached the limit of simultaneously allowed processes. The default for Mac OS XS is set to 100, which probably should be enough for the majority of users out there, but for a developer this limit can easily be reached in the course of his or her normal work. What to do? Well, Phillip Moore has the answer:
create /etc/launchd.conf file if it does not already exist and add the following line:
limit maxproc 512 2048
You will need to reboot for the change to take effect, but after that you'll probably never run into this problem again...
