Web X.Y

Tips and tricks for development with Java, Python, Django, the Google Web Toolkit, and Linux.

Python: Using decorators with functools.wraps for automated logging and other goodies December 10, 2008

Filed under: python — adambossy @ 10:37 pm
Tags: , , ,

from functools import wraps

def magiclogging(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        print ‘Starting ‘ + func.func_name
        result = func(*args, **kwargs)
        print ‘Finishing ‘ + func.func_name
        return result
    return wrapper

More detail at Stack Overflow.

Even more at IBM DeveloperWorks.

 

Java: Checkout Eclipse source code using only CVS December 8, 2008

Filed under: Java — adambossy @ 5:14 pm
Tags:

Don’t even mess with SVN. It’s terrible.

Instructions to check out Eclipse via CVS, no plug-ins required (see pictures): http://wiki.eclipse.org/index.php/CVS_Howto#CVS_and_firewalls

 

GWT: Java method calls from Javascript Native Interface (JSNI) with multiple parameters December 8, 2008

Filed under: GWT — adambossy @ 6:58 am
Tags: , , ,

Because the GWT tutorial doesn’t give a clear example.

handler.@com.healthySoftware.client.controlPanel.SaveButton::handleJsonResponse(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/user/client/ui/Panel;)(jsonObj, panel);

 

Java: Checkout Eclipse source code using only CVS December 5, 2008

Filed under: Java — adambossy @ 5:31 pm
Tags:

Don’t even mess with SVN. It’s terrible.

Instructions (see pictures): http://wiki.eclipse.org/index.php/CVS_Howto#CVS_and_firewalls

 

Django: “newforms-admin: root() takes exactly 3 arguments (2 given)” December 4, 2008

Filed under: Django — adambossy @ 5:50 pm
Tags: , , , ,

Continued from urls problem.

Regex groups, named groups:

http://www.mail-archive.com/django-users@googlegroups.com/msg54489.html

Yes there is. You can use regex groups:

(r'^admin/(.*)', site1.root),

The string that matches .* will be passed as an extra arg.

Or named groups:

(r'^admin/(?P<url>.*)', site1.root),

Additionaly, you can pass extra args:
http://www.djangoproject.com/documentation/url_dispatch/#passing-extra-options-to-view-functions

Juanjo
 

Django: “No module named urls” error for /admin/ December 4, 2008

Filed under: Django — adambossy @ 5:48 pm
Tags: , , ,

Backward compatibility issue from Django 0.96 -> Django 1.0.

http://groups.google.com/group/django-users/browse_thread/thread/28df85c31f859f36

>> http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Mergednewforms-adminintotrunk :


# OLD:
from django.conf.urls.defaults import *

urlpatterns = patterns('',
    (r'^admin/', include('django.contrib.admin.urls')),
)

# NEW:
from django.conf.urls.defaults import *
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
    (r'^admin/(.*)', admin.site.root),
)
 

 
Follow

Get every new post delivered to your Inbox.