Rick Hurst Web Developer in Bristol, UK

Menu

Category: plone

I can see clearly now..

Clouseau product in Plone
At plone conference I saw Andy McKay demonstrate his Clouseau product, but I have only just got round to trying it. Incredibly useful – I particularly like the way you can use it in context, i.e. when editing a plone page you can click the magnifying glass icon, type “context.” and instantly get a list of the attributes and methods available via the Schema. For people like me who find the zodb a dark and mysterious place, this is a nice environment to use to explore. Cheers Andy!

Getting the Title of the current level0 node in Plone

This is not so much a “how-to”, but more of a “is this how-to?”, I post it here mainly to invite comment and expose my ignorance about the much cleaner method that probably exists.

OK, first my use case – in a skin I am building the title of the current level 0 node is always displayed as a section heading e.g. If you are viewing the page “eggs”, a few levels down and the breadcrumb trail reads home -> foo -> bar -> eggs, “foo” is displayed as a banner heading, so wherever you are in the site you know what main section you are in.

so I have created a skin script called getLevelZeroTitle that has approximately this in it (with try/except statements, and a list of id’s to ignore to handle errors):-

current_level0_path = ‘/’.join(context.getPhysicalPath()[:3])
section_id = context.getPhysicalPath()[2]
current_level0_title = context.portal_catalog(path=current_level0_path)[0].Title
return current_level0_title

Is this the way forward or is there something “built in” to handle this?

archived comments

Rick,

Funny, we had a very similar use-case recently.

We wrote a script that looked like this:

## Script (Python) “getSectionTitleForBanner”
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Figure out the appropriate title for the display banner
##
# Get the physical path to the context & the site portal
curr_path = context.getPhysicalPath()
portal = portal_path = context.portal_url.getPortalObject()
portal_path = portal.getPhysicalPath()

len_portalpath = len(portal_path)
from_root_path = curr_path[len_portalpath:]

if len(from_root_path) > 1:

if curr_path != portal_path:
from_root_path = from_root_path[:1]

from_root_path = “/”.join(from_root_path)
display_section = portal.restrictedTraverse(from_root_path)

return display_section.Title()
——–

HTH. (I cut out a section that handled an exception where we wanted to not show level 0 folder sections).

Jon Stahl 2006-12-13 15:19:00

first version posted has assumptions about location of portal in zodb.. second version.. is overly complex and expensive.. something simpler..

portal = context.portal_url.getPortalObject()
parent = context
if parent is portal: return portal.TItle()
while 1:
if parent.aq_parent is portal:
return parent.Title()
parent = parent.aq_parent

kapil 2006-12-15 00:26:01

Thanks Kapil!
I’m a newbie at python but was able to fathom your elegant script (once I saw the typo and realized where indenting was needed) and use it on the site I’m currently building.

Winn King 2006-12-25 02:46:05

If you love your plone data, set it free…

If you can get it back into version 2.5 then the data belongs to plone, otherwise it never belonged to plone in the first place..

I’m still undecided and a bit lost about how i’m going to get www.dfrskatezine.com upgraded from 2.1 to plone 2.5

To recap:-

  • I can’t really upgrade it in situ (although could be persuaded to try it if people think this is the best bet)
  • portal zexp import didn’t work for me
  • smaller zexp imports left me with broken stuff.
  • it is on a shared instance so the data.fs file is too big to move realistically (once again, still an option if encouraged)

so…I’ve started creating some zpts that I can use to dump content as xml files (e.g. all_articles.xml, containing title, content, url and any other data I need to move – kind of RSS on acid). Not quite XMLforest, but I haven’t got my head round that yet as I live in the skin layer mostly. The masterplan is to then use some python foo magic to populate a fresh 2.5.most_recent_stable site from this XML.

Obviously I need to handle the images and other files seperately – so far I have used a skin script to generate a file containing wget statements for each visible/published image on the site and download the images with a mirrored folder structure, along with an accompanying xml file with the captions, descriptions and paths. I intend to rebuild my products from scratch (pop my zope 3 cherry even?) so I don’t necessarily need my existing products to be 2.5 compatible.

Think i’m going about this the wrong way? Please let me know! Please also bear in mind that while I am a keen student, I am mostly a GUI guy (+ basic archetypes development), and am easily confused by your crazy python talk, and have been made weak by your excellent installers, to the point that I haven’t got a clue how you would go about installing or upgrading zope if it requires me to do anything more than click buttons 😉

archived comments

You might want to look into GenericSetup. There was a talk at the Plone conf about it. http://plone.org/events/conferences/seattle-2006/presentations/PloneConference2006-GenericSetup.pdf/view

Also check out CMFFolderExport: http://palladion.com/home/tseaver/software/CMFFolderExport

Good luck.

skeeter 2006-11-21 17:23:40

Moving the Data.fs is the recommended (and only guaranteed) way that this’ll work. Your time is too valuable for you to waste it re-building XML support. 😉

Just remember to pack the database from the control panel before transferring it, and it should be a decent size (depending on the content, of course).

Alexander Limi 2006-11-21 18:06:21

There’s ArcheCSV that you could try: http://plone.org/products/archecsv. Walk over your content types with a page template and create a .csv out of it and use ArcheCSV to import it. It looks like you have ~40 or so articles so it shouldn’t be too bad…

FWIW, one thing I did last week was bulk import about 500 links into a Plone portal from an unordered list of links on a single HTML page. I parsed the page with BeautifulSoup (http://www.crummy.com/software/BeautifulSoup/) and used a Plone Link template (download any Link content type via WebDAV to get the template) to create individual link files that I could just upload via WebDAV.

Shane

Shane Graber 2006-11-21 19:41:38

Upgrading from 2.1 to 2.5 should be pretty painless to do in situ – just make sure you have backups, so you can revert if it for some reason should fail.

Alexander Limi 2006-11-22 12:44:23

Thanks for all your much appreciated advice – I have made a bit of progress by moving data.fs – I now have a partially functional local copy running on plone 2.5 on my mac 🙂

Rick Hurst 2006-11-22 14:14:58

How to confuse the hell out of the plone navtree and yourself in six easy steps

Six simple steps to make the plone 2.5 navigation portlet get it’s knickers in a twist:-

  1. create a folder in the root of a plone site
  2. in folder contents in the root, move your folder to the top so that it is the first item (after “home” if you have that enabled) in the navigation tree
  3. in the new folder create a new page and set that page as the default view
  4. in the ZMI enable “Folder” as a type that can be used for a default page (see this is where I should have known something bad was going to happen)
  5. go to the root of the site and set your new folder as the default view of the portal (i.e so that the homepage of the portal is in fact the default page in your new folder one level deep – believe it or not I had a reason to do this)
  6. Hey presto your new folder falls to the bottom of the navtree – no amount of reordering will persuade it otherwise! You can try swearing too if you like, that won’t work either 😉

archived comments

Yep, I realise this is a bizarre use case – one which came from a client where I had migrated their site from another CMS, which had the home page of the site being the same page as the default page of an “about” section. They didn’t want to change this set-up. I won’t file it as a bug and I promise I won’t do it again 😉

In the end I solved my problem by not doing the “folder as default page” hack, but adding “about” as the first option for default_page under site_properties – a hack which works here as long as there are no other objects of the same name. I’ll publish the url of the site when it goes live so you can see my use case.

Rick 2006-11-08 08:42:42

I’m not even going to try to think about why you’d want to do this. File a bug if you wish. It’ll probably be assigned to me and I’ll probably ignore it on account of silly use case. 🙂

If you see this happening with other types than Folder (i.e. where there is a real use case) then it’s a more serious bug. I think RichDocument and other non-structural folder (marked with INonStructuralFolder) are the ones that would be bad if they don’t work.

If I were to guess, I’d say that:

– When the Folder is the default-page of the portal, it ought to be hidden
– However, you have showAllParents on
– The folder itself actually has a default page, or something else is causing the showAllParents logic to be invoked (this may be a bug)
– showAllParents will always place at the bottom (limi says we may move this to the top instead)

To be clear, showAllParents (a flag, which when true implies this behaviour – ) works on things that are ordinarily not in the tree (typically marked with “hide in navigation” or of a non-listed type). If the current item or one of its direct ancestors is not visible and showAllParents is true, it will still show those items. It may not know where to show them, though, in which case it’ll end up at the bottom. It depends. Navtree code is complex.

Martin

Martin Aspeli 2006-11-07 23:16:32

There’s a reason folders are not enabled as being default views of a folder, you know. If you change that, you’re on your own. 😉

Alexander Limi 2006-11-08 00:23:58

PloneFormGen – through the web form builder for plone

An off-hand comment I heard about PloneFormGen while I was at plone conference has possibly just payed for most of the conference and travel expense to get to Seattle. I can’t remember where I heard it, but someone mentioned that it was a nice product. I stuck it on my mental to-do list to try it out…

I’m currently working on a site that is close to going live and I had an email waiting for me from the client on friday, saying something like “by the way, can you change that join button so that it sais join our mailing list?” The conversation that followed let me establish that in fact what they wanted was a custom contact form with a few extra options. Usually I would then proceed to hack the contact form and mail script around to achieve this – knowing that I would have to be careful not to lose my customisations if I upgraded or reskinned the site, but this time I decided to try PloneFormGen.

Now that really was painless, really easy to figure out (i’m one of those people who you have to threaten with physical violence before I will RTFM). Thumbs up to Steve McMahon for a very useful product 🙂

what I did on hol..h^h^h.. at plone conf 2006

central not so perky

I intended to do a comprehensive wrap up of our trip to plone conference in seattle (and stopover in new york), but it is still a bit of a blur, and i’m still jetlagged (ok, i’m just a lightweight, i’m always sleepy). I need to have a look at all the presentation material and my notes, so I promise to write something up and provide some feedback to the presenters in the next week.

The major insight (plonewise) to come out of this week is that resistance to Zope 3 is futile, in fact i’m quite excited about the idea now 🙂

stick a fork in me – i’m done



it’s the start of day three of plone conference 2006 and I am stuffed with both plone knowlege and lovely delicious fatty food. This hasn’t been as debauched as previous conferences (for the netsight contingent at least) as the jet lag has made us flake out in the evening before we manage to to do any serious damage to our livers.

Last night we took a cab up to a mall to try to procure some cheap consumer electronics – the cab ride there and back was an experience in itself – the first driver hadn’t got a clue where he was going and was asking for directions from us, while mysteriously changing lanes and indicating for no reason – the driver on the way back thought he was in Gran Turismo or something.

plone conference 2006 seattle

space needle

i’m two days into plone conference 2006 and it has all been a bit of a whirlwind so far. I’m eight hours behind UK time and travelled 26 hours to get here after missing our connecting flight in houston, thanks to some helpful individual at passport control who wouldn’t let us jump the queue.

so far we haven’t ventured much further than three or four blocks away from the venue, but luckily there are ample bars and restaurants close by. The hotel has good wifi, the conference venue wifi has been intermittent but seems to be improving. I’ve been too busy to blog much, but I have uploaded one or two photos to flicker.

The conference itself has been interesting and the keynote this morning has given me a clearer understanding of where plone is at the moment and where it is going. I was also pleased to note that I am not alone in having trouble with migrations between version and at least it is a recognised issue and much thought and effort is going into a solution, and that solution involves being able to dump a sites content into an intermediate format that can be used to populate a new site, thus giving me a way to get my content where I can see it, rather than hidden in zodb/zexp voodoo.

plone migration woes

At the moment, my pet plone project DFR skate zine is still live, but because netsight have some devious plans for the server it is on, I am trying to upgrade it to the latest version of plone. The site is current running plone 2.1.1 (tip: if you can’t remember what version of plone your site is running, go into the ZMI and click on portal_migration – you’ll find lots of useful info there, including the plone version).

Initial attempts didn’t go well, but I haven’t given up yet. I’m now trying a different approach – creating a blank plone 2.5 site and trying to bring the content over bit by bit. Some of it imported just fine and other objects are throwing various key and attribute errors.

This blog post by Andreas Jung looks like it could be quite useful – my version jump is nowhere near as big as the version described here, but the technique looks interesting – particularly the script for cloning a tree of objects.

I have some fairly radical plans for the development of the DFR site, I was actually thinking of recreating the skin and content type products from scratch, because a) I want a single skin for public and admin view now and b) because the archetypes content types were patched together in a bit of an ad-hoc way, and now they seem a bit.. well… unclean, and basically I think I can do better now..


so… the masterplan at the moment is to extract the content into some format that I can get to the data easily (as I still find it very confusing trying to get to data “lost” in zodb, when the site is broken), then write a script to populate the new site from the data. Obviously xml fits the bill (along with files and folders for media content).

Marshall and XMLForest have been whispered to me on a need to know basis! If I can crack this i’ll be much more confident about maintaining plone sites long term, in the same way that I am confident with CMS’s that use a SQL database for storage.