Skip to content

Instantly share code, notes, and snippets.

View jedie's full-sized avatar

Jens Diemer jedie

View GitHub Profile
#!/usr/bin/env python
# coding: utf-8
"""
based in http://www.djangosnippets.org/snippets/1044/
"""
import os
BASE_PATH = os.path.abspath(os.path.dirname(__file__))
#!/usr/bin/env python
# coding: utf-8
"""
based in http://www.djangosnippets.org/snippets/1044/
"""
import os
BASE_PATH = os.path.abspath(os.path.dirname(__file__))
# source line:
"""
"supplier" ManyToManyField:
new, would be renamed supplier -> not new anymore supplier
= always the same supplier
"""
# would be changed to:
"""
...
posts = query.order_by(order)
if 'topics' in request.GET['show_as']:
print posts.count() # This is very fast
# seems to be qual what using here to get all pk:
print "this is slow 1:"
@jedie
jedie / search1.diff
Created August 7, 2012 14:57
DjangoBB seatch patch
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0ab606f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,13 @@
+*.py[co]
+*.egg-info
+.pydevproject
+.project
diff --git a/djangobb_forum/views.py b/djangobb_forum/views.py
index c1772f3..8981d4b 100644
--- a/djangobb_forum/views.py
+++ b/djangobb_forum/views.py
@@ -166,7 +166,8 @@ def search(request):
base_url = "?action=show_user&user_id=%s&show_as=" % user_id
if not show_as_posts:
# show as topic
- # FIXME: This should be speed up. This is not lazy:
+ # FIXME: This should be speed up. Same problem as below.
import time
class SmoothCacheTime(int):
def __new__(cls, value=None):
if value is None:
value = time.time()
i = int.__new__(cls, value)
return i
i = SmoothCacheTime()
#!/usr/bin/env python
# coding: utf-8
"""
http://wiki.python-forum.de/Plattform%20unterscheiden
"""
import os
import sys
import platform
def test_clean_bbcode3(self):
post = Post.objects.create(
text=(
u'test äöüß'
),
bbcode_uid="1234abcd",
bbcode_bitfield="foo",
)
self.assertEqual(post.get_cleaned_bbcode(),
u'test äöüß'
def test_clean_bbcode4(self):
post = Post.objects.create(
text=(
'test äöüß [url=https://github.com/jedie/PyLucid/views.py:1234abcd]/views.py[/url:1234abcd]'
),
bbcode_uid="1234abcd",
bbcode_bitfield="foo",
)
self.assertEqual(post.get_cleaned_bbcode(),
'test äöüß [url=https://github.com/jedie/PyLucid/views.py]/views.py[/url]'