Things to come

A bit of a taster really, a post about the things that I intend to write – well that’s one way of getting me to ensure that I do write them.

NestedListHelper
I’ve written a helper to generate nested UL’s from the results of a find(‘threaded’) call. I’ve been using the helper to generate the nested lists for CSS menus and it is also great for sitemaps. Just needs a bit of tidying up before I set it free.

Back to basics with Auth
(This one is actually in draft right now) Another CakePHP one – I’ve been using a quite complex auth / groups / users solution derived the fabulous solution by Studio Canaria but these things get more and more complex. Recently for a project I just needed something simple but I’d forgotten how complex and powerful even basic Auth can be, so I decided to write a kind of back to basics tutorial.

My perfect E-book
I love books. I hate reading PDFs or anything book-like of the screen. My thoughts on the perfect E-book reader.

A nervy bit of sailing

dsc_2652.jpg

dsc_2653.jpg

dsc_2654.jpg

dsc_2655.jpg

Free UK Postcode Geocoding

I’ve just come across and started using a brilliant new free UK postcode lookup (so far it has provided me with the Latitude & Longitude of every postcode I’ve thrown at it), it’s fast, free and easy to use and can return the Latitude & Longitude as either CSV or JSON – whatever takes your fancy. Perhaps best of all, all it requires is the postcode, not other parts of the address like a property name or number.

http://www.ernestmarples.com (apparently Ernest Marples was the Postmaster general who introduced the postcode to the UK)

A quick vaguely Cakey post

Not a real post this really, more of a snippet, but something of interest. I just switched on view cacheing for my UK Business Directory (a personal project of mine) and by my rough and ready benchmarking with firebug the load times increased by 75%. The site is hosted on Dreamhost which whilst great value for money and very featureful isn’t always the fastest of hosts, so it has made a real difference.

I’ve also just added fulltext search to the site – its slightly unusual in that it searches two tables at either end of a HABTM relationship, when I get the time I’m planning to write a quick post about setting that up with CakePHP.

Flirting with Django – part 2

Just a quick post. I’ve been on holiday and I’ve been quite busy with various other things like setting myself up as full blown freelancer (dedicated website powered by Django coming soon)(anybody need a website?) and tweaking my new business directory website, so i haven’t had a chance to do too much.

In my previous post I mentioned that the one thing that drove me utterly mad was the issue of serving static files from Django. I thought that I had got it licked. My god I was wrong. Everything was working fine or so I assumed by tying in the Django FileBrowser and Django TinyMCE started to cause me problems. In the end I was left with a situation where I could browse for an image (using FileBrowseField) and select it but when I saved the page on the next page the paths were scrambled somehow and the file browser would not open. (Clearly my own newbie fault but damn hard to sort – and caused by my attempts to sort the static files issue).

The TinyMCE plugin is great, don’t get me wrong installing TinyMCE is not hard but setting up the plugins can be a chore so this is a nice little package – particularly the way it integrates with the File Browser.

The FileBrowser plugin is also great, but may one day if I get good enough at Python and Django I will rewrite it. Personally I like to have all my uploads managed in a database (as anyone who has tried out my extension to the CakePHP MeioUpload behaviour will see). My feeling is that with the FileBrowser things could get messy pretty fast. Be nice to have everything in inline popups / modal dialogues rather than new windows (haven’t tried yet).

I did solve the static file issue but I had to create a brand new clean app to test it out (integrated with TinyMCE + FileBrowser). Key parts of settings.py as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = 'E:/xampp/htdocs/django/s2/media/'
 
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'
 
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/admin/'
 
FILEBROWSER_URL_WWW = '/'
 
TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    'E:/xampp/htdocs/django/s2/templates'
)
 
 
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    's2.shop',
    'sorl.thumbnail',
    'filebrowser',
    'tinymce',
)
 
TINYMCE_DEFAULT_CONFIG = {
    'plugins': "table,spellchecker,paste,searchreplace",
    'theme': "advanced",
    'theme_advanced_toolbar_location' : "top",
    'theme_advanced_toolbar_align' : "left",
    'theme_advanced_statusbar_location' : "bottom",
    'theme_advanced_resizing' : "true"
}
TINYMCE_SPELLCHECKER = True
TINYMCE_COMPRESSOR = True

It’s funny – I really don’t feel that the whole static file thing is explained anywhere clearly enough. Should be fun when I come to deploy it on a real server. The experience so far has really got me thinking about ‘Auto Magic’ – the way frameworks can do so too much. Here I am building something fairly complex and learning both Python and the framework at the same time – at the moment I feel there is too much magic, the framework is so powerful I am completely detached and it doesn’t really help me learn Python particularly (mostly as I am having to write so little). i am constantly amazed at how terse the language is; CakePHP has a lot of magic but I still have to type a fair bit; with Django I don’t feel I’m writing at all – it makes an interesting comparison to Java which really doesn’t seem to be at all concerned with saving poor programmers fingers.

Until next time…