Skip to content

Instantly share code, notes, and snippets.

@moschlar
moschlar / index.py
Created November 23, 2012 15:01
Index page for comparing different JavaScript-based source code editor widgets
#!/usr/bin/env python
import tw2.core as twc
import tw2.forms as twf
import tw2.bootstrap.forms as twb
import tw2.devtools as twd
#https://github.com/moschlar/tw2.ace
import tw2.ace
#https://github.com/moschlar/tw2.codemirror
import tw2.codemirror
@moschlar
moschlar / test_quick.py
Created September 27, 2012 22:02
Badass speedup of simple tg site tests
# -*- coding: utf-8 -*-
"""
This test module will run setUp and tearDown only *once* for all test cases in this module.
This is very convenient for users who want to just test multiple urls whether they are reachable and respond with the correct http response code.
"""
import logging
log = logging.getLogger(__name__)
from os import path
<section id="extras" class="body">
% if 'blogroll' in conf:
<div class="blogroll">
<h2>blogroll</h2>
<ul>
% for name, link, tooltip in conf.blogroll:
% if not link:
<li><p>${ name or '&nbsp;' }</p></li>
% else:
<li><a href="${ link or '#' }" rel="external" title="${ tooltip or '' }">${ name or '&nbsp;' }</a></li>
@moschlar
moschlar / types.py
Created August 14, 2012 08:49
Get file mime type with python-magic
#!/usr/bin/env python2
import os, sys
from magic import Magic
from collections import defaultdict
from itertools import groupby
from pprint import pprint
m = Magic(mime=True)
me = Magic(mime_encoding=True)
@moschlar
moschlar / test_site.py
Created June 14, 2012 14:34
Test multiple sites
from sauce.tests import TestController
__all__ = ['TestSite']
class TestSite(TestController):
sites = ['/', '/about', '/contact']
def _do_site(self, site):
response = self.app.get(site)
@moschlar
moschlar / widgets.py
Created June 5, 2012 13:44
ToscaWidgets 2 Bootstrap - CalendarDateTimePicker
class CalendarDateTimePicker(Bootstrap, twc.CompoundWidget):
resources = set(CalendarDatePicker.resources + CalendarTimePicker.resources)
date = CalendarDatePicker()
time = CalendarTimePicker()
def _validate(self, value, state=None):
"""
Inner validation method; this is called by validate and should not be
called directly. Overriding this method in widgets is discouraged; a
custom validator should be coded instead. However, in some
@moschlar
moschlar / submission.py
Created May 30, 2012 16:59
A ToscaWidgets2 widget that needs a dynamic SelectField and does work :)
# -*- coding: utf-8 -*-
'''
Created on 17.03.2012
@author: moschlar
'''
import tw2.core as twc
import tw2.forms as twf
import tw2.bootstrap as twb
# -*- coding: utf-8 -*-
'''
Created on 17.03.2012
Ported to tw2 on 25.05.2012
@author: moschlar
'''
import tw2.core as twc
import tw2.forms as twf
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4
inherit eutils bash-completion-r1
DESCRIPTION="Git extensions to provide high-level repository operations for Vincent Driessen's branching model."
HOMEPAGE="https://github.com/nvie/gitflow"
# -*- coding: utf-8 -*-
'''
Created on 17.03.2012
Ported to tw2 on 25.05.2012
@author: moschlar
'''
import tw2.core as twc
import tw2.forms as twf