Posts for the 'Websites' Category

  1. Django and URLS naming

    Django URLs naming can be a pain sometimes, unless it is just me but an easy way to debug is to use Django’s shell and import urlresolvers:

    python manage.py shell

    >> from django.core.urlresolvers import reverse
    >> reverse('nameofurl')

    If there are arguments in the URLS field (for instance passing in the slug):

     >> reverse('nameofurl', 'slug') [/sourcecode]

    Then it should resolve the name to the URL path needed. If it doesn’t, well something is wrong. We got a weird Traceback when using Python 2.5 though:

    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", line 297, in reverse
        return iri_to_uri(u'/' + get_resolver(urlconf).reverse(viewname, *args, **kwargs))
      File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", line 282, in reverse
        if lookup_view in self.reverse_dict:
      File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", line 221, in _get_reverse_dict
        self._reverse_dict[pattern.callback] = (pattern,)
      File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", line 178, in _get_callback
        self._callback = get_callable(self._callback_str)
      File "/Users/azimi/Code/Python/Django/django-trunk/django/utils/functional.py", line 130, in wrapper
        result = func(*args)
      File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", line 47, in get_callable
        lookup_view = getattr(__import__(mod_name, {}, {}, ['']), func_name)
      File "/website/xmlrpc.py", line 8, in </module><module>
        dispatcher = SimpleXMLRPCDispatcher() # Python 2.4
    TypeError: __init__() takes exactly 3 arguments (1 given)
    >>> reverse('homepage')
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", line 297, in reverse
        return iri_to_uri(u'/' + get_resolver(urlconf).reverse(viewname, *args, **kwargs))
      File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", line 284, in reverse
        raise NoReverseMatch
    NoReverseMatch
    </module></console></module></console>

    Looks like something is broken in support for python 2.5 on OS X with django, but I wonder if it is just us thats found this.

    By timc3 on the
    March 13th, 2008
  2. Predictions for 2008

    I don’t think its too late to provide some predictions for 2008, so here are mine.

    3D Printers
    We are going to be seeing a lot more on the subject, although they have been out for a while I think this is going to be the year that we are going to be hearing alot more about 3D printers and 3D printing methods, and seeing a lot more things they can do. Also the price will drop I am sure meaning that there are more around to play with.

    3D_printer.gif

    Phones
    I think the phone market will see some much better models this year, coming from the increased R&D that the iPhone would have produced. Touch screens are already advancing as proved by new models from Samsung, and software will bound to improve. Microsoft will lag behind as usual. The Samsung model SCH-W559 I am particularly interested in checking out as it has a vibrating touch screen (called VibeTonz) that provides feedback to make it feel like a mechanical device.

    Samsung-sch-w559.png

    OS X viruses or worms.
    Apple and OS X are proving increasingly popular due to ease of use and maintenance, but these increase in popularity could mean that we see an increase in nefarious activity on the platform. This is might not be as bad as it seems, it is built on quite a stable secure platform and will lead to increased security on applications and service running on the system.

    Facebook backlash.
    Facebook is not the elegant social networking site it once was. Too many applications, services and third parties are in on the act and now it looks like a complete mess. It might be just me but it also seems that the hosting is always one step behind. I have heard that the next release they are working on is for collapsable menus and for hiding things, but I have already taken off information from the service.

    By timc3 on the
    January 17th, 2008
  3. 100 things that you didn’t know about 2007

    For once BBC news comes up with something interesting, a list of 100 things that you didn’t know about 2007:

    http://www.bbc.co.uk/blogs/magazinemonitor/2008/01/100_things_we_didnt_know_last_3.shtml

    Some that I like include:

    Newcastle is the noisiest place in England.
    Only about half of China’s population can speak the national language, Mandarin.
    There is mobile phone reception from the summit of Mount Everest.
    Denmark is the happiest country in Europe; Italy the unhappiest.
    Cats can be police constables

    Incidentally I am now posting this from the latest version of MarsEdit to which I have just upgraded. Best blogging software I have found yet.

    By timc3 on the
    January 7th, 2008
  4. John Battelle’s Searchblog: Predictions 2008

    This is quite interesting, though I had hoped that he would say Myspace would disappear. Heres hoping.

    John Battelle’s Searchblog: Predictions 2008: “This year I am going to organize my predictions by companies (just the big ones) and trends. I’m focusing on advertising and search markets and the largest companies in that space, as that seems to be what’s on our collective minds these days, and it’s what I seem to have focused on in the past, as I read through my past prediction posts.

    So what are the trends in 2008?”

    By timc3 on the
    January 2nd, 2008
  5. Django and OSX

    Those who have been here before know that I am a big fan of the Django python webframework, and also a big fan of OS X. So I thought that I would install Django on my MacBook Pro.

    I did have it all installed on my G4 laptop, but I am going to be using it with at least two different databases on this machine. I am not going to give a complete, what I typed style install, just an overview because it is fairly easy.

    1. Install latest version 2.4.* of Python from http://www.pythonmac.org
    2. Check out the development version of Django from http://www.djangoproject.com/download/ (I checked it out in /django – probably not the best place to put it.)
    3. Install latest stable version (5.1) of MySQL from http://www.mysql.com/
    4. Install latest stable version of MySQL tools http://www.mysql.com/products/tools/administrator/
    5. Install MySQLdb from http://www.pythonmac.org/packages/py24-fat/index.html
    6. Create a symlink so Python can find django: ln -s /django/django_src/django/ /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django
    7. Then I followed some instructions on blog.vixiom.com to add the path that I need.
    8. edit your .bash_profile file in your home directory with the following path: /django/django_src/django/bin/:/Library/Frameworks/Python.framework/Versions/Current/bin:

    Now that should be everything needed to start running with Django and MySQL. PostGreSQL is of course the better database but for the testing work that I am doing my webhost at the moment doesn’t support PostgreSQL..

    By timc3 on the
    July 9th, 2007
  6. upgraded wordpress

    Just a quickone, but I have upgraded wordpress on this site to version 2.2.1 which should be the very latest. I had it stuck at a very old version before so it should operate better now, and also I should have all the latest bug fixes.

    By timc3 on the
    July 3rd, 2007
  7. YUI and Camino

    So I have been adding some AJAX goodness to the new site that I am building (all will be revealed soon after testing!) and after some help choosing a framework I decided upon Yahoo’s YUI.

    It helps that some others are already looking at this library, but I am so far having trouble with Camino.

    Camino is my favorite browser on the Mac by far, so of the niceness of the Gecko browsing engine along with better Mac integration but should I support it. I want to degrade it nicely, turning it over to my normal XHTML forms but I have yet to find a way. So I am going down the route of trying to find out manually.

    Even though its a minor browser I still feel that I should do my best, to find out how I decided to look at the stats for this site over the past 2 months to see using what and this is the result:

    Firefox: 52.38%
    Internet Explorer: 34.21%
    Safari: 6.24%
    Opera: 3.53%
    Mozilla: 1.89%
    Konqueror: 0.72%
    Camino: 0.69%
    Netscape: 0.24%
    Mozilla Compatible Agent: 0.07%
    Galeon: 0.03%

    So quite minor, but I like Camino so I should, and I like Opera so I just need to check that on a Mac, but I wouldn’t be surprised if that figure is me!

    updates to come.

    By timc3 on the
    October 15th, 2006
  8. Django site comments and all!

    I haven’t been posted that much here recently and thats because I have been doing other things and working on other sites. I have also built a new server for home, which will be detailed later, but first and foremost I am still playing with Django and build a site using it.

    I have had enough with doing WordPress sites, and although I do know it fairly well I wanted to write something a bit more tailored to the application. And its a good test for the plans I have for other applications later on.

    Django I am enjoying, but its not with out frustration. And although in parts it is amazingly well documented for a framework thats been in the public eye for a relatively shorttime it does miss out on the docs in some parts. I am finding that some things are overdocumented and its hard to find relatively simple bits of information and others such as the comment system just isn’t documented.

    Although they are quite upfront about the comment system needing documents, it is an area that slows down the production pipeline quite alot, to the point where its as slow going as any other development. I suppose I can’t complain too much but still I hope this gets addressed reasonably quickly. I should put down my own experiences with the comment system at this point for others to use, but it should be noted that I don’t know much at all and this is only my findings and what I have so far:

    1. The Django comment system is broken up into three areas – Comments, Karma and Freecomment and if you are interested in what these contain then looking at the database should be your first port of call.
    2. Free comments and comments are different though in some cases if you are using a template or method using free_ then you can sometimes safely omit free_ and get the standard comment system.
    3. The standard comment system is based around logged on users, while freecomments seems to be open to all.
    4. At the moment due to the lack of documentation the two best places to find out information is from the django source itself /django/contrib/comments and in the sourcecode posted by Jeff Croft for his Lost-Theories website.

    Here you can see the django comments tables in MySQL (my host doesn’t yet support PostGreSQL, so I develop in the same database I am going to host on).

    MySQL view of the comments system

    So this has lead me to get a working but rough comments module into my test site. I am using a mixture of my own views and generics like most, and I have created my own templates for the tables in my model.

    In the details page for one model, I am pulling out some information from the post like so:

    {% block content %}
    {{ object.article_body|escape|linebreaks }}
    {% endblock %}

    Then I am referring to the comments. My model is called Post so that is what I am pulling the comments out for:

    {% block metacontent %}
    {% load comments.comments %}
    {% get_comment_list for website.post object.id as comment_list %}
    {% ifequal post.get_comment_count 0 %}
    No one has posted any comments yet. Perhaps you'd like to be the first?
    {% endifequal %}
    {% for comment in comment_list %}
    {{ comment.comment }}
    {% endfor %}

    Then I pull in the standard comment form:

    {% comment_form for website.post object.id%}

    In your templates directory you can then create a subdirectory called “comments” and the commenting system will search in here first for the comments templates before using its own.

    I copied the form.html template in here and modified it, and then I also created templates for posted.html and preview.html. If you are looking for ideas for these two again Jeff Croft’s source code for Lost-Theories is very helpful.

    And this is as far as I have got so far. In the future I would love to extend it with the Karma system but there is alot more to do to get this site up and running.

    By timc3 on the
    October 8th, 2006
  9. Dreamhost backup plans

    I have been looking at how I backup my data at home, and one thing that always comes to mind is how to get these backups of site, and preferrably into a different geographical area easily.

    Well Amazon S3 storage was always on my mind, but recently dreamhost have gone crazy with their storage offerings.  I know have over 400Gb of space with over 4Tb of transfer for a small outlay each month.

    A cost comparison has been done here by Joseph Scott showing how the two compare:

    http://joseph.randomnetworks.com/archives/2006/10/03/amazon-s3-vs-dreamhost/

    I am going to be looking at implementing something with dreamhost I think, I am not a major corporation, I am a home user with some data so I think dreamhost will be fine.

    Bacula and Backuppc are two projects that run on Debian that I will be checking out, and first and foremost I want to make sure that my data is encrypted quite strongly.  Though I am probably going to put up my photo archive just as is, to have easy access when needed.  More posts to come on this.

    By timc3 on the
    October 8th, 2006