Posts for the 'Websites' Category

  1. Orbited + Django dev daemon

    Today I got my Django project working with Orbited.

    By creating a twisted proxy for Orbited and Django I am able to serve a development environment for both Django and Orbited plus the builtin MorbidQ message queue.

    I am going to be using this to give live notifications of events that are happening on the system in realtime, and so it should be able to handle quite a large load. To do this I will use another queue in production, but I have found it needed to sort out the development environment first of course.

    This daemon I have put up at GitHub .

    It even serves the static files. Much thanks goes to the HotDot project for seeing how alot of this was done, but I have taken out the authentication and other bits to make it cleaner for general use.

    By timc3 on the
    August 21st, 2010
  2. Realtime web – Orbited vs Tornado

    My latest task and one that I have been researching and playing with for some time is to integrate real time feedback in to our web application. The main goal is to be able to provide real time feedback of jobs and updates to users without Ajax style polling.

    This is a simple requirement to write, but one that had many deeper issues. Firstly it needs to be able to handle many users concurrently and secondly it should do so without blocking execution of code. Our application framework was not designed for this and this is no problem, it has been designed to do certain thing well and other I am really not going to force upon it.

    The main application framework will handle the standard page requests, user authentication and the rest of the standard stack, so I have been looking at technologies to complement its capabilities. This has led me to look at Comet applications and very fast non-block frameworks.

    Of these I would prefer to keep the language in Python, there seem to be good alternatives in Java and .Net but I would rather keep an upgrade path by having a language that can be migrated across to these (thanks Jython and IronPython) and keep data in a backend store that is language agnostic.

    Orbited and Tornado are really good candidates. I am going to stay away from more raw implementations of non-blocking event based frameworks such as Twisted because efforts are often better at this stage in building to serve a business purpose where possible. Orbited does actually use twisted, and I am hoping that I will have little need to dig that deep except for understanding its implementation.

    Tornado I initially didn’t think of, but came around after reading “Building the Realtime User Experience” in which the author, Ted Roden, seems rather partial to it. In fact it can work quite well in fronting our application, but I am starting to reconsider based upon two factors. Firstly, even though it itself was built for a largish scale operation (FriendFeed – now owned by FaceBook), it has little other commercial users behind it and I haven’t found many examples of usage with integrating with Django, Pylons, Turbogears or Zope in a production environment. Secondly what really turns me off is the immaturity of its tests. Looking on GitHub even the README shows that little effort has been put into its testing environment, let alone their sporadic coverage.

    Twisted on the other hand is extremely mature in both terms of numbers of deployments and its test environment, and this makes Orbited a much better candidate.

    I have yet to look at certain other alternatives, such as Diesel, but I have a feeling that I will again come around to start using Orbited.

    The other huge plus for me in using Orbited is that it can use the STOMP protocol, and use RabbitMQ or ActiveMQ. Other parts of our technology stack are starting to use STOMP and I wish to move more operations on to an event queue, which will open up much in terms of flexibility in the future.

    Its a pity that “Building the Realtime User Experience” was so limited in terms of covering alternatives to Tornado.

    By timc3 on the
    August 16th, 2010
  3. Twitter mobile phone number fail

    Could someone please tell me exactly how I am supposed to put in my phone number?

    twitter.png

    Seriously something wrong with this. And of course if I click submit it tells me that I should have filled out the number correctly.

    By timc3 on the
    March 18th, 2009
  4. Facebook is AOL 2.0

    Facebook is The Borg: “

    Much of the activity that used to happen out in the wild unfettered Net, over email, open (XMPP-based) IM and blog posts is now happening inside the Facebook silo. It is AOL 2.0.

    I avoid the place, but that’s getting harder. On this current visit I see 7 friend suggestions, 273 friend requests, 6 event invitations, 5 good karma from debo requests, 1 good karma request, 220 other requests, 4 new updates, 235 items in my inbox, 7 pokes and 522 friends to start with.

    Okay, I just said yes to several friend requests, congratulated a friend on his new twins, and started chatting in FB for the first time.

    To FB’s credit, it’s working on a Jabber/XMPP interface, so you can chat to FB-based friends through any client that talks XMPP. That’s cool, but The Borg still grows.

    I also notice that FB now has a tiny pale gray thumbs-up and thumbs-down for its advertising. When I click on the down thumb (which I always do — I haven’t yet seen a relevant ad), it just says ‘Loading…’ in a big box that won’t go away.

    So I just punched out. I suspect I’ll be doing less of that.

    (Via The Doc Searls Weblog.)

    By timc3 on the
    January 8th, 2009
  5. This is awesome – Papervision

    This is really really awesome, and you have to really check it out for your self.

    MeWithAPet.jpg

    Its a little flash application that uses a webcam or other camera attached to your computer to project a little ‘Proto’ guy on top of a printed piece of paper. They have even got some code released for it.

    Check it out here with some images and video, but it really works better to try it yourselves:

    http://www.boffswana.com/news/

    By timc3 on the
    December 16th, 2008
  6. django one form, two models

    This post is a work in progress is now working I am glad to say. I have been working on a django site which needs two models updated for one post. It is actually using models very close to that on django-forums and I have created a forms.py file:

    class ThreadForm(forms.ModelForm):
        class Meta:
            model = Thread
            exclude = ('forum', 'sticky', 'closed', 'posts', 'views', 'latest_post_time')
         
        def clean_title(self):
            title = self.cleaned_data['title']
            if not alnum_re.search(title):
                raise forms.ValidationError(ugettext("Titles can only contain letters, numbers and underscores"))

            if len(title) < 1:
                raise forms.ValidationError(ugettext("Please enter a title"))
            return title

           
    class PostForm(forms.ModelForm):
        class Meta:
            model = Post
            exclude = ('thread', 'author', 'time', 'related_item')
           
        def clean_body(self):
            body = self.cleaned_data['body']
            if len(body) < 1:
                raise forms.ValidationError(ugettext("Please enter some body text"))
            return body

    And then in my views (after importing in the correct models):

    @login_required
    def groupnewthread(request, slug):
        thegroup = get_object_or_404(GroupsOfUser, slug=slug)
        if request.method == 'POST':
            f = request.POST.copy()
            tdata = {
                'title': f['title'],
            }
            pdata = {
                'body': f['body'],
            }
            t = ThreadForm(tdata)
            p = PostForm(pdata)
            if t.is_valid():
                newthread = t.save(commit=False)
                newthread.forum = thegroup
               
               
                if p.is_valid():
                    newthread.save()
                    newpost = p.save(commit=False)
                    newpost.thread = newthread
                    newpost.author = request.user
                    newpost.save()
             
                    strmessage = 'has created a thread <a href="%s">%s</a>' % (newthread.get_absolute_url(), newthread.title)
                    usm = UserStatus(user = newpost.author, message = strmessage)
                    usm.save()
             
                    return HttpResponseRedirect(reverse('groupdetail', args=[thegroup.slug]))
           
        else:

            t = ThreadForm()
            p = PostForm()
           
        objContext = RequestContext(request, {'threadform': t, 'postform': p})
        return render_to_response('groups/group_thread_add.html', objContext)

    Now the bit that is in progress is the returning part of dealing with the form data being bound, but I am going to write a custom handler. This is obviously going to be much easier to handle than an update, which I will have to deal with at a point.

    The form HTML looks like this btw:

    {% extends "base.html" %}
    {% load i18n %}
    {% block title %}
        {% trans 'Add a new group thread' %}
    {% endblock %}
    {% block body %}
        <h1>{% trans 'Create a new group thread' %}</h1>
    <div class="column span-14">
        {% if t.errors %}
        <h3>{% blocktrans count t.errors|length as count %}Please correct the following error:{% plural %}Please correct the following errors:{% endblocktrans %}</h3>
        {% endif %}
        {% if p.errors %}
        <h3>{% blocktrans count p.errors|length as count %}Please correct the following error:{% plural %}Please correct the following errors:{% endblocktrans %}</h3>
        {% endif %}
        <table>
        <form method="post" action=".">
            {{ threadform.as_table }}
            {{ postform.as_table }}
        <tr><td></td><td><input type="submit" value="{% trans "Update" %}"/></td></tr>
        </form>
        </table>
    </div>
    {% endblock %}
    By timc3 on the
    June 21st, 2008
  7. Looks like Django is really taking off

    Since the introduction of Google’s appengine which includes support for some of Django’s code, and the template system there has been an incredible amount of press for Django.

    At the moment there is no backend support for AppEngine in Django (and DB2 support is still lacking – there was a blog post about a year ago but nothing seems to have happened since, and I would love to be proved wrong on that one) but it must only be a matter of time before this happens so for the moment you have to disable the ORM support. Pity, but I can see why.

    But I am glad that Django is getting the attention that it deserves, I have long know that Python is well used in Google (and Yahoo for that matter), and now we should see even more people using Django which can only be a good thing for the ever-growing community.

    Here is an excellent write-up on Google App Engine http://www.dougma.com/archives/81

    By timc3 on the
    April 18th, 2008
  8. 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
  9. 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