Filtered by Zope

Page 3

Reset

Comparing Ruby and PHP

September 21, 2006
0 comments Zope

I was reading Of snakes and rubies; Or why I chose Python over Ruby which is an article comparing Python and Ruby. The blog article has loads of comments. This one I liked in particular

"For people writing good production code in PHP, I'm not trying to pile on - I know you get disrespected enough. It's possible to write well-structured sites on PHP, and lots of you do. It's just that in PHP, anyone can learn how to create spaghetti code in 10 minutes, but you have to learn a decent-sized body of knowledge to gain the ability to separate presentation from logic. By contrast, when novices get started in Rails, they're using good structure by default. They have to make an effort to screw it up."

Truncated! Read the rest by clicking the link below.

TinyMCE + Zope = ZTinyMCE

June 1, 2006
8 comments Zope

ZTinyMCE in action This is my first release of ZTinyMCE. ZTinyMCE makes it easy to use TinyMCE, the best Open Source WYSIWYG editor in my opinion.

We at Fry-IT use this a lot for our websites as shown in the screenshots. The ZTinyMCE product works only with Zope2. Once you have it installed and you have created a ZTinyMCE instance in your root plus a ZTinyMCE Configuration object called "tinymce.conf" all you have to do to convert a plain page of HTML with textareas to a plain page of HTML with WYSIWYG textareas is this:


<script tal:replace="structure here/tinymce.conf">
</script>

Setting security declarations to Zope classes

February 2, 2006
5 comments Python, Zope

If you're into Zope python product stuff, read on, otherwise don't bother.

Thanks to Brian Lloyd (Zope corp) and Florent Guillaume (Nuxeo) I now know how to set security declarations on a class outside the class. It doesn't work like a normal python class (new or old style) which was a bit of a surprise. This is how you do it in a "normal" python class:


class _Z:
  def __init__(self):
      self.z = "Z"
  def declareProtected(self, *a,**k):
      print "++declare something+"

def foo():
  print "I'm being called"
  return _Z()

class A:
  security=foo()
  def __init__(self):
      pass
A.security.declareProtected("foo")

Truncated! Read the rest by clicking the link below.

Major performance fix on file searches

November 19, 2005
0 comments Zope, IssueTrackerProduct

A week ago I ran some ad hoc benchmarks on various suspect functions in the IssueTrackerProduct and came to a clear and simple conclusion: searching is the bottleneck and within the search it's the searching for file attachments that take all of the time.

If you're interested and open minded, here's the results of that benchmark This sparked some thoughts. First I wrote a filename splitter which isn't rocket science but I'm proud to say that it's use is brilliant. Before, the find-by-file function in the IssueTrackerProduct used a plain old find() test like this:


filename.find('foo') > -1

This is very fast but not very intelligent. For example it'll with match on foobar.txt and plainfooter.gif. So, what I did instead was to create a KeywordIndex and index all the splitted filenames in that index.

Truncated! Read the rest by clicking the link below.

Filename splitter

November 15, 2005
4 comments Python, Zope

I need to create a Zope index for a ZCatalog that is KeywordIndex. A KeywordIndex is a list (array if you like) that is used to describe some data. For example, if the data is "Peter is a Swedish Londoner", the the keywords are ("peter", "swedish", "londoner"). What about if the data you want to create an index of is a filename like "NameLog.txt" or "holiday-00412-juli-05.jpg". I've now quickly written a little something that seems to do a decent job. It splits the filenames (these are filenames only and no paths) by caMel structure, dot (.), underscore (_), dash (-) and digits.

If you want to play with my little script, have a look at filenamesplitter.py If you open that script you'll see that it tests a whole bunch of filenames (taken from the Demo issuetracker) and if you want to see what this the result is, here it is:

Truncated! Read the rest by clicking the link below.

"Clever" date formatting accessibility

November 10, 2005
14 comments Python, Zope

Last night I wrote a little function that tries to show dates cleverly by comparing the date with todays date, it formats the date differently.

If the date is today is just says "Today 10:00" and for yesterday it says "Yesterday 10:00". If it's within a week it shows is like this "Thursday 10:00". If the date is older than about 30 days it skips the time part and just shows "13-May 2005" and if anything else (ie. > 7 and < 30 days) it shows the whole thing like this "13-Oct 2005 10:00".

What do you think about this? ...from a usability/accessability point of view. One counter argument I have against this is that if you print off a page where it says "Today 12:22" and leave that printed paper for a few days, what "Today" means will change.

To demonstrate it, I've put together a little demo page so that you can get a feel for how it works. Please let me know what you think.

Toggle Zope's debug mode

October 1, 2005
0 comments Zope

This is far from rocket science but since I personally many times find it useful I thought I could share it with other Zope developers/users who find themselfs often editing the etc/zope.conf file to change the debug-mode key.

This script opens the zope.conf file and changes it to say debug-mode off if it said debug-mode on before and changes it to debug-mode on if it said debug-mode off before.

Truncated! Read the rest by clicking the link below.

Pimp my COREBlog

September 27, 2005
5 comments Zope

I've started using lovely COREBlog by Atsushi Shibata at work recently as a "work blog". It's not going live because it's company internal stuff such as "Don't forget to send the invoice to Foobar Ltd".

I think COREBlog has a lot of potential. One of the best features is that it supports the Blogger, MovableType and MetaWeblog APIs which means that I can very quickly jot down new blog items without disrupting my workflow.

There are still some little issues that annoy me but not really stopping me from doing what I want to do. The one thing that annoys me the most is the design. It's better than nothing but it really isn't great in my opinion. Where can I find some other existing neat looking COREBlog instances willing to share their stylesheet? I wish there was a way that I can search Google for all blogs generated by COREBlog and then just open them one by one.

'Cache-Control' or Expires

September 16, 2005
3 comments Zope

Dieter Maurer was as kind as he always is one the Zope mailing list and explained to me the difference between using the Cache-Control and the Expires header for inducing browsers to cache your web elements. He explains:

Cache control is the modern (HTTP 1.1) way, "Expires" the old (HTTP 1.0) one.

My problem is that I've know about each but never bothered to find out why there are two ways of doing the same thing. In most of my projects I've used the oldschool method of setting RFC822 formatted future dates on the Expires header, but from now on I'll use both. Dieter continues on my question "What is best to use and for what?":

Use them both:

HTTP 1.1 clients will honour "Cache-Control" (which is easier to use and much more flexible).

HTTP 1.0 clients will ignore "Cache-Control" but honour "Expires". With "Expires" you get thus at least a bit control for these old clients.

Truncated! Read the rest by clicking the link below.