Skip to content

Instantly share code, notes, and snippets.

View nandoflorestan's full-sized avatar

Nando Florestan nandoflorestan

View GitHub Profile
@uris77
uris77 / repo_pattern.py
Last active May 8, 2024 14:20
Example of Repository Pattern with SQLAlchemy
# This is a very crud example of using the Repository Pattern with SQLAlchemy. It allows me to completely ignore interactions with
# the database. This is only pulled in whenever I require to persist or retrieve an object from the database. The domain/business
# logic is entirely separated from persistence and I can have true unit tests for those.
# The tests for persistence are then limited to very specific cases of persistence and retrieving instances, and I can do those
# independent of the business logic. They also tend to be less tests since I only need to test them once.
iff --git a/django/template/__init__.py b/django/template/__init__.py
index 8c89c67..576e7b1 100644
--- a/django/template/__init__.py
+++ b/django/template/__init__.py
@@ -839,6 +839,14 @@ class VariableNode(Node):
def __repr__(self):
return "<Variable Node: %s>" % self.filter_expression
+ def clean_pks(self, output):
+ # avoid localization of pk or ids
@ericrasmussen
ericrasmussen / formgenerator.py
Created February 9, 2012 00:02
FormGenerator to extend Deform functionality
"""
Simple module to ease form handling with ``Deform``. The provided
``FormGenerator`` class handles repetitive tasks like validation,
xhr requests, and recovering from exceptions thrown by the model.
### Begin example scenario: Adding a new user
from myschemas import UserSchema
from formgenerator import (
@reedobrien
reedobrien / recaptcha.py
Created November 16, 2010 04:57
Deform Recaptcha Widget
## widget
import httplib2
from urllib import urlencode
import colander
from colander import null
from colander import Invalid
from deform.widget import CheckedInputWidget