Site Scene

Posts Tagged ‘script’

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 (email, password, calendar_url, start_time, end_time, title, location, content).
      • Email/password are your auth details
      • calendar_url is where you’re putting the event,
      • and the rest of the args are related to the event itself.
    • It builds the XML-based request to create the event.  I tried going for the gdata API, but it’s just over the top for a simple exercise like this.
    • Send the request to Google (twice, as required), and create the event in the process.
  • A custom PFG script adapter like this:
    from DateTime import DateTime
    from my.theme.Extensions.GoogleCalendar import createGoogleCalendarEvent
    calendar_url = 'http://www.google.com/...'
    email = 'myu...@google.com'
    password = 'shhhhhsecret'
    startDateTime = (DateTime(str(fields['start-date-time']))).HTML4()
    endDateTime = (DateTime(str(fields['end-date-time']))).HTML4()
    eventTitle = str(fields['purpose'])
    eventLocation = str(fields['rooms-to-book'])
    eventContent = 'Booked for:  '+ str(fields['booking-name'])
    createGoogleCalendarEvent(context, email, password, calendar_url, startDateTime, endDateTime, eventTitle, eventLocation, eventContent)
    

And that should be that.  As long as all your URLs, emails, passwords, and fields in your form are suitable, this should work a treat.  Note that the start-date-time and end-date-time fields are date/time fields in your Form Folder and converting to HTML4() makes them into Google’s format.  Additional info can be added in the eventContent variable, and that’ll turn up in the Description in Google Calendar.

For added spice…

Just add a web interface to your Google Calendar to your Plone site (eg in a normal Plone page; watch out for iframe filtering) and let people book themselves into things.  Would be great to see PFG know when a Google Calendar event was on (and stop people submitting) but it’s a bit much just for now.

Buildout: Trying to create a Plone/Zope instance

Eeek…what’s this mean?

install() got an unexpected keyword argument 'allow_hosts'

after trying to build zope2zeoserver from my buildout configuration. (more…)

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. (more…)