Posts tagged 'form'

Checking Plone REQUEST for Ajax’d requests (XMLHttpRequest)

Recently, I’ve needed a PloneFormGen (PFG) form of mine to have certain fields excluded when the form is displayed in one of Plone 4’s fancy popups.  At the same time, I need this field to still persist within the ‘standard’ view of the form.  It’s the request object to the rescue, and all I’ve had to do is insert this TALES expression against the Enabling Expression for my PFG field:

python:request.environ.get('HTTP_X_REQUESTED_WITH') != 'XMLHttpRequest'

and the end result is that unless the request is one of XMLHttpRequest, then we’ll show the field.

Shouldn …

Plone, Dexterity, and Incorrect Widgets

A nice ‘gotcha’ is the distinction between Zope’s schema.Date and schema.Datetime. The difference is obvious and straightforward when the two terms are laid out side-by-side: one is for dates only and the other adds a time component. Where things fell down for me in my usage of these fields with a Dexterity-based content type in Plone is the human component. When these fields are mashed in together within a lot of other text/Python/names, it’s easy to miss those 4 little letters of ‘time’. This lead me trying to use a DatetimeFieldWidget when I really …

PloneFormGen (Plone) & Google Calendar Integration

It’s a little bit of a different mash-up, but it’s still nonetheless useful to have, given types of booking forms and so forth that could utilise it.  The easiest way I found (to avoid security issues with Python scripts in Plone) was to create an external method and just import it within a PFG Custom Adapter.

Parts

  • My GoogleCalendar.py external method.  I’ve had to add this into a policy product I have.  The function should be generalised enough to work with any Google account, hosted or not.  In short:

    • It takes in a variety of arguments …

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 …