Planet Plone

This is where developers and integrators write about Plone, and is your best source for news and developments from the community.

September 02, 2014

Blue Dynamics: Custom Object Source Binder for z3c.forms

by Peter Holzer at 2014-09-02T13:30:00Z

Within a folderish dexterity content type i had to select objects for a relation field from just that context. Therefore i wrote a small Custom Source Binder.

from plone.formwidget.contenttree.source import ObjPathSource
from plone.formwidget.contenttree.source import ObjPathSourceBinder
class SubTreeObjPathSource(ObjPathSource):
    def __init__(self, context, selectable_filter,
                 navigation_tree_query=None):
        super(SubTreeObjPathSource, self).__init__(
                context, selectable_filter,
                navigation_tree_query=navigation_tree_query)
        del self.navigation_tree_query['portal_type']
        self.navigation_tree_query['path']['query'] = \
                '/'.join(context.getPhysicalPath())
class SubTreeObjPathSourceBinder(ObjPathSourceBinder):
    path_source = SubTreeObjPathSource

 

And the updated field definition: 

    contact_person = RelationList(
        title = _(u"Contact Person"),
        value_type = RelationChoice(
            source = SubTreeObjPathSourceBinder()
        )
    )

Plone.org: Plone News for August

2014-09-02T13:12:32Z

Summary of Plone News from around the world for the month of July.

August 28, 2014

Martijn Faassen: Morepath 0.5(.1) and friends released!

2014-08-28T15:32:54Z

I've just released a whole slew things of things, the most important is Morepath 0.5, your friendly neighborhood Python web framework with superpowers!

What's new?

There are a a bunch of new things in the documentation, in particular:

Also available is @reg.classgeneric. This depends on a new feature in the Reg library.

There are a few bug fixes as well.

For more details, see the full changelog.

Morepath mailing list

I've documented how to get in touch with the Morepath community. In particular, there's a new Morepath mailing list!

Please do get in touch!

Other releases

I've also released:

  • Reg 0.8. This is the generic function library behind some of Morepath's flexibility and power.
  • BowerStatic 0.3. This is a WSGI framework for including static resources in HTML pages automatically, using components installed with Bower.
  • more.static 0.2. This is a little library integrating BowerStatic with Morepath.

Morepath videos!

You may have noticed I linked to Morepath 0.5.1 before, not Morepath 0.5. This is because I had to as I was using a new youtube extension that gave me a bit too much on readthedocs. I replaced that with raw HTML, which works better. The Morepath docs now include two videos.

  • On the homepage is my talk about Morepath at EuroPython 2014 in July. It's a relatively short talk, and gives a good idea on what makes Morepath different.
  • If you're interested in the genesis and history behind Morepath, and general ideas on what it means to be a creative developer, you can find another, longer, video on the Morepath history page. This was taken last year at PyCon DE, where I had the privilege to be invited to give a keynote speech.

August 27, 2014

eGenix: eGenix PyRun - One file Python Runtime 2.0.1 GA

2014-08-27T07:00:00Z

Introduction

eGenix PyRun is our open source, one file, no installation version of Python, making the distribution of a Python interpreter to run based scripts and applications to Unix based systems as simple as copying a single file.

eGenix PyRun's executable only needs 11MB for Python 2 and 13MB for Python 3, but still supports most Python application and scripts - and it can be compressed to just 3-4MB using upx, if needed.

Compared to a regular Python installation of typically 100MB on disk, eGenix PyRun is ideal for applications and scripts that need to be distributed to several target machines, client installations or customers.

It makes "installing" Python on a Unix based system as simple as copying a single file.

eGenix has been using the product internally in the mxODBC Connect Server since 2008 with great success and decided to make it available as a stand-alone open-source product.

We provide both the source archive to build your own eGenix PyRun, as well as pre-compiled binaries for Linux, FreeBSD and Mac OS X, as 32- and 64-bit versions. The binaries can be downloaded manually, or you can let our automatic install script install-pyrun take care of the installation: ./install-pyrun dir and you're done.

Please see the product page for more details:

    >>> eGenix PyRun - One file Python Runtime

News

This is a patch level release of eGenix PyRun 2.0. The major new feature in 2.0 is the added Python 3.4 support.

New Features

  • Upgraded eGenix PyRun to work with and use Python 2.7.8 per default.

Enhancements / Changes

  • Fixed a bug in the license printer to show the correct license URL.

install-pyrun Quick Install Enhancements

eGenix PyRun includes a shell script called install-pyrun, which greatly simplifies installation of PyRun. It works much like the virtualenv shell script used for creating new virtual environments (except that there's nothing virtual about PyRun environments).

With the script, an eGenix PyRun installation is as simple as running:

./install-pyrun targetdir

This will automatically detect the platform, download and install the right pyrun version into targetdir.

We have updated this script since the last release:

  • Updated install-pyrun to default to eGenix PyRun 2.0.1 and its feature set.

For a complete list of changes, please see the eGenix PyRun Changelog.

Please see the eGenix PyRun 2.0.0 announcement for more details about eGenix PyRun 2.0.

Downloads

Please visit the eGenix PyRun product page for downloads, instructions on installation and documentation of the product.

More Information

For more information on eGenix PyRun, licensing and download instructions, please write to sales@egenix.com.

Enjoy !

Marc-Andre Lemburg, eGenix.com

August 26, 2014

UW Oshkosh How-To's: How to add or change your site's portal tabs

by nguyen at 2014-08-26T20:39:33Z

You can add, change, or remove portal tabs from your standard UW Oshkosh site, if you have Manager role (ie. are a member of the Administrators group).

  • Log into your site
  • Go to Site Setup
  • Go to the Zope Management Interface
  • Click on "portal_actions"
  • Click on "portal_tabs"

You will see:

portal_tabs_01.png

You add a new tab by checking the box to one of the existing tabs (e.g. "tab4"), then clicking on the Copy button, then on the Paste button, then you'd get this:

portal_tabs_02.png

Edit the new tab by clicking on it, to see:

portal_tabs_03.png

Change the Title value and the URL (Expression) value, then press the Save Changes button at the bottom.

For the URL value, just edit the last part of the value, e.g. if it says:

    string:${globals_view/navigationRootUrl}/contact-information

change the "contact-information" part to whatever you need, e.g. if I wanted the tab to go to a page with the ID "buy-me" I would change the value of the above to

    string:${globals_view/navigationRootUrl}/buy-me

To navigate back to the portal tabs, click here:

portal_tabs_04.png

There you can also change the ID of a tab by checking the box next to it then clicking the Rename button:

portal_tabs_05.png

 

 

Six Feet Up: "Mastering Plone" Documentation - A Great Online Resource

by Chrissy Wainwright at 2014-08-26T11:00:00Z

MasteringPlone.pngRecently, Philip Bauer and Patrick Gerken of starzel.de took the outline from their Mastering Plone training and put it online as a training resource.

The great thing about this is that instead of documentation that lists what is available to use, this training walks you through the process of creating a Plone site and setting up custom content.

I am primarily a front-end developer, but have recently been learning python and how to do more back-end development with Plone.  I went through the bits of this Plone Training that I didn’t already know how to do, and found it to be a great resource.  I have already gone back to it a few times to use as a reference.

I did find some small mistakes and typos while working through the training, but fortunately, the code for the training is on Github in the Plone repo. I was able to commit the fixes and see the training updated right away. Anyone that is a Plone Core Contributor can make changes like this.  Philip and Patrick do request that any larger changes be made as a pull-request.

Our new developer, Rob, has also been going through the training, and he was not already familiar with Plone. Since the training is currently more of an outline, it’s not perfect.  But this has allowed Rob to learn even more while working through the parts that didn’t work as expected.

Check out the training at http://plone-training.readthedocs.org

August 22, 2014

Connexions Developers Blog: Tech Behind Search Improvements

by Ed Woodward at 2014-08-22T14:10:51Z

Over the summer, we have made several improvements to the new version of the site (Rewrite),. One of the biggest improvements was with search. Since we released Rewrite, the performance of search has been a concern.  We did little to improve the speed before the release because of time constraints. It was decided that we needed to revisit it this summer to get things in great shape for the Fall semester.

We implemented the following changes:
  • Cache single word and subject searches - we added Memcached to store some searches.  A cron job is reloading the subject searches into the cache on a regular basis.
  • Pagination on Search Result page - previously we were displaying all of the search results on the same page. This caused a long page render time which made the slow search even slower. We are now displaying 10 items on each page. Books are displayed first since most users are looking for books. When possible, we use the cached search results to return the next page.
  • Improved SQL performance - we tweaked the SQL used for the queries to optimize them.
All of these changes are no-brainers, but have vastly improved search.

Netsight Developers: Netsight is Recruiting: SysAdmin

2014-08-22T09:17:17Z

Netsight are looking for a new full-time Systems Administrator.

Based in the UK, we are one of Bristol's longest running web design and development firms. This is a great opportunity for the right candidate to build a successful career in web software systems administration, and work with a great local company. Find out more about us here.

We are looking for someone with a keen interest in technology, who enjoys spending their time working with computers and operating systems and has no fear of the command line. You'll enjoy solving problems and need to be happy to look things up. You're likely to be working in small teams, so you'll need to be also need to be happy asking colleagues for help when you need it or want to bounce ideas off someone.

You’ll need a good working knowledge of Unix variants and an instinctual awareness of system security considerations (i.e. the ability to understand how an attacker would compromise a system and implement countermeasures), but at the same time balance this with the developers’ and customers’ needs.

On a day-to-day basis you’ll be working alongside our experienced sysadmin, reporting to senior management and the company directors.

We are a pretty relaxed company and have an informal, open-plan office, with a variety of ways to get away from the machines. That said, we need people who can manage their time effectively and take responsibility for the work they are doing.

 

Required Skills:

Basic pre-requisites:

  • At least 2 years systems administration experience in a commercial web development environment.
  • Good communication skills – this role will become client facing to at least some degree, as you clarify requirements and report progress to members of the clients' organisations. You will also need the ability to work well in small, closely-knit teams (typically of 2 to 4 people) and effectively argue your case when needed.
  • Ability to remain calm when under pressure (i.e. when things break).
  • Based in Bristol with easy transport into the centre. In due course this role may require occasional out-of-hours work.


 General Unix experience - GNU/Linux/FreeBSD/OpenBSD/Solaris etc.:

  • Comfortable with command line only!

  • Remote admin via SSH

  • Mindful of system security (permissions, file system ACLs, passwords, restricted user accounts etc)

  • Shell scripting

  • Must like emacs and dislike vi… j/k ;)

GNU/Linux (preferably apt-based such as Debian/Ubuntu):

  • Installing OS and software, setting up, administering user accounts etc

Windows:

  • Able to undertake basic network/security maintenance tasks, as and when required

Apache web server:

  • Creating new virtual hosts

  • RewriteRules

  • Setting up a reverse proxy

  • Optional knowledge of optimising Apache for large workloads

Mail server:

  • Experience with SMTP daemons (e.g, Exim)

  • Cyrus Imap daemon

  • SASL auth

  • Spam assassin

  • Mail filtering (e.g. Sieve filters)

Experience with high-uptime server hardware:

  • Knowledge of RAID levels and best application of different RAID set ups.

  • Diagnosing hardware faults

  • IPMI

  • Building and maintaining PCs and servers: Installing memory, CPUs (applying thermal paste, heatsinks etc)

Networking:

  • DNS - administering DNS records (A, CNAME, MX, TXT etc)

  • IP Subnets

  • Switch management (HP/Cisco)

  • Experience of routing protocols (eg. BGP, OSPF, etc)

  • WiFi

  • OpenVPN

Programming experience:

  • Shell scripting

  • Python scripts


Desirable additional skills/experience:

Experience with the following is desirable but not essential. These technologies form a significant part of our infrastructure, so a willingness (and ability) to learn them is important:

  • Ansible

  • Asterisk

  • Bareos/Bacula

  • Ceph

  • Ejabberd

  • Exim

  • Ganeti

  • HAProxy

  • MySQL/MariaDB/PostgreSQL

  • Nagios

  • Nginx

  • Python

  • Plone

  • RADIUS

  • Varnish

  • Zope


Bonus Points:

  • 8/16 bit computer games / arcade cabinets:-  maintenance and operation

  • Good working knowledge of scalextric:-  performance optimisation

  • Eating burgers and pizza:-  willingness to accept the Netsight Sysadmin Challenge*

(* Details will be included in successful applicant’s induction pack)

 

What's in it for you?

  • Starting salary in the region of £20-30K (depending on experience).
  • Laptop and mobile phone.
  • Conference attendance allowance.
  • A relaxed working environment.
  • Share options as you progress (and associated dividends).

Please send your CV to careers@netsight.co.uk

Sorry, no agents

It's nothing personal. If we need you, we'll call.

August 21, 2014

Plone.org: Announcing the Plone Conference 2015 selection process

2014-08-21T20:35:00Z

With Plone Conference 2014 drawing near, it is time to begin planning for our next conference in 2015.

eGenix: PyDDF Python Sprint 2014

2014-08-21T10:00:00Z

The following text is in German, since we're announcing a Python sprint in Düsseldorf, Germany.

Ankündigung

Der erste PyDDF Python Sprint 2014 in Düsseldorf:

Samstag, 27.09.2014, 10:00-18:00 Uhr
Sonntag, 28.09.2014, 10:00-18:00 Uhr
Seminarraum 25.41.00.45
(Gebäude 25.41, Erdgeschoss, Raum 45) des
ZIM der HHU Düsseldorf

Informationen

Das Python Meeting Düsseldorf (PyDDF) veranstaltet zusammen mit dem ZIM der Heinrich-Heine-Universität Düsseldorf ein Python Sprint Wochenende im September.

Der Sprint findet am Wochenende 27/28.09.2013 im Seminarraum 25.41.00.45 (Gebäude 25.41, Erdgeschoss, Raum 45) des ZIM der HHU Düsseldorf stattfinden:
Folgende Themengebiete haben wir als Anregung angedacht:
  • Openpyxl
Openpyxl ist eine Python Bibliothek, mit der man Excel 2010 XLSX/XLSM Dateien lesen und schreiben kann.

Charlie ist Co-Maintainer des Pakets und würde gerne an folgenden Themen arbeiten:

- ElementTree Implementation des lxml.etree.xmlfile Moduls (context manager)
- Co-Routines für die Serialisierung
- Python Code-Object-Generierung anhand des Schemas
  • HTTP Audio Streaming für Mopidy
Mopidy ist ein MPD Musikserver, der viele Internet-Streaming-Dienste abonnieren kann, diese jedoch nur über lokale Audiogeräte ausgibt.

Es wäre schön, wenn man auch Internetradios anschließen könnte, wie z.B. die Squeezebox. Es gibt dazu schon ein Ticket, auf dem man vermutlich aufbauen könnte:

- https://github.com/mopidy/mopidy/issues/56

Ziel wäre es, eine Mopidy Extension zu schreiben, die dieses Feature umsetzt.
Natürlich kann jeder Teilnehmer weitere Themen vorschlagen, z.B.
  • Kivy (Python auf Android/iOS)
  • RaspberryPi (wir werden ein paar davon mitbringen)
  • FritzConnection (Python API für die Fritzbox)
  • OpenCV (Bilder von Webcams mit Python verarbeiten)
  • u.a.
Alles weitere und die Anmeldung findet Ihr auf der Sprint Seite:
Teilnehmer sollten sich zudem auf der PyDDF Liste anmelden, da wir uns dort koordinieren:
Wir haben nur begrenzten Platz im Seminarraum, daher wäre es gut, wenn wir die ungefähre Anzahl Teilnehmer schon in Vorfeld einplanen könnten. Platz ist für max. 30 Teilnehmer.

Über das Python Meeting Düsseldorf

Das Python Meeting Düsseldorf ist eine regelmäßige Veranstaltung in Düsseldorf, die sich an Python Begeisterte aus der Region wendet.

Einen guten Überblick über die Vorträge bietet unser PyDDF YouTube-Kanal, auf dem wir Videos der Vorträge nach den Meetings veröffentlichen.

Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld, in Zusammenarbeit mit Clark Consulting & Research, Düsseldorf.

Viel Spaß !

Marc-Andre Lemburg, eGenix.com

Published: 2013-03-20
<noscript> <div style="border-top: 1px solid; text-align: center;">Please enable JavaScript to make full use of our web-site. Thank you.</div> </noscript>

August 20, 2014

UW Oshkosh How-To's: How to allow downloading of PloneFormGen saved data

by nguyen at 2014-08-20T22:24:26Z

PloneFormGen 1.6.7 and up provides a control panel in Site Setup that lets you control who can download saved data.  By default, Manager, Owner, and Site Administrator are allowed to download saved data but you can check boxes for other roles, such as Editor, Reader, Member.

The following method completely bypasses those permission checks.

In the form folder go to the ZMI (append /manage_main to the PFG form's URL) then add a Script (Python).  Call it download_tsv and in the body put:

request = container.REQUEST
RESPONSE =  request.RESPONSE
data = context['saved-data']
return data.download_tsv(request, RESPONSE)
 

Then provide the user with the URL of that script, e.g. 

http://www.yoursite.edu/division/request-form/download_tsv

That link will still require that the person log in, but if you granted "can read" to that person (or to a group that the person is a member of) via the form's Sharing tab, they will be able to get the tab-separated-values file directly from their browser, which they can either save locally or open with an application.

August 19, 2014

UW Oshkosh How-To's: How to clone a PloneFormGen form onto another site

by nguyen at 2014-08-19T19:24:26Z

There is a not-so-well known feature of PloneFormGen that lets you clone a form easily onto another site. (Cloning a form within the same site is easy via the Actions -> Copy and Actions -> Paste menu items).

The Actions menu contains an "Export" item that creates a .tgz file representing the contents (fields, adapters, etc.) of a form.  

  1. Use the Actions -> Export menu item to create a .tgz file downloaded to your local disk.
  2. On the site where you want to clone this form, create a new form (Add New -> Form Folder)
  3. In the new form, use the Actions -> Import menu item.  
  4. Browse to the .tgz file you created in Step 1, and check the "Remove existing form items?" box to replace everything in the current form with what's in the .tgz file.
  5. Press the Import button.
  6. Review the resulting form; it should be identical to the original form.  You may have to edit date/time fields and uncheck/check the box to show the time fields. 

screen shot of PloneFormGen export-import feature

Note to self: update the PloneFormGen docs with this! at http://docs.plone.org/working-with-content/managing-content/ploneformgen/index.html

UW Oshkosh How-To's: How to add a simple "captcha" to your /contact-info form

by nguyen at 2014-08-19T18:17:04Z

Overview

You can make a simple customization to your site's contact-info form.

The one on this Plone Projects site at http://www.uwosh.edu/ploneprojects/contact-info was suddenly inundated with spam submissions.

I customized the form to add a simple math question with a required answer, and I customized the form validation script to check that the correct answer was provided.

The following instructions are known to work specifically with Plone 3.1.4 and 4.2.  If you try these instructions and they work with other versions of Plone and PloneFormGen please let us know.

Customize the Contact Form

Go to portal_skins and use the Find tab to locate the form with ID "contact-info".  Customize it. 

Near the end of the form, above the form controls div:

<div class="formControls">

add this HTML:

        <div class="field"
          tal:define="error errors/quiz|nothing"
          tal:attributes="class python:test(error, 'field error', 'field')">
          <label for="quiz" i18n:translate="label_quiz">
            Quiz Question
          </label>
          <span class="fieldRequired" title="Required"
                  i18n:attributes="title title_required;"
                  i18n:translate="label_required">(Required)</span>
          <div class="formHelp" i18n:translate="help_quiz">
            Please prove you are human.  What is 3+2?
          </div>
          <div tal:content="error">Validation error output</div>
          <input type="text"
                 id="quiz"
                 name="quiz"
                 size="1"
                 value=""
                 tal:attributes="value request/quiz|nothing"
                 />
        </div>

and press Save Changes.

This adds a string field of length 1, with the ID "quiz". The help text asks the user to answer the question 3+2.

Customize the Validation Script

Next go to portal_skins and use the Find tab to search for the script with ID "validate_site_feedback", and customize it.

Add "quiz" to the parameter list, so it should read:

subject,message,sender_from_address,quiz

Near the end of the script, above the line:

if state.getErrors():

add the following code:

if not (quiz and quiz.strip()):
    state.setError('quiz', _(u'Please answer the question'), 'quiz_required')
else:
    if (quiz.strip().find('5') != 0):
        state.setError('quiz', _(u'Please answer the question correctly - enter a single digit'), 'quiz_required')

and press Save Changes.

How to Change the Quiz Question

To change the quiz question, you'll need to:

  • change the help text, where it says
    What is 3+2?
  • if the length of the answer is not a single character, change the length where it says
    size="1"
  • change the validation script where it looks for the correct answer,
    quiz.strip().find('5')
    and replace
    5
    with the correct answer
  • change the validation script error message if the length of the answer is not a single character, where it says 
    enter a single digit

 
 
 

 

Plone.org: Plone News for July

2014-08-19T18:10:52Z

Summary of Plone News from around the world for the month of July.

Martijn Faassen: New HTTP 1.1 RFCs versus WSGI

2014-08-19T12:35:00Z

Recently new HTTP 1.1 RFCs were published that obsolete the old HTTP 1.1 RFCs. They are extensively rewritten.

Unfortunately the WSGI PEP 3333 refers to something only made explicit in the old version of the RFCs, but which is much harder to find in the new versions of the RFCs. I thought I'd leave a report of my investigations here so that others who may run into this in the future can find it.

WSGI is a protocol that's like HTTP but isn't quite HTTP. In particular WSGI defines its own iterator-based way to send larger responses out in smaller parts. It therefore cannot deal with so-called "hop-by-hop" headers, which try to control this behavior on a HTTP level. The WSGI spec says a WSGI application must not generate such headers.

This is relevant when you're dealing with a WSGI-over-HTTP proxy. This is a special WSGI application that talks to an underlying HTTP server. It presents itself as a normal WSGI application.

The underlying HTTP server could very well be sending out stuff like such as Transfer-Encoding: chunked. The WSGI spec does not allow a WSGI application to send them out though, so a WSGI proxy must strip these headers out.

So what headers are to be stripped out? The WSGI spec refers to section 13.5.1 in now-obsolete RFC 2616.

This nicely lists hop-by-hop headers:

  • Connection
  • Keep-Alive
  • Proxy-Authenticate
  • Proxy-Authorization
  • TE
  • Trailers
  • Transfer-Encoding
  • Upgrade

That RFC also says:

"All other headers defined by HTTP/1.1 are end-to-end headers."

and then confusingly:

"Other hop-by-hop headers MUST be listed in a Connection header, (section 14.10) to be introduced into HTTP/1.1 (or later)."

which one is it, HTTP 1.1? I guess that's one of the reasons this text got rewritten.

In the new rewritten version of HTTP 1.1, this list is gone. Instead it specifies for some headers (such as TE and Upgrade) that these should be added to the Connection field. A HTTP proxy can then strip out the headers listed in Connection, and then also strip out Connection itself.

Confusingly, while the new RFC 7230 refers to the concept of 'hop-by-hop' early on, and also say this in the change notes in A.2:

"Also, "hop-by-hop" header fields are required to appear in the Connection header field; just because they're defined as hop- by-hop in this specification doesn't exempt them."

it doesn't actually say any headers are hop-by-hop anywhere else. Instead it mandates some headers should be added to Connection.

But wait: Transfer-Encoding is not to be listed in the Connection header, as it's not hop-by-hop. At least, not anymore. I've seen it described as 'hopX-by-hopY', but not in the RFC. This is, I think, because a HTTP proxy could let these through without having to remove them. But not for a WSGI over HTTP proxy: it MUST remove Transfer-Encoding, as WSGI applications have no such concept.

I think the WSGI PEP should be updated in terms of the new HTTP RFC. It should make explicit that some headers such as Transfer-Encoding must not be specified by a WSGI app, and that no headers that must be listed in Connection can be specified by a WSGI app, or something like that.

Relevant mailing list thread:

http://lists.w3.org/Archives/Public/ietf-http-wg/2014JulSep/thread.html#msg1710