Planet Plone

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

August 09, 2012

Mark van Lent: "AttributeError: queryMethodId" when creating an object

by Mark van Lent at 2012-08-09T14:05:28Z

While working on a client project, I created an (Archetypes based) content type with a text field. After adding a custom view as the default view, I got an AttributeError when I tried to add a new object. 

Some details about the content type:

  • It includes a TextField which uses the RichWidget (read: TinyMCE).
  • I changed the default_view setting from folder_listing to view in the Generic Setup configuration file (types/WikiPage.xml in my case).

Whenever I tried to add a new object, I got the following traceback:

  ...
  Module zope.tal.talinterpreter, line 583, in do_setLocal_tal
  Module zope.tales.tales, line 696, in evaluate
   - URL: file:home/mark/eggs/Products.TinyMCE-1.2.11-py2.6.egg/Products/TinyMCE/skins/tinymce/tinymce_wysiwyg_support.pt
   - Line 6, Column 2
   - Expression: <PathExpr standard:u'object|here'>
   - Names:
      {'container': <PloneSite at /site>,
       ...
       'user': <PropertiedUser 'admin'>}
  Module zope.tales.expressions, line 217, in __call__
  Module Products.PageTemplates.Expressions, line 155, in _eval
  Module Products.PageTemplates.Expressions, line 117, in render
  Module Products.CMFDynamicViewFTI.browserdefault, line 76, in __call__
  Module Products.CMFPlone.PloneFolder, line 122, in __call__
AttributeError: queryMethodId

If I removed the text field or set the default view back to folder_listing, the error did not present itself.

To make a long story short: in the end it appears to be an issue with Products.TinyMCE version 1.2.11. And since that version is included in Plone 4.1.5, I spent quite some time figuring out why my new content type didn't work while a similar content type in an older project did. Figuring I had done something wrong, I did not immediately realise that the older project was using Plone 4.1.4 (and thus an older version of Products.TinyMCE that does not have this issue)…

The solution: pin Products.TinyMCE to version 1.2.12. Or you could just use Plone 4.1.6 or 4.2, which both include the fixed version by default.

Connexions Blog: Connexions Android App Gets Updated

by Ed Woodward at 2012-08-09T13:56:59Z

The Connexions for Android app has a couple of new features.

  • Users can now copy content from a chapter in Android 2.3 and below.  The copied content can be pasted into a Note in the app or into another app.  To copy, select the Copy icon from the Actionbar at the bottom of the screen and follow the instructions in the popup message.  The Copy feature works by default in Android 3.0 and above, so the Copy icon is not displayed in the Actionbar for those devices.
  • Notes can now be shared.  Send your notes to yourself or classmates using email, texting or any app that will share plain text.  To share a note, open the Note Editor and select the Share icon from the Actionbar at the bottom of the screen.  A list of available applications to share with will be displayed.  Select an application from the list and the note will be copied to the app.
There are some additional bug fixes in this release as well. The app can be found in the Google Play Store and on the Connexions site.  If you use the app, let us know what you think about the changes at android at cnx.org.

Plone Conference 2012: Talk submissions: deadline ahead

by Plone Conf Organization at 2012-08-09T11:55:00Z

So what is it that gets you to submit a talk? Throw in a bottle of Dutch beer? Hand out an extra Plone goodie? Maybe just the thought that your effort contributes to the success of the conference. As you know, a large portion of the conference consists of presentations about all the wonderful aspects of Plone. If we share what we know, the community as a whole benefits.

As said before, the organization received some solid submissions. scalable deployment, data visualization, Plomino or instant messaging; we have a wide range of talks but still some gaps remain. We like to hear from Pyramid specialists. Also Github experts and marketing gurus are welcome. The broader the range of talks, the better.

Again the deadline is set on August 15th. In the next couple of days submitted talks will be evaluated and put into a schedule. On September 1st the final program will be presented and people who do the talk will get a message.

Are you ready to contribute? Check out the list of talks and send in yours.

August 08, 2012

Netsight Developers: A Brief Bit of History

by Matt Hamilton at 2012-08-08T15:15:23Z

The University of Bristol have recently done a campaign to highlight the success of the University's alumni after they graduated. As part of this they commissioned a number of short videos with a number of alumni. Both myself and about half of the Netsight staff (including the other two directors, Chris and Ben) are alumni of the University of Bristol Computer Science department.

So I thought I'd share with you the video they produced which gives you a little insight into the company and how it started twelve years ago.

Enjoy!

About Netsight from Matt Hamilton on Vimeo.

Hector Velarde: Integrating Travis CI with your Plone add-ons hosted on GitHub

by hvelarde at 2012-08-08T12:50:00Z

I took me a little bit but, with the help of
I took me a little bit but, with the help of Mikko and Martin, I've got a couple of add-ons running tests with Travis CI.

Before setting up Travis CI, you have to make some changes to the Setup Script of your package.

In my case, my add-on package only works for Plone versions 4.1 and later, so I have added Products.CMFPlone as a dependency:

    …
    install_requires=[
        'setuptools',
        'Products.CMFPlone>=4.1',
        ],
    extras_require={
        'test': ['plone.app.testing'],
        },
    …

Products.CMFPlone contains a cut down feature set: just the things I need to run my tests.

Setting up Travis CI is pretty easy: just sign in and activate your GitHub Service Hook

Now, you need to configure your Travis CI build with a .travis.yml file in the root of your repo:

In my case I'm running tests for Plone's latest stable release (4.2 at I write this post) on top of Python 2.7.

Let's take a look at the travis.cfg buildout configuration file:

The main issue I experimented on my first tests was timeouts, so I have a couple of tricks here for you: first, we are extending the standard Plone testing buildout configuration that includes most declarations for us and takes care of always running the latest stable version; we are only going to use the test part. You need to add the package-extras just if your add-on is using plone.app.testing on the test option in extras_require of your package declaration as mentioned above.

zope.globalrequest is needed to run the tests and it was not included on Products.CMFPlone, so we need to declare it in test-eggs (this is already fixed on Plone's branches for versions 4.2 and 4.3, so we could remove this at some point in the near future). You may also need to include Pillow in you package; just uncomment it.

We also need to add a socket-timeout of 3 seconds and a list of allow-hosts to download the dependencies. This is pretty important and will avoid timeouts as Travis CI has hard time limits and timeouts are between 10 and 15 minutes for test suite runs (1).

Last, we have to replace the eggs option on the test part; we need to do this because we don't want to include neither Plone or plone.app.upgrade on the tests.

Finally, you can add a Status Image with a link back to the result of your last build on your README.txt file:

.. image:: https://secure.travis-ci.org/collective/your.package.png
    :target: http://travis-ci.org/collective/your.package

To run the tests you only need to make a push to your GitHub repo. Easy, isn't it?

For a live example of all I mentioned above, take a look at the collective.prettydate package.

Travis CI is really easy to set up and fun to use; I strongly recommend it and, if you like it, please show your love donating.


August 07, 2012

Nathan Van Gheem: A better folder contents implementation

by Nathan Van Gheem at 2012-08-07T15:55:00Z

We've found that many of our clients have trouble with the default drag and drop plone offers. Additionally, it's often asked for a multi-file uploader.

wildcard.foldercontents is the packing of various different features:

  • Better drag and drop based off of jQuery UI sortable
  • uploadify multi-file uploads based off of collective.uploadify
  • automatic folder sorting--idea stolen from collective.sortmyfolder

 

Here's a brief choppy demonstration of how it works:

Alex Clark: pythonpackages.com: Using PyPI’s OAuth1 support to register and upload packages

by aclark4life at 2012-08-07T05:16:54Z

TL;DR PyPI has OAuth1 support; pythonpackages.com uses it to send your GitHub repos to PyPI.

Thanks in very large part to Richard Jones, the Python Package Index now has support for registering and uploading packages via OAuth1. And using his sample code I was able to take advantage of it on pythonpackages.com.

The result is a fairly elegant approach to releasing packages sans dirty hacks (I had been asking users for their username and password, then storing them in an encrypted session cookies so I could send them to PyPI.)

Here’s how it works now.

Sign In With GitHub

GitHub provides an easy way to let folks sign in to pythonpackages.com with their APIv3. I was able to code the OAuth dance using only the requests library (HT Kenneth Reitz). This was working as of late 2011.

Select a package

Once you are signed in, you can select a package. Selected packages can perform various actions, one of which is Tag and Release.

As soon as you select Tag and Release, you are required to authenticate with PyPI.

Enter your PyPI credentials

In order to get the beta out the door, a dirty hack was added to allow users to enter their PyPI credentials. Credentials were saved in an encrypted session cookie, then written out to .pypirc before calling `python setup.py upload`. Really terrible. This was shipped in early July 2012 and is thankfully no longer necessary (though it is still necessary to push the initial commit to GitHub.)

Authorize pythonpackages.com

Now authorization can happen elegantly via OAuth1. First, sign in to PyPI. Then authorize pythonpackages.com to act on your behalf. Lastly, profit (register and upload your package).

Register and upload your package

At this point you are free to tag and release.

 

I am really excited about this. I began fantasizing about it almost a year ago and after several false starts (pypissh, openid, avoidance) it is now a reality. If you have a minute, please give it a try.



August 06, 2012

Lennart Regebro: Looking for projects!

by Lennart Regebro at 2012-08-06T19:18:19Z

It’s that time of year again. It probably has something to do with everyone else being vacation but me. :-)

I have nothing booked from about two weeks from now, so if anyone has a project they need a developer for, and it has anything to do with Python, Zope or Plone, then contact me at regebro@gmail.com.

I can take on small week-long projects, or long projects that last months.


Filed under: plone, python

Plone.org: Plone Conference 2012 Adopts Plone Code of Conduct

by Mark Corum at 2012-08-06T15:50:01Z

The Plone community is open-minded and therefore friendly to everybody. Nevertheless, we applaud the initiative to come up with a code. By having such a document today, we can prevent problems in the future. Without pointing fingers, there are similar communities who had to deal with harassment of members - particularly at events.

So what is it all about? Simple: we do not tolerate harassment or bullying online or offline in any way. Pretty straightforward, isn't it?  We don't care how you look, what you do for fun or where you were born. Being a Plone enthusiast is good enough for us. The code of conduct describes penalties and consequences to offenders but we are convinced we do not have to use them. If you play nice, then we won't pull rank. :)

On this page you will find the complete code of conduct.

Six Feet Up: Making the Six Feet Up Site Responsive

by Chrissy Wainwright at 2012-08-06T10:30:00Z

Six Feet Up's mobile drop-down menuYou can read and see plenty of articles about mobile and responsive development, but this is quite different than actually making an existing production site fully responsive. Here's how I went at it for our own Six Feet Up site, which is powered by the open source CMS Plone.

The idea was to take our existing design and modify it to look good on mobile browsers.  Previously, the site was using a fixed width at 980px wide. The decision of how the site would look on narrow browsers first went to the marketing team. They decided how the elements would rearrange, and which would be dropped, if any. They came up with a wireframe of the narrow design.

I then chose how everything would fall in to place for all the in-between widths. The site continues to be fixed for browsers greater than 980px, but becomes fluid as you get narrower than that. I then set break points at widths when either something broke the layout, or a column became too narrow.

The biggest code changes in the site happened to the main_template. Still being on Plone 3, we were using the tabled version of the site. The table cells were converted to divs, and the divs were arranged to match how they would appear for the narrowest view. The order became content column, right column, left column. Nearly all other site changes were done in CSS, including those for the global navigation.

A common challenge for developers working on a responsive design can be to get it to actually work in a mobile browser. You can do all your testing using Firefox, and get a decent responsive design together, but it will not work in any other browser.  You may need to add a meta tag for viewport:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />

As far as I am concerned, I ran into an unusual problem - the media queries were not working for me when put inline into the CSS. I ended up creating a separate stylesheet for each breakpoint, so the media query is on the style tag that imports each file.

<style type="text/css" media="screen and (max-width: 690px)">@import url(690.css);</style>

Once you know those two tricks, future experiences with responsive design should be much faster.  For me, writing the CSS was the easiest part. One of the most time-consuming parts will likely be getting the client and designer to decide how the site should display at various break points.

Are you working on a responsive design project yourself? Feel free to email me with questions and/or comments.

Dylan Jay: Facets & Taxonomies in Plone

2012-08-06T00:30:42Z

Over time we've had various requests from clients wanting more ways to categorise their content. Plone provides some easy ways in code to add fields to existing content types or create new types. With dexterity you can even add new content types via the control panel. Once you can these additional fields there are some great tools such as eea.facetednavigation to make use of these additional fields to great a nice search interface. Still the situation seemed unsatisfactory. You couldn't just create a site for a user and let them organise Pages, Files etc how they wanted to. Since there seemed to be a gap we went ahead and created collective.facets

Collective.facets is designed to be a simple control panel an administrator can add and remove facets from. Each additional facet you add will add a keyword field to all of  your content types. In addition a keyword index is added to the catalog, a column added to the catalog and a new field is available in your collections criteria. 
There were other ways I considered implementing this such as augmenting the existing keyword widget to allow hierarchical tags. However this way seemed simpler and more likely to be compatible with other plugins. There have been several attempts at similar plugins before such as PortalTaxonomycollective.taxonomysupport and discussions over the years about how Plone Taxonomies and Facets could/should work such as by Jon Stahl, or Martin Aspeli, or me or in tickets. With all these attempts and nothing seeming to be widely used over time, we'd like some feedback if collective.facets is heading in a direction that will be useful to others. We'd prefer this to making something that works just for our clients and collective.facets becoming yet more plone plugin road kill. Your comments welcome.

Permalink | Leave a comment  »

August 04, 2012

Josh Johnson: The Johnson Pyramid Of Programmer Greatness.

by jjmojojjmojo at 2012-08-04T20:46:36Z

I’m a big fan of an NBC sitcom called “Parks and Recreation“.

I’ve had this as my desktop background at home for a few months. It has inspired me to try my hand at using the concept to inspire my fellow developers and engineers.

Explaining how you can be as good as me isn’t easy.  It requires large, complicated charts (and pop culture references). [pause for laughter]

Here it is, the ‘Johnson Pyramid of Programmer Greatness’ (we’ll say it’s about… 80% serious):

Johnson Pyramid of Programmer Greatness

Also available in a laser-printer friendly Black and White:

Johnson Pyramid of Programmer Greatness - BW

The full-sized image is approximately 48 by 36 inches @ 150dpi, but the form factor will scale down to fit on US letter-sized paper. I hope you enjoy it. I, for one, will be plastering it all over my place of employment.


Lennart Regebro: p4a.plonecalendar 2.1b1 released

by Lennart Regebro at 2012-08-04T19:34:52Z

Yes, Plone4ArtistCalendar is alive, and 2.1b1 has just been released! Plone4ArtistCalendar are extensions that give you nice Calendaring support for Plone, with day, week and month views. There are other alternatives, most notable solgema.fullcalendar, but Plone4ArtistCalendar doesn’t use JavaScript, so it is accessible for those who can’t use JS.

Version 2.1b1 has the following major improvements:

  • It now uninstalls cleanly. Again. I fixed that years ago, but I thing p4a.subtyper since “lost” the uninstall. The 1.2.2 release of p4a.subtyper now has a proper uninstall again.
  • It no longer uses p4a.subtyper. You no longer mark folders and collections as being of the Calendar subtype, instead you just choose one of the calendar views from the Display-menu. This is more “Ploneish” and less confusing, and also makes uninstalling easier.
  • It now supports Plone 4.2. That includes supporting the new Collection-type.

Other changes are that there is no longer any official support for Plone 3.0, 3.1 and 3.2. Plone 3.3 is still supported, though, and although I didn’t test it under Plone 4.0 it seems unlikely that it would run under Plone 3.3 and 4.1 but not 4.0. There is also no longer any official support for p4a.ploneevent, and hence no official support for recurrence. No code has been removed, so it should still work, but I’m not aware of anyone using p4a.ploneevent anyone. Recurrence will in the future be done through plone.app.event, but this is not supported yet.

Support for plone.app.event is the only planned future feature, otherwise the plan is to clean up and remove code, and simplify, simplify, simplify.


Filed under: calendaring, plone

August 03, 2012

Dylan Jay: Complex Plone registry settings revisted.

2012-08-03T14:48:13Z

We needed some more complex Registry settings and an associated Control Panel form for a plug-in we are working on for Plone. In a recent article the Red Turtle guys showed us how use complex schemas to auto create forms and store the results in the registry which worked great. Unfortunately the technique, as they point out, defeats one of the goals of the registry to allow the values to be edited with just the normal registry control panel. So we were inspired to develop something to turn complex schemas into something that allowed us to store our registry settings in a human readable way.

For example take schema with a list in it:

    class IFacetDefinition(Interface):
        name = schema.ASCIILine(title=_(u"Facet Name"), required=True)
        description = schema.ASCIILine(title=_(u"Description"), required=False)

    class IFacetSettings (Interface):
        facets = schema.Tuple(
                title=_(u'Additional Facet Fields'),
                description=(u"Names of additional keyword fields"),
                value_type=schema.Object(IFacetDefinition, title=_(u"Facet Definition")),
                required=False,
                default=(),
                missing_value=()
         )

We won't use the registry.xml generic setup profile step to register this schema as it will complain.

Instead we created a new registry proxy that deals with setting and getting attributes of schemas which are lists.

        reg = getUtility(IRegistry)
        proxy = ComplexRecordsProxy(reg, IFacetSettings, prefix='collective.facets')

You can now use "proxy.facets" as you would any list. e.g.

        print [f.name for f in proxy.facets]
        del proxy.facets[5]

The results would be stored in the registry like this

collective facets facets/i00000 descriptionDescriptionASCIILineblah
collective facets facets/i00000 nameFacet NameASCIILineblah
collective facets facets/i00001 descriptionDescriptionASCIILineA long description
collective facets facets/i00001 nameFacet NameASCIILineMy Facet
Yes this schema won't work for 100000 items but I'm not sure you should be using the registry for a list that long anyway :)

The proxy makes it easy to create a control panel form for our settings schema

   class FacetSettingsEditForm (controlpanel.RegistryEditForm):
        schema = IFacetSettings
        label = u"Facets Settings"
        description = u"Manage your additional facets"

        def getContent(self):
            reg = getUtility(IRegistry)
            return ComplexRecordsProxy(reg, IFacetSettings, prefix='collective.facets')

        def applyChanges(self, data):
            reg = getUtility(IRegistry)
            proxy = ComplexRecordsProxy(reg, IFacetSettings, prefix='collective.facets')
            proxy.facets = data['facets']
            ...

Neat. Nice control panel, nicely stored.

Picture_44

Permalink | Leave a comment  »

Mikko Ohtamaa: Adding custom shortcut links to TinyMCE dialogs in Plone

by Mikko Ohtamaa at 2012-08-03T09:33:51Z

Plone's Products.TinyMCE versions 1.3beta+ provide custom shortcut links in Add link and Add images dialogs. You can add your site specific shortcuts there yourself.

The most common use case is a shortcut link into a folder which acts as a site image bank. On multilingual sites this folder is

  • Below natural language folders in the site root (e.g.  /image-bank when you have /fi and /en)
  • Language neutral – images are shared across the languages

Because of the special language neutral nature, navigating to the image bank folder using normal Plone navigation is difficult.

For adding images use case we can fix this by including a shortcut which directly takes you to the image bank from main Add image screen.

Below is an example of Finnish shortcut “Kuvapankki” which is a custom addition besides Home and Current Folder.

../_images/tinymce_images.png

New TinyMCE shortcuts can be registered as global utility via Products.TinyMCE.interfaces.IShortcut interface.

We’ll register our image bank as a shortcut into TinyMCE image dialog.

First make sure your add-on is grok’ed.

Then drop in the following file shortcut.py file into your add-on:

from five import grok
from Products.TinyMCE.interfaces.shortcut import ITinyMCEShortcut
class ImageBankShortcut(grok.GlobalUtility):
    """Provides shortcut to the language neutral image bank below language folders """
    grok.name("imagebank")
    grok.provides(ITinyMCEShortcut)
    # This time we don't bother with i18n and assume
    # the whole world understands Finnish
    title = u'Kuvapankki'
    # Portal root relative path
    link = "/kuvapankki"
    def render(self, context):
        # http://collective-docs.readthedocs.org/en/latest/misc/context.html
        portal_state = context.restrictedTraverse('@@plone_portal_state')
        return ["""
        <img src="img/folder_current.png" />
        <a id="currentfolder" href="%s">%s</a>
        """ % (portal_state.portal_url() + self.link, self.title)]

After this you still need to go to TinyMCE control panel (http://localhost:8080/Plone/@@tinymce-controlpanel) and enable the link button in the settings for Image Shortcuts.

Note: You might also want to disable TinyMCE inline image uploads through CSS and disable image creation in arbitraty folders on your site.

If you have anything to contribute for this article do it in collective.developermanual WYSIWYG page.

 Subscribe to this blog in a reader Follow me on Twitter