Skip to content

Instantly share code, notes, and snippets.

View Michae1Weiss's full-sized avatar

Mykhailo B Michae1Weiss

View GitHub Profile
@vytas7
vytas7 / multipart.rst
Last active May 10, 2022 11:20
Multipart form handling in Falcon proposal

multipart/form-data handling in Falcon proposal

Design philosophy

Multipart form handling should be performant, straightforward, and leave full control of the parsing process to the user, i.e. no surprising magic such as automatic creation of large files and saving anything there by default (although tools/helpers may exist to assist in that too).

@ketanbhatt
ketanbhatt / update.py
Last active October 19, 2023 12:20
Update with Last modified time Django auto_now fields
def update_with_last_modified_time(qs, **kwargs):
# This function adds any auto_now field to the update call because QuerySet.update() doesn't do it :X
model_fields = qs.model._meta.get_fields()
fields_and_value_map = {}
for field in model_fields:
try:
auto_now = field.__getattribute__('auto_now')
except AttributeError:
auto_now = False
@glenfant
glenfant / testwsgimock.py
Created February 3, 2017 09:19
How to create a temporary WSGI app suitable to unit tests mocking
# -*- coding: utf-8 -*-
# If you need to test a REST client, this is a Python 2 recipe that runs a
# simple WSGI app for your tests. Any improvement suggestion is welcome.
# Run this with "python -m unittest testingwsgi"
# Put this in a testing resources module, say tests/resources.py
import os