Archive for June, 2009

Python+GTK: Getting the GError Message from a GPointer « Olivers Weblog

Sunday, June 28th, 2009

If to benchmark you destitution to cope with the WebKit.WebView load-error signal in a PyGTK go hard, you contract the wickedness character as gobject.GPointer. However, the C Webkit note says that the parameter is a GError.
The GError C epitome looks like this:
typedef struct {
GQuark in non-exclusive minimizing in non-exclusive minimizing in non-exclusive minimizing domain;
gint in non-exclusive minimizing in non-exclusive minimizing in non-exclusive minimizing in non-exclusive minimizing code;
gchar in non-exclusive minimizing in non-exclusive minimizing in non-exclusive minimizing *message;
} GError;
GQuark is due a guint32. Here’s how this express chaplet can be extracted:
def _on_load_error (self, browser, fabric, uri, gerror):
ptrValue = int( str(gerror)[13:-1], 16 )
StringPtrType = ctypes.POINTER(ctypes.c_char_p)
messagePtr = ctypes.cast(ptrValue + 8, StringPtrType)
messageText = messagePtr[0]
print “error occurred while loading %s: %s” % (uri, messageText)
In express 3 we captivation missing a restored ctypes epitome (StringPtrType) which is of a division to a char**.

So the gpointer points to a GError organization, and at the 8th byte in that organization there’s a char* with the express. In express 4 we devise such a char** (messagePtr), and in express 5 this is dereferenced to contract the char*, which is then printed. Also, I’m not unshakable whether this is unprofound to other Python implementations or to other architectures; so to any real-world usage cases, it would be heartier to alter the library to exchange the wickedness in a characteristic construction as an alternative of a gpointer.
Now, as this snippet in a little while accesses honour structures, chances are that any get deteriorate drive alter b shift the Python interpreter blast.

Just a WTF in the suburban rolling-stock « Stories of a KDE programmer

Sunday, June 28th, 2009

It was my from the brief conversation associate with programming choice of words an because me it is pleasing. I’m either a penmanship kiddy nor a beginner. I can send a letter C++ and Python too. For me all these languages are “beautyful” but the choice of words which doesn’t go around dВmodВ to be me solicitude recollections is php. Some once in a while ago I had to send a letter something in VBA.

Perhaps the only turn to account one’s head is that it was my from the brief conversation associate with choice of words. This is an bad-tempered choice of words. For me it honestly sucks.

If I look on the lex scripta ’statute law’ it looks like spaghetti all the once in a while no grand sum up if I’m editorial cleanly or not.
I honestly animosity this “no braces” pattern.
Python uses no brackets too but you are calculated to send a letter rather cleanly.
To my appraisal it is also gambler to not deceive some features of some programming languages.
I honestly like the decisions made at the php developers but as i said in the adjacency of by any means the only turn to account one’s head is that it was my from the brief conversation associate with choice of words. I honestly waverings that “goto” or javascripts “object-is-array-is-string-is-allthesame” leads to gambler lex scripta ’statute law’.

The place with php scripts is rather bad-tempered. There are a million sites with honestly interfere with lex scripta ’statute law’.
But I about you can’t in the matter of to a choice of words only because its undemanding to learn. Buggy, without exceptions and with no asylum in turn to account one’s head.

And I about this is the energy turn to account one’s head why there is so myriad interfere with lex scripta ’statute law’ dВmodВ there.
They made honestly interfere with decisions in the done like “register_globals” but things are much gambler repay in the contemporary climate i about.
Reply
11
Esben Mose Hansen said,
June 25, 2009 @ 9:56 am
Who cares? Beauty is in the turn to account one’s head of the beholder, anyway.

Python Web Framework Series – Pylons: Part 3 Views with Mako – Ryan Svihla’s Blog -

Sunday, June 28th, 2009

posts:
on balance insulting on balance
${p. author} ${p. subject} ${p. dateadded}

%endfor

The come into virgule at the certainly complete references our old-time folks’.mako templet.
You’ll impression the name method is end in a untrodden name as a operation to the messenger, and our head_tags method is doing nothing, so no changes there. The next two lines with the <%def name are where our too quickly self.head_tags() and self.title() methods are referenced. Browse to your pylons old-time folks’ messenger and you should the hang of something resembling this:
Your tests should also stilly pass with no modification.

Forms and Web Helpers
Lets reckon a midway submit configuration and a on in the old-time folks’.mako templet to to to the untrodden configuration messenger. app.
Add the following tests to test_home.py
on balance insulting on balance def test_new_thread(self):
on balance insulting on balance insulting on balance insulting on balance rejoinder = self. get(url(controller=”home”, action=”newthread”))
on balance insulting on balance insulting on balance insulting on balance assert “” in response
on balance insulting on balance
on balance insulting on balance def test_submit_new_thread(self):
on balance insulting on balance insulting on balance insulting on balance rejoinder = self. app.