ParTecs Weblog

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.

Announcing PloneSkype

March 15th, 2006

PloneSkype is available for download. PloneSkype allows the Plone portal members to communicate with other portal members via Skype. PloneSkype takes communication on the plone platform beyond the asynchronous mode of email, discussion boards and blogs.

Features :

1. Portlet to display online Portal Members
2. Display the user status on the document created by him.
3. Display status of the user when you visit his/her home folder.
4. Option to set type of “skype presence” icons.
5. The portal member has the option of disabling their presence shown to the portal members.
6. Option to setup the status refresh interval.
PloneSkype Screenshot

Download it today and give it a spin.

Tell us how we can expand the idea of using Skype with Plone further and what features you would like to see added to PloneSkype.

Rock on!

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.

When Plone met Skype…

March 13th, 2006

Of late we have been using Skype more and more to communicate (both one-on-one and multiway conferencing) and have been quite happy with it. Something we are even happier with is our company intranet which is based on Plone and which we use heavily for asynchronous communication. So we thought it was pretty natural to have a product that would integrate Skype with Plone. Now we all know how the Plone world is littered with custom Products that solve pretty much any problem you can think of (and with some of them, you wonder who would ever need something like that?) So we went out to plone.org and began our hunt for such a product expecting to find about a dozen versions all covering the essential functions but differing in their UI and implementation details. And what do you think we found?

Zilch. Zipp. Nada. 3 degrees below…

Absolutely nothing whatsoever that resembled anything which even remotely addressed this need. It appears that Plone and Skype are two parallel worlds without any cross border terrorism 🙂
So we set out to write this product. And PloneSkype was conceived!

What did we want from such a product:

1. For starters, a portlet that would show all the members who were logged into Skype at that time and the ability to start a conversation with any of them

2. The ability to tie together a skype icon that will be displayed along the by-line which already appears on pages created by members

3. To be able to set your own skype id on your preferences page

4. Administrator to update skype id of members

5. Display if member is online on Member search page

This seems to be a good set of starting requirements. Se we started implementing these requirements and as it turns out, Skype provides a nice enough API to make much of this quiet easy to implement.And PloneSkype was born! The end product is available for download and install here.

Of course, with design and implementation the devil is in the proverbial details. Along the way we were confronted with issues for which we had to make a few trade-offs. Stay tuned for future installments here to find out and appreciate these design decisions.

Update: Plone Skype available for download 

Undo more than 20 transactions in Zope

February 27th, 2006

Some time ago I need to undo more that 20 transactions in one go. The zope interface displayed only 20 transactions per page. I did the unthinkable and tried to undo the transactions by opening the Zope database on the interpreter. There is a much simpler solution that skipped my mind. All one needed to do was manipulate the URL like so.

http://localhost:8080/manage_UndoForm ?first_transaction:int=20&last_transaction:int=100& PrincipiaUndoBatchSize:int=80

This might seem really obvious but it skipped my mind. And if you were still wondering how one would go about viewing the undo log of the Zope database. I have a small code snippet that will help you get started.

>>> from ZODB import FileStorage, DB
>>> storage = FileStorage.FileStorage('Data.fs')
>>> root=DB(storage).open().root()
>>> print storage.undoLog(0, 10)

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.

« Previous Page

Feedburner RSS

Enter your email address:

Delivered by FeedBurner

Blogroll

Categories

RSS Telematics Freedom

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

Archive

Sky Sponsored by Web Hosting