- A ton of Mixins look really reusable, but do we really need all of them (or any of them).
- Does is makes sense to have ProcessFormView and DisplayFormView ? Maybe this should be one view (having both functions is the common case) and people can prevent display/process by subclassing.
- Most view's MRO looks like this: FooBarView, MixinA, MixinB, ..., TemplateMixin, View. If I wanted an almost exactly same view, but a one that uses diffrent template system (or a JSON serializer), I have to either create
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
# Klient FTP | |
# Napisany przez Sherifa, na licencji Open Source | |
# importuje biblioteke | |
import ftplib | |
# Chyba widac... | |
print "=======================\n" | |
print "====== FTP Klient =====\n" | |
print "=======================\n" |
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 ConfigParser import RawConfigParser, NoOptionError | |
class SectionProxy(object): | |
__slots__ = ('_section_name', '_config') | |
def __init__(self, config, section_name): | |
self._section_name = section_name | |
self._config = config | |
def __getattr__(self, name): |
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 ConfigParser import RawConfigParser, NoOptionError | |
class SectionProxy(object): | |
__slots__ = ('_section_name', '_config') | |
def __init__(self, config, section_name): | |
self._section_name = section_name | |
self._config = config | |
def __getattr__(self, name): |
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 Base(object): | |
def foo(self): | |
return "foo" | |
class FaultyClass(Base): | |
def foo(self): | |
return "faulty-" + Base.foo(self) |
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
@login_required | |
def personal_items(request, **kwargs): | |
qs = kwargs['queryset'] | |
qs = qs.filter(author=request.user) | |
# i inne filtry... | |
kwargs['queryset'] = qs | |
return django.views.generic.list_detail.object_list(request, **kwargs) | |
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
# -*- coding: utf-8 | |
hrum = True # "hrum" to niezbyt dobra nazwa zmiennej | |
while hrum: | |
try: | |
option = int(raw_input("Menu:\n0.Zakoncz\n1.Sciagniecie witryny przez http\n2.Sciagniecie pliku\n3.Pobranie pliku z ftp\n")) | |
except ValueError: | |
continue | |
if option == 0: |
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
def decorator_with_kwargs(decorator): | |
""" | |
There are many techniques to produce decorators that can be used with | |
arguments and without them. Accepting only keyword arguments is the simples, IMHO. | |
>>> def execution_decorator(view, opts): | |
... return view(**opts) | |
... | |
>>> def format_kwargs(**kwargs): | |
... return "ARGS: %r" % kwargs |
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 django.conf import settings | |
from functools import wraps | |
class _s: | |
def __init__(self, a=10, b=None): | |
self.a, self.b = a,b | |
def _override_settings(overrides): | |
_orig = {} | |
_missing = [] |
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 A(object): | |
def method(self): | |
return "A" | |
class B(A): | |
def method(self): | |
return "B" + super(B, self).method() | |
class C(B): | |
pass |