Posts tagged 'plone' – Page 6

Plone: URL Encoding In A Script

So, for today’s problem, how can we get a URL (specifically the GET request arguments) suitably encoded? Easy, if we’re talking about a Python script that lives on the file system and can be used within Zope/Plone that way. But what about some sort of Python script that has to exist on the Plone site (specifically, creating a PloneFormGen (PFG) Custom Adapter)?

First thing I jumped to is urllib and urlecode: but no luck because you’re unauthorised to import the library in your script. Boo!

After much poking, and Googling for something that I thought should …

Plone: Correcting Page Template Errors Easily

Here’s how to correct pesky problems in your code/XHTML since the line number and column references are slightly useless in the ZMI.

Paste contents from a page or page template from the ZMI into a program like gedit and then the line and column reference numbers will be correct (once you remove the comment about the error from the top of the page).

Editing in the ZMI is a bit painful, but we persevere.

Plone: Varnish Configuration (Cache Hits, Purge Fails)

What a painful, painful day. It’s taken about the entire day, but I’ve finally figured out why our Varnish configuration around here for Plone/Zope hasn’t been accepting PURGE requests. Thus, without accepting purge requests correctly, any content that gets changed in Plone doesn’t get updated in the cache until it times out (or we restart it). Ouch - especially because it affects all sites under virtual hosting, and a lot of these sites have publicly visible content that needs to be available immediately.

So, the problem manifested itself as thus:

  • Cache hits happen
  • Performance was good …

Plone: Re-ordering Folder Contents

Ahhh, a new work week.

The first perplexing puzzle for the week was a seemingly silly idea (it still is) in Plone where it allows you to view the contents of a given folder in batches of 20. Now, combine this concept (which is good) with a concept of being able to re-order items within the folder (which is good too), you end up with not being able to move items between ‘batches’.

Troublesome. There’s nothing obvious that you can do aside from disabling your browser’s JavaScript and using the manual buttons. Nope: not feasible.

Try making your …

Plone How-To: XHTML Compliant Flash Insertion

Wow, it seems easy doesn’t it. Just add an object tag, params, and embed and we’re done, right? Well, sure, if we didn’t want to adhere to W3C standards.

To do the right thing, we need something like this:

<object type="application/x-shockwave-flash" data="movie.swf" width="100" height="100">
    <param name="movie" value="movie.swf" />
    <img src="alt.jpg" width="100" height="100" alt="" />
</object>

Not much to it there, and this is available everywhere on the web. It validates okay, and that’s what we need.

However, if you follow normal procedure for sticking this …

Plone: PloneFormGen Customisations

Another fun problem for me to address today: upgrading to the latest version of Plone (3.1.7 at time of writing) caused my custom PloneFormGen (otherwise known as PFG) view to break in a nasty way:

Module None, line 13, in fgvalidate_base
- <fscontrollervalidator at /site/fgvalidate_base used for /site/registration-form>
- Line 13
Module Products.PloneFormGen.content.form, line 519, in fgvalidate
Module plone.protect.authenticator, line 60, in check
Forbidden: Form authenticator is invalid.

Obviously there’s some new validation code for forms in Plone 3.1+. Thanks to a very simple (and useful!) blog entry: http://www.die-welt …

Plone: Buildout Won’t Install Products.OpenXml

UPDATE: Installation of Products.OpenXml appears to work happily with buildout when I’m using z3c.recipe.staticlxml to build lxml separately from having to easy_install or install system-wide packages.

So it’s almost Christmas time and I’m still slaving away working. It’s all about commitment.

Today in my life I’ve been trying to install the OpenXml product for Plone (using buildout, of course):

david@computer:~/buildout/instance$ ./bin/buildout
Uninstalling zopepy.
Uninstalling instance.
Updating plone.
Updating zope2.
Updating productdistros.
Installing instance.
Getting distribution for 'Products.OpenXml'.
Got Products.OpenXml 1.0.1.
Getting distribution for 'openxmllib' …

Plone: Archetypes With Paster

From http://www.koansys.com/tech/create-plone-3-archetype-product-with-zopeskel-and-buildout:

ZopeSkel can create Archetype-based products for Plone 3. Wire it up in Buildout.

After creating a Plone 3 instance (e.g., with Unified Installer) go into the src/ directory and create a development product with ZopeSkel:

> paster create -t archetype
Enter title (The title of the project) ['Plone Example']: Koansys Newproduct
Enter namespace_package (Namespace package (like plone)) ['plone']: koansys
Enter package (The package contained namespace package (like example)) ['example']: newproduct
Enter zope2product (Are you creating a Zope 2 Product?) [False]: True
Enter version (Version) ['0.1']:
Enter description (One-line description of the package …

Plone: Ploneboard Conversation Editing

I’m back with even more Plone goodness. Turns out Ploneboard has a problem/issue (well, HAD an issue until I went and edited the code on the SVN repository for the Collective of Plone. Read: will not have in the next major release) with redirecting the user after they go and edit a post. So essentially the user ends up getting to a page that says ‘Insufficient privileges’, which is was extremely odd considering I do everything as an admin.

The fix goes a little something like this:

In ploneboard_scripts/comment_redirect_to_conversation change it to be:

# XXX if we ever …

Plone: Page Template Redirects

Was wondering how to get a Plone page template to go to a page before the template actually loads. Now, actually getting Plone to not go to this template would be FAR better, but since we can’t actually modify the functionality of the Favourites content items in the content listings (not easily), I instead modify it’s default view.

Using this:

<head>
    <metal:js fill-slot="javascript_head_slot">
        <script type="text/javascript"
        tal:content="python:'location.href=\''+portal.absolute_url()+'/'+here.remoteUrl+'\';;'">
        </script>
    </metal:js>
</head>

We see that the page reloads to the relevant location as soon as the head JavaScript …