Skip to content

Instantly share code, notes, and snippets.

View xqliu's full-sized avatar

Lawrence Liu xqliu

  • Liu Xiangqian
  • Singapore
  • X @xqliu
View GitHub Profile

Flask-SQLAlchemy Caching

The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.

Usage

retrieve one object

# pulling one User object

user = User.query.get(1)

ModelView
---------
# field1 (->Model1), field2 (->Model2) filtered by field1 values
column_filter_by = ('field2')
form_widget_args = {
'field2': {
'data-filter-by': 'field1',
}
}
@xqliu
xqliu / test.py
Created April 15, 2017 17:01 — forked from mrjoes/test.py
How to customize options in QuerySelectField. High level idea: 1. Hook `create_form` to change options when creating model and `edit_form` when editing model 2. Provide different `query_factory` for the field 3. Do filtering/population logic in the _get_parent_list Alternatively: 1. Can hook `scaffold_form` and change `form.parent.kwargs['query_…
from flask import Flask, request, url_for
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.admin.contrib import sqlamodel
from flask.ext import admin
# Create application
app = Flask(__name__)
# Create dummy secrey key so we can use sessions
Serial Keys:
FU512-2DG1H-M85QZ-U7Z5T-PY8ZD
CU3MA-2LG1N-48EGQ-9GNGZ-QG0UD
GV7N2-DQZ00-4897Y-27ZNX-NV0TD
YZ718-4REEQ-08DHQ-JNYQC-ZQRD0
GZ3N0-6CX0L-H80UP-FPM59-NKAD4
YY31H-6EYEJ-480VZ-VXXZC-QF2E0
ZG51K-25FE1-H81ZP-95XGT-WV2C0
VG30H-2AX11-H88FQ-CQXGZ-M6AY4
@xqliu
xqliu / migrate-jira-to-github-issues.groovy
Created October 6, 2021 07:14 — forked from graemerocher/migrate-jira-to-github-issues.groovy
JIRA to Github Issues Migration Script
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='1.1.0')
@Grab(group='joda-time', module='joda-time', version='2.7')
import wslite.rest.*
import org.joda.time.*
import org.joda.time.format.*
import groovy.xml.*
import groovy.json.*
import static java.lang.System.*
import groovy.transform.*
@xqliu
xqliu / generate_complete_docs.py
Last active October 1, 2024 00:52
Python Script to Preprocess VuePress Document
import os
import argparse
import re
import shutil
import logging
import textwrap
# Define regex patterns for content references
CONTENT_SLOT_PATTERN = re.compile(r'<Content\s+slot-key="(.*?)".*?/>')
CONTENT_PAGE_SLOT_PATTERN = re.compile(r'<Content\s+:page-key="getPageKey\(\$site\.pages,\s*\'(.*?)\'\)"\s+slot-key="(.*?)".*?/>')