New Blog
So, I won't be posting here again, but that's OK because I stopped posting anyway. I have a new blog at jouire.com these days, so update your feed readers and bookmarks accordingly.
'import site' failed; use -v for traceback
site-packages
directory that's screwing up Python's import path initialisation and could lead to you being unable to import some installed modules.pdb
:> python -v
>>> import pdb
>>> pdb.pm()
> [python_lib_path]/posixpath.py(173)exists()
-> return False
(Pdb) u
> [python_lib_path]site.py(146)addpackage()
-> f.close()
(Pdb) f
<closed file '[site-packages]._blah.pth', mode 'rU' at 0x52c38>
Your actual output will be quite a bit different with a lot of debugging information spewed into the console but let's explain what's going on here:import pdb
pm
(postmortem) function to enter the (Pdb)
shell and inspect the exact point at which the error occured.u
.f
file object.._blah.pth
is causing Python's site import routine to choke. [bug report]site-packages
and try again, repeating the steps above if you get the same error.PYTHONPATH
environment variable, looking for .pth
files. These can contain further directories to be added to the import path and are typically created by python packaging systems like easy_install
. [more info on .pth
files]blah.pth
).site-packages
directory and Python should be back to normal.
<select>
drop down in Safari 3.2.1.<div id="relative" style="position: relative;">
<div id="fixed" style="position: fixed; top: 0; left: 0;">
<select>
<option>Choose another option</option>
<option>Garbled</option>
</select>
</div>
</div>
The bug is triggered by javascript:// Set the fixed container's positioning to absolute
var element = document.getElementById('fixed');
element.style.position = 'absolute';
// Access its clientWidth or clientHeight properties
element.clientWidth;
element.clientHeight;
// Restore the positioning to its original value of fixed
element.style.position = 'fixed';
Element.getDimensions
method [source].Element.getDimensions
.Element.getDimensions
function.position: fixed
element and don't call Element.getDimensions
on it.Element.getDimensions
, there's a handy way to do that without altering the Prototype source code. Simply define your own version and then extend Element
with it by using Element.addMethods
. This will override the built in method.Element.addMethods({
getDimensions: function(element) {
// Your version in here
// ...
}
});
Element.getDimensions
, I forked Prototype on github with a fix for this issue:Element.getDimensions
Labels: browsers, bugs, css, javascript, safari
order_with_respect_to
that allows you to order objects within the scope of a related ForeignKey object._order
column to the model's database table to keep track of this ordering.get_RELATED_order()
set_RELATED_order()
RELATED
is the lowercased model name of the ordered objects
class Entry(model.Model):
# ... fields
class Comment(model.Model):
entry = model.ForeignKey(Entry, related_name='comments')
# ... more fields
class Meta:
order_with_respect_to = 'entry'
>>> entry = Entry.objects.latest()
>>> entry.get_comment_order()
[1, 2, 3, 4]
>>> entry.set_comment_order([2, 1, 4, 3])
get_comment_order
get_next_in_order
and get_previous_in_order
[3]
>>> comment = Comment.objects.get(pk=3)
>>> comment.get_next_in_order()
<Comment: 4>
>>> comment.get_previous_in_order()
<Comment: 2>
method_set_order
and method_get_order
in django.db.models.base
. backget_previous_in_order
but it should be fixed soon. Update: Fixed by the queryset-refactor backLabels: livebus