This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TimeoutContext(object): | |
u""" | |
Контекст устанавливающий таймаут на операции с сокетами | |
>>> with TimeoutContext(14.88): | |
... urlopen('http://google.com').read() | |
Traceback (most recent call last) | |
... | |
timeout: timed out | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
threads = self.get_queryset().order_by('-update_time') | |
thread_container = [] | |
for thread in threads: | |
posts = thread.posts.all()[:3] | |
item = dict(thread=thread, posts=posts) | |
thread_container.append(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseBoardClass(ListView): | |
model = models.Board | |
def get_context_data(self, board_name): | |
context = super(BaseBoardClass,self).get_context_data(**kwargs) | |
board = get_object_or_404(models.Board.objects,name=board_name) if board_name or None | |
context['board'] = bord | |
return context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scrapy.contrib.loader.processor import Compose | |
from operator import itemgetter | |
Compose(itemgetter(0))('a') | |
... | |
RuntimeError: maximum recursion depth exceeded while calling a Python object |