ParTecs Weblog

ParTecs Plone Widgets go sourceforge

January 13th, 2007

I am happy to announce that our major GPL Plone Widgets will be now maintained and released on SourceForge.net.

We thank everybody helping on these projects. Our other widgets are still available from our website and if interest grows we’ll be happy to maintain another sf.net project page.

We invite all developers willing to help making PloneSkype, PloneInvite and PloneCaptcha really useful products for the community to join efforts. So, if you have the will, don’t hesitate in joining the mailing lists linked above and start getting your hands dirty with python.

Multifile Widget

April 10th, 2006

Ever wanted to allow users to upload more than one file as an attachment to a document, akin to Gmail’s web interface?
The new Multifile Widget will allow you to do that. The picture below should illustrate how the widget works.
Multifile screenshot

The Add file and Remove funtions use AJAX. This makes the widget appear very snappy.

You can download the latest version – here

Announcing DateBox

March 21st, 2006

DateBox is a Plone Archetype Field using JavaScript, DHTML and advanced Date parsing to generate the date based on the grammar passed. The purpose of DateBox is to simplify the date entering process using grammatical terms we are all familiar with.

In simpler terms, that means, with DateBox installed on your site, users can enter dates like

  • Today
  • Tomorrow
  • next friday
  • 6 april
  • 7th may 2006

and the datebox widget will convert that into proper date formats (eg: YYYY-MM-DD).

datebox

Download: Get it here
DateBox is also available on Plone.org under the Products section
Usage:

1. Install as usual in your Products folder
2. Install in your Plone Site with the Quickinstaller tool
3. In your custom Archetype, add :
from Products.DateBox import DateBoxField
from Products.DateBox import DateBoxWidget
4. Use like a regular field/widget in your Type’s Schema. There is an included example.

Full usage example::
DateBoxField(‘test_datebox’,
required = True,
widget = DateBoxWidget(lable = ‘Test DateBox’,
description = ‘Test DateBox Field’,
label = ‘Test Datebox’,
i18n_domain = ‘plone’)
)

A demo type is included. Set INSTALL_DEMO_TYPES = False in config.py to disable it.

Low hanging fruit in the quest to Ajaxify Plone

March 16th, 2006

Seems like everyone is talking about Ajaxification these days. The corridors at ParTecs are abuzz with how this or that Plone feature is ripe for Ajax. And everyone is unanimous in their agreement that Plone really needs this, like Mandy Moore needs Clearasil. Mainly because every bit of the screen real estate in Plone is dynamic, and when you trigger a full screen refresh, there is so much magic going on behind the scenes that it boggles your mind. Every portlet on the sctreen, every tab and every menu item is computed on the fly and while it is a thrill for the upstart programmer, it costs many milli-seconds in screen refresh time, something that can kill even a semi-production site. So any effort to minimize these page refreshes and stop recomputing the whole world on each click will be welcomed in a big way by Plone users everywhere.

Take for instance the Calendar portlet. Nice, as long as you don’t click any button on it. And when you do this inadvertantly, the whole world comes to a screeching halt. And slowly as the new day dawns, you see an ugly URL instead of the page you thought you were supposed to be on. I guess it was so bad that plone.org has removed the Calendar portlet from their home page. Now if the calendar portlet could just be ajaxified and then refresh just itself, Plone users would be thrilled.

Or the way batching works when you do folder contents. The code that run behinds this is definitely not a sight for the faint-hearted. Essentially the whole list, even if it has a thousand items, is recalculated as you wade through each page even though only 10 items are displayed at a time. I do not mean to underplay the complex nature of this problem itself, but surely there is scope for optimization where only the required objects that fit in the current page are woken up. Ajax can definitely come to our rescue here.

Ajaxifying Archetypes

March 14th, 2006

Plone has had Archetypes for ages. Being someone from the pre-Archetype era who has hand rolled them a couple of times (TTWTypes and Formulator ring a bell, anyone?), AT was to me the greatest invention since sliced bread. I have used them in a few applications, and being able to whip out objects and forms and write code just to specify *business logic* was such a joy to behold!

So it causes me endless heartburn when some slick noobie comes along and shows me how she can generate content types on the fly with this great new framework called Cowboy or TurboCam or something without writing any SQL. Now you can bet your ZODB that what I would really like to do is tell her how I have been doing this even before she learnt to type [Ctrl-D] to exit from the python prompt. And then redirect her to all those Archetypes screens which function on less than 20 lines of code – most of which is actually data and may be a little validation. Instead, I blink. And you know why! Its that darn 4 lettered word that my Archetypes still can’t do. My Archetype screens are so hopelessly static and plain behind the times. If only we could have the Ajax-y sexiness of some of those frameworks.

So what do we need to do? Well… I head off to the google toolbar. AJAX+Archetypes. Only 2 relevant hits. Gnubi is working on FAT AT product. No releases yet. And Balazs Ree has a proposal which is basically at the level of the individual widgets.

But I am thinking along a different direction. Which is, basically eliminate the view/edit duality imposed by the templates. Instead, you have a single tab which will allow you to both view and also edit the page if you have the right permissions and save it — and all happens with the same URL and page template so it is ripe for AJAX-ification.

I am going to investigate this with the help of some good friends. Will keep you posted.

AHAH (Asynchronous HTML and HTTP) and Plone

February 22nd, 2006

Recently I have tried working with AHAH along with Plone and found myself reaping the benefits of AJAX and the Zope framework. And what impressed me the most is that I wrote very little JavaScript.

I am going to run through an example of using AHAH with Controller Page Templates.

eg: form.cpt
<html>
<head>
<script language="JavaScript" type="text/javascript"
xsrc="MochiKit.js" mce_src="MochiKit.js"  ></script>
<script language="JavaScript" type="text/javascript">
function LoadManager() {
bindMethods(this);
}

LoadManager.prototype.postFormData = function(theform) {
var data = {}
for (var i in theform.elements) {
var formelement = theform.elements[i];
data[formelement.name] = formelement.value;
}
var d  = doSimpleXMLHttpRequest(theform.action, data);
d.addCallback(this.updateDOM);
d.addErrback(this.fetchError);
}

LoadManager.prototype.updateDOM = function(dom) {
var text = dom.responseText;
this.div.innerHTML=text;
}

LoadManager.prototype.fetchError = function(err) {
alert(err);
}

function postForm(theform, replacediv) {
loadManager = new LoadManager();
loadManager.div = $(replacediv);
loadManager.postFormData(theform);
}
</script>
</head>
<body>
This text will not reload on form submission.
<div id="reloadme">
<div metal:use-macro="here/comment_form/macros/view">
</div>
</body>
</html>

eg: form.cpt.metadata

[default]
title=Reply to Comment

[validators]
validators..Save = validate_comment

[actions]
action.success = traverse_to:string:comment_reply
action.success..Save = traverse_to:string:comment_reply
action.failure = traverse_to:string:comment_form

eg: comment_form.cpt

<metal:block use-macro="here/global_defines/macros/defines" />

<div metal:define-macro="view">

<form  action=""   method="post"
tal:define="errors options/state/getErrors">
<input type="hidden" name="form.submitted" value="1" />

<div class="field"
tal:define="error python:errors.get('comment', None)"
tal:attributes="class python:test(error, 'field error', 'field')">

<label for="title" i18n:translate="label_subject">Comment</label>

<div tal:content="error">Validation error output</div>
<input name="comment"
id="comment"
value=""
tabindex=""
tal:attributes="value request/comment|nothing;tabindex tabindex/next" />

</div>
</div>
<input onClick="postForm(this.form, 'comments')"
tabindex=""
type="button"
value="Save"
name="form.button.Save" />
</form>

</div>
</metal:block>

You must ensure that the response after the form submission is only the contents that you replaced in you macro and not an entire HTML file.

Feedburner RSS

Enter your email address:

Delivered by FeedBurner

Blogroll

Categories

RSS Telematics Freedom

May 2017
M T W T F S S
« May    
1234567
891011121314
15161718192021
22232425262728
293031  

Archive

Sky Sponsored by Web Hosting