




Good documentation should be readable from source, and usable to generate fancy HTML. That’s why RST is so commonly used:
Good documentation should often show code. This article demonstrates an inconsistency between RTFD and GitHub rendering, and how to fix it.
As far as sphinx is concerned, the default highlight language for code blocks is Python. This will render as Python on Sphinx/RTFD:
Read MoreBy E. W. Dijkstra.
An interesting topic by Anssi Kääriäinen flew by django-developers mailing list about ticket #16649: “Models.save() refactoring: check updated rows to determine action”.
The ticket mentions a 50% performance optimization. Here’s an explanation by akaariai (core developer):
A bit more information about what the approach suggested is about. Assume you load a model from DB, change some fields and save it. We currently do:
SELECT - load from DB [change fields]; save() In save: SELECT - assert that the PK exists in the DB if yes: UPDATE else: INSERT
The second select above is usually redundant. If we know the object is loaded from DB (
Read Moreself._state.adding == False
), and we are saving it to the same DB it was loaded from (self._state.db == the db we are saving to
), then it is very likely the object exists in the DB. So, instead we should do:
Personnaly, I’ve never thrusted that feature ever. I prefer to remember or regenerate my passwords. Egor Homakov explains how this feature can be exploited in javascript.
… then try ignorance.
This message is intended to motivate developers to document their stuff.
Extract from a great thread on the django-developper mailing list started by Trey Raymond:
I’m a DB engineer working for Yahoo, and we have a new product using django that I’m onboarding. We see a variety of easily fixed issues, but one major one - there are 21 many-many tables here, yet they have auto increment primary keys
-- Example, existing:
CREATE TABLE `accounts_profile_starred_groups` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`profile_id` int(10) unsigned NOT NULL,
`group_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `profile_id` (`profile_id`,`group_id`),
KEY `group_id_refs_id_e2f1545` (`group_id`)
) ENGINE=InnoDB;
-- Fixed:
CREATE TABLE `accounts_profile_starred_groups` (
`profile_id` int(10) unsigned NOT NULL,
`group_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`profile_id`,`group_id`),
KEY `group_id_refs_id_e2f1545` (`group_id`)
) ENGINE=InnoDB;
Looking forward to see how it goes !
Read MoreSounds pretty cool if you ask me. Check out this fine free DNS management service.
Here’s a really cool contribution. Harry Percival emailed django-developers about his employer, PythonAnywhere:
We do offer Django hosting as part of our Free plan, so it’s a nice place for people to come and try out Django, for free, maybe host a prototype web app…
I registered to give it a tried and received an amazing welcome email, which I won’t spoil for you !
This is the second article about reversing urls in javascript. The previous article actually presented a bad idea.
Github’s API is undubitably quite suprising for a web developer that isn’t aware of the HATEOAS concept, here’s the kind of things you can see for example:
[
{
"updated_at": "2012-11-27T14:42:24Z",
"svn_url": "https://github.com/yourlabs/django-cities-light",
"language": "Python",
"milestones_url": "https://api.github.com/repos/yourlabs/django-cities-light/milestones{/number}",
"downloads_url": "https://api.github.com/repos/yourlabs/django-cities-light/downloads",
"subscription_url": "https://api.github.com/repos/yourlabs/django-cities-light/subscription",
"teams_url": "https://api.github.com/repos/yourlabs/django-cities-light/teams",
"full_name": "yourlabs/django-cities-light",
"git_url": "git://github.com/yourlabs/django-cities-light.git",
"git_tags_url": "https://api.github.com/repos/yourlabs/django-cities-light/git/tags{/sha}",
"owner": {
"login": "yourlabs",
"organizations_url": "https://api.github.com/users/yourlabs/orgs",
"followers_url": "https://api.github.com/users/yourlabs/followers",
"starred_url": "https://api.github.com/users/yourlabs/starred{/owner}{/repo}",
"following_url": "https://api.github.com/users/yourlabs/following",
"avatar_url": "https://secure.gravatar.com/avatar/c0efe8e5c15bd268224fbc40a574329d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png",
"repos_url": "https://api.github.com/users/yourlabs/repos",
"subscriptions_url": "https://api.github.com/users/yourlabs/subscriptions",
"url": "https://api.github.com/users/yourlabs",
"events_url": "https://api.github.com/users/yourlabs/events{/privacy}",
"gravatar_id": "c0efe8e5c15bd268224fbc40a574329d",
"received_events_url": "https://api.github.com/users/yourlabs/received_events",
"id": 1040547,
"gists_url": "https://api.github.com/users/yourlabs/gists{/gist_id}"
},
Wow, so many URLs… At first, this may look original, if not excentric. Why aren’t they just documented ?
Read MoreKeeping your inbox clean can be quite a pain. Except with keyboard shortcuts.
?
shows the list of shortcuts,/
to search mails,c
to compose a message,gi
brings you to the inbox,j
and k
moves the little blue cursor between threads,x
selects the thread that has the blue cursor,e
archives selected threads,o
opens selected threada
is for reply to all,r
is for reply.That’s it !
Read More