code
stringlengths
1
1.72M
language
stringclasses
1 value
"""TLS Lite + httplib.""" import socket import httplib from gdata.tlslite.TLSConnection import TLSConnection from gdata.tlslite.integration.ClientHelper import ClientHelper class HTTPBaseTLSConnection(httplib.HTTPConnection): """This abstract class provides a framework for adding TLS support to httplib.""" ...
Python
"""TLS Lite + smtplib.""" from smtplib import SMTP from gdata.tlslite.TLSConnection import TLSConnection from gdata.tlslite.integration.ClientHelper import ClientHelper class SMTP_TLS(SMTP): """This class extends L{smtplib.SMTP} with TLS support.""" def starttls(self, username=None, password...
Python
"""TLS Lite + asyncore.""" import asyncore from gdata.tlslite.TLSConnection import TLSConnection from AsyncStateMachine import AsyncStateMachine class TLSAsyncDispatcherMixIn(AsyncStateMachine): """This class can be "mixed in" with an L{asyncore.dispatcher} to add TLS support. This class es...
Python
class IntegrationHelper: def __init__(self, username=None, password=None, sharedKey=None, certChain=None, privateKey=None, cryptoID=None, protocol=None, x509Fingerprint=None, x509TrustList=None, x509CommonName=None, setti...
Python
"""Classes for integrating TLS Lite with other packages.""" __all__ = ["AsyncStateMachine", "HTTPTLSConnection", "POP3_TLS", "IMAP4_TLS", "SMTP_TLS", "XMLRPCTransport", "TLSSocketServerMixIn", "TLSAsyncDispatcherMixIn", "TLSTwisted...
Python
"""TLS Lite + xmlrpclib.""" import xmlrpclib import httplib from gdata.tlslite.integration.HTTPTLSConnection import HTTPTLSConnection from gdata.tlslite.integration.ClientHelper import ClientHelper class XMLRPCTransport(xmlrpclib.Transport, ClientHelper): """Handles an HTTPS transaction to an XML-RPC server.""" ...
Python
""" A state machine for using TLS Lite with asynchronous I/O. """ class AsyncStateMachine: """ This is an abstract class that's used to integrate TLS Lite with asyncore and Twisted. This class signals wantsReadsEvent() and wantsWriteEvent(). When the underlying socket has become readabl...
Python
"""Class for post-handshake certificate checking.""" from utils.cryptomath import hashAndBase64 from X509 import X509 from X509CertChain import X509CertChain from errors import * class Checker: """This class is passed to a handshake function to check the other party's certificate chain. If a handshake f...
Python
"""Class for storing SRP password verifiers.""" from utils.cryptomath import * from utils.compat import * import mathtls from BaseDB import BaseDB class VerifierDB(BaseDB): """This class represent an in-memory or on-disk database of SRP password verifiers. A VerifierDB can be passed to a server handshake...
Python
"""OpenSSL/M2Crypto 3DES implementation.""" from cryptomath import * from TripleDES import * if m2cryptoLoaded: def new(key, mode, IV): return OpenSSL_TripleDES(key, mode, IV) class OpenSSL_TripleDES(TripleDES): def __init__(self, key, mode, IV): TripleDES.__init__(self, key, mo...
Python
"""PyCrypto RC4 implementation.""" from cryptomath import * from RC4 import * if pycryptoLoaded: import Crypto.Cipher.ARC4 def new(key): return PyCrypto_RC4(key) class PyCrypto_RC4(RC4): def __init__(self, key): RC4.__init__(self, key, "pycrypto") self.context = ...
Python
"""OpenSSL/M2Crypto RSA implementation.""" from cryptomath import * from RSAKey import * from Python_RSAKey import Python_RSAKey #copied from M2Crypto.util.py, so when we load the local copy of m2 #we can still use it def password_callback(v, prompt1='Enter private key passphrase:', prompt...
Python
"""Helper functions for XML. This module has misc. helper functions for working with XML DOM nodes.""" import re from compat import * import os if os.name != "java": from xml.dom import minidom from xml.sax import saxutils def parseDocument(s): return minidom.parseString(s) else: from javax....
Python
"""Factory functions for asymmetric cryptography. @sort: generateRSAKey, parseXMLKey, parsePEMKey, parseAsPublicKey, parseAsPrivateKey """ from compat import * from RSAKey import RSAKey from Python_RSAKey import Python_RSAKey import cryptomath if cryptomath.m2cryptoLoaded: from OpenSSL_RSAKey import OpenSSL_RSAK...
Python
import os #Functions for manipulating datetime objects #CCYY-MM-DDThh:mm:ssZ def parseDateClass(s): year, month, day = s.split("-") day, tail = day[:2], day[2:] hour, minute, second = tail[1:].split(":") second = second[:2] year, month, day = int(year), int(month), int(day) hour, minute, secon...
Python
"""Miscellaneous functions to mask Python version differences.""" import sys import os if sys.version_info < (2,2): raise AssertionError("Python 2.2 or later required") if sys.version_info < (2,3): def enumerate(collection): return zip(range(len(collection)), collection) class Set: def ...
Python
"""Pure-Python RC4 implementation.""" from RC4 import RC4 from cryptomath import * def new(key): return Python_RC4(key) class Python_RC4(RC4): def __init__(self, key): RC4.__init__(self, key, "python") keyBytes = stringToBytes(key) S = [i for i in range(256)] j = 0 for...
Python
"""OpenSSL/M2Crypto RC4 implementation.""" from cryptomath import * from RC4 import RC4 if m2cryptoLoaded: def new(key): return OpenSSL_RC4(key) class OpenSSL_RC4(RC4): def __init__(self, key): RC4.__init__(self, key, "openssl") self.rc4 = m2.rc4_new() m2...
Python
"""Class for parsing ASN.1""" from compat import * from codec import * #Takes a byte array which has a DER TLV field at its head class ASN1Parser: def __init__(self, bytes): p = Parser(bytes) p.get(1) #skip Type #Get Length self.length = self._getASN1Length(p) #Get Value ...
Python
"""HMAC (Keyed-Hashing for Message Authentication) Python module. Implements the HMAC algorithm as described by RFC 2104. (This file is modified from the standard library version to do faster copying) """ def _strxor(s1, s2): """Utility method. XOR the two strings s1 and s2 (must have same length). """ r...
Python
"""OpenSSL/M2Crypto AES implementation.""" from cryptomath import * from AES import * if m2cryptoLoaded: def new(key, mode, IV): return OpenSSL_AES(key, mode, IV) class OpenSSL_AES(AES): def __init__(self, key, mode, IV): AES.__init__(self, key, mode, IV, "openssl") ...
Python
"""cryptomath module This module has basic math/crypto code.""" import os import sys import math import base64 import binascii if sys.version_info[:2] <= (2, 4): from sha import sha as sha1 else: from hashlib import sha1 from compat import * # *******************************************************************...
Python
"""Abstract class for AES.""" class AES: def __init__(self, key, mode, IV, implementation): if len(key) not in (16, 24, 32): raise AssertionError() if mode != 2: raise AssertionError() if len(IV) != 16: raise AssertionError() self.isBlockCipher = ...
Python
""" A pure python (slow) implementation of rijndael with a decent interface To include - from rijndael import rijndael To do a key setup - r = rijndael(key, block_size = 16) key must be a string of length 16, 24, or 32 blocksize must be 16, 24, or 32. Default is 16 To use - ciphertext = r.encrypt(plaintext) plai...
Python
"""Cryptlib 3DES implementation.""" from cryptomath import * from TripleDES import * if cryptlibpyLoaded: def new(key, mode, IV): return Cryptlib_TripleDES(key, mode, IV) class Cryptlib_TripleDES(TripleDES): def __init__(self, key, mode, IV): TripleDES.__init__(self, key, mode,...
Python
"""Abstract class for RC4.""" from compat import * #For False class RC4: def __init__(self, keyBytes, implementation): if len(keyBytes) < 16 or len(keyBytes) > 256: raise ValueError() self.isBlockCipher = False self.name = "rc4" self.implementation = implementation ...
Python
"""PyCrypto RSA implementation.""" from cryptomath import * from RSAKey import * from Python_RSAKey import Python_RSAKey if pycryptoLoaded: from Crypto.PublicKey import RSA class PyCrypto_RSAKey(RSAKey): def __init__(self, n=0, e=0, d=0, p=0, q=0, dP=0, dQ=0, qInv=0): if not d: ...
Python
"""PyCrypto AES implementation.""" from cryptomath import * from AES import * if pycryptoLoaded: import Crypto.Cipher.AES def new(key, mode, IV): return PyCrypto_AES(key, mode, IV) class PyCrypto_AES(AES): def __init__(self, key, mode, IV): AES.__init__(self, key, mode, IV, ...
Python
"""Abstract class for 3DES.""" from compat import * #For True class TripleDES: def __init__(self, key, mode, IV, implementation): if len(key) != 24: raise ValueError() if mode != 2: raise ValueError() if len(IV) != 8: raise ValueError() self.isBl...
Python
"""Cryptlib RC4 implementation.""" from cryptomath import * from RC4 import RC4 if cryptlibpyLoaded: def new(key): return Cryptlib_RC4(key) class Cryptlib_RC4(RC4): def __init__(self, key): RC4.__init__(self, key, "cryptlib") self.context = cryptlib_py.cryptCreateCon...
Python
"""Abstract class for RSA.""" from cryptomath import * class RSAKey: """This is an abstract base class for RSA keys. Particular implementations of RSA keys, such as L{OpenSSL_RSAKey.OpenSSL_RSAKey}, L{Python_RSAKey.Python_RSAKey}, and L{PyCrypto_RSAKey.PyCrypto_RSAKey}, inherit from this. ...
Python
"""Miscellaneous functions to mask Python/Jython differences.""" import os import sha if os.name != "java": BaseException = Exception from sets import Set import array import math def createByteArraySequence(seq): return array.array('B', seq) def createByteArrayZeros(howMany): ...
Python
"""Pure-Python AES implementation.""" from cryptomath import * from AES import * from rijndael import rijndael def new(key, mode, IV): return Python_AES(key, mode, IV) class Python_AES(AES): def __init__(self, key, mode, IV): AES.__init__(self, key, mode, IV, "python") self.rijndael = rijnda...
Python
"""Toolkit for crypto and other stuff.""" __all__ = ["AES", "ASN1Parser", "cipherfactory", "codec", "Cryptlib_AES", "Cryptlib_RC4", "Cryptlib_TripleDES", "cryptomath: cryptomath module", "dateFuncs", "hmac", "...
Python
"""Pure-Python RSA implementation.""" from cryptomath import * import xmltools from ASN1Parser import ASN1Parser from RSAKey import * class Python_RSAKey(RSAKey): def __init__(self, n=0, e=0, d=0, p=0, q=0, dP=0, dQ=0, qInv=0): if (n and not e) or (e and not n): raise AssertionError() ...
Python
"""Cryptlib AES implementation.""" from cryptomath import * from AES import * if cryptlibpyLoaded: def new(key, mode, IV): return Cryptlib_AES(key, mode, IV) class Cryptlib_AES(AES): def __init__(self, key, mode, IV): AES.__init__(self, key, mode, IV, "cryptlib") sel...
Python
"""Factory functions for symmetric cryptography.""" import os import Python_AES import Python_RC4 import cryptomath tripleDESPresent = False if cryptomath.m2cryptoLoaded: import OpenSSL_AES import OpenSSL_RC4 import OpenSSL_TripleDES tripleDESPresent = True if cryptomath.cryptlibpyLoaded: impo...
Python
"""PyCrypto 3DES implementation.""" from cryptomath import * from TripleDES import * if pycryptoLoaded: import Crypto.Cipher.DES3 def new(key, mode, IV): return PyCrypto_TripleDES(key, mode, IV) class PyCrypto_TripleDES(TripleDES): def __init__(self, key, mode, IV): TripleDE...
Python
"""Classes for reading/writing binary data (such as TLS records).""" from compat import * class Writer: def __init__(self, length=0): #If length is zero, then this is just a "trial run" to determine length self.index = 0 self.bytes = createByteArrayZeros(length) def add(self, x, lengt...
Python
"""Classes representing TLS messages.""" from utils.compat import * from utils.cryptomath import * from errors import * from utils.codec import * from constants import * from X509 import X509 from X509CertChain import X509CertChain import sha import md5 class RecordHeader3: def __init__(self): self.type ...
Python
"""Constants used in various places.""" class CertificateType: x509 = 0 openpgp = 1 cryptoID = 2 class HandshakeType: hello_request = 0 client_hello = 1 server_hello = 2 certificate = 11 server_key_exchange = 12 certificate_request = 13 server_hello_done = 14 certificate_ve...
Python
"""Class for storing shared keys.""" from utils.cryptomath import * from utils.compat import * from mathtls import * from Session import Session from BaseDB import BaseDB class SharedKeyDB(BaseDB): """This class represent an in-memory or on-disk database of shared keys. A SharedKeyDB can be passed to a s...
Python
"""Class for setting handshake parameters.""" from constants import CertificateType from utils import cryptomath from utils import cipherfactory class HandshakeSettings: """This class encapsulates various parameters that can be used with a TLS handshake. @sort: minKeySize, maxKeySize, cipherNames, certifi...
Python
"""Class for caching TLS sessions.""" import thread import time class SessionCache: """This class is used by the server to cache TLS sessions. Caching sessions allows the client to use TLS session resumption and avoid the expense of a full handshake. To use this class, simply pass a SessionCache ins...
Python
"""Class representing a TLS session.""" from utils.compat import * from mathtls import * from constants import * class Session: """ This class represents a TLS session. TLS distinguishes between connections and sessions. A new handshake creates both a connection and a session. Data is transmitt...
Python
"""Base class for SharedKeyDB and VerifierDB.""" import anydbm import thread class BaseDB: def __init__(self, filename, type): self.type = type self.filename = filename if self.filename: self.db = None else: self.db = {} self.lock = thre...
Python
"""Exception classes. @sort: TLSError, TLSAbruptCloseError, TLSAlert, TLSLocalAlert, TLSRemoteAlert, TLSAuthenticationError, TLSNoAuthenticationError, TLSAuthenticationTypeError, TLSFingerprintError, TLSAuthorizationError, TLSValidationError, TLSFaultError """ from constants import AlertDescription, AlertLevel class ...
Python
""" TLS Lite is a free python library that implements SSL v3, TLS v1, and TLS v1.1. TLS Lite supports non-traditional authentication methods such as SRP, shared keys, and cryptoIDs, in addition to X.509 certificates. TLS Lite is pure python, however it can access OpenSSL, cryptlib, pycrypto, and GMPY for faster crypt...
Python
"""Class representing an X.509 certificate chain.""" from utils import cryptomath class X509CertChain: """This class represents a chain of X.509 certificates. @type x509List: list @ivar x509List: A list of L{tlslite.X509.X509} instances, starting with the end-entity certificate and with ever...
Python
"""Import this module for easy access to TLS Lite objects. The TLS Lite API consists of classes, functions, and variables spread throughout this package. Instead of importing them individually with:: from tlslite.TLSConnection import TLSConnection from tlslite.HandshakeSettings import HandshakeSettings f...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Manage videos on YouTube. ''' import StringIO import gdata.photos.service from storage import Provider from storage import ProviderSetting # default developer key registered by dev@expressme.org, # but you can als...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)'
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)'
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Upload photo to google picasaweb service. ''' import StringIO import gdata.photos.service from storage import Provider from storage import ProviderSetting class PhotoProvider(Provider): name = 'Google PicasaWeb...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)'
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Storage providers. ''' import os import re def find_photo_modules(): from storage import photo as pkg return __find_modules(pkg) def find_file_modules(): from storage import file as pkg return __fin...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' import os import unittest # import gaeunit to initialize GAE test environment: import framework.gaeunit def _search_tests(path, package, depth): all = os.listdir(path) prefix = package if packa...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' from datetime import datetime import unittest import siteconfig class Test(unittest.TestCase): def test_date_format_samples(self): dt = datetime(2008, 2, 21) self.assertEquals([ ...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Forum app model. ''' from google.appengine.ext import db from framework import store class Forum(store.BaseModel): pass class ForumTopic(store.BaseModel): user = db.StringProperty(required=True) forum ...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Forum app that allows users to discuss. '''
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' build.py - count lines of code - pre-compile all views for speed - make package (.zip) file for publish. ''' import re import os from framework import view PACKAGE_EXCLUDES = ( r'^.*...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Global interceptor for ExpressMe application. ''' from manage import cookie from framework import store def _detect_current_user(kw): kw['current_user'] = None ctx = kw['context'] auto_sig...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Utils for integration test. ''' import os import random def dummy_title(word_list, word_count): ''' Generate dummy title. ''' L = [] MAX = len(word_list) - 1 r = int(word_count * 0.2) wor...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)'
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' ExpressMe web application entry point: mapping to r'^/.*$'. ''' from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from framework.web import Dispatcher application = w...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2009 Frederico Caldeira Knabben * * == BEGIN LICENSE == * * Licensed under the terms of any of the following licenses at your * choice: * * - GNU General Public License Version 2 or l...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") h...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python """ FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2009 Frederico Caldeira Knabben == BEGIN LICENSE == Licensed under the terms of any of the following licenses at your choice: - GNU General Public License Version 2 or later (the "GPL") http:...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' ExpressMe version definition. ''' major_version = 1 minor_version = 0 def get_version(): ''' Get current version as string ''' return '%d.%d' % (major_version, minor_version)
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' App interceptor ''' def intercept(kw): pass
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)'
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Handle index page '/'. ''' from framework.web import get from blog import controller as blog_controller from blog import model as blog_model @get('/') def index(**kw): ''' show recent posts...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __title__ = 'Default' __designer__ = 'Michael Liao (askxuefeng@gmail.com)' __description__ = 'A simple, clear theme as default theme for ExpressMe.' __url__ = 'http://www.expressme.org/' __sidebars__ = 2
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __title__ = 'Blue Max' __designer__ = 'Michael Liao (askxuefeng@gmail.com)' __description__ = 'A Blue Max theme provided by Blue Sky' __url__ = 'http://www.expressme.org/' __sidebars__ = 2
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Theme for apps. ''' import os import logging from framework import view import navigation import siteconfig import runtime def get_themes(use_cache=True): ''' Get all themes' logic names....
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Theme app management. ''' import logging from framework import store from manage import AppMenu from manage import AppMenuItem import theme def get_menus(): ''' Get menus for management. ''' theme...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Core app. ''' DEPRECATED = True import os from manage import shared @post('/upload/$') def upload(type): if context.user is None: raise HttpForbiddenError() # get photo service: provider = shar...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Manage cookie for auto-signin. ''' import time import base64 import hashlib AUTO_SIGNIN_COOKIE = 'auto_signin' IS_FROM_GOOGLE_COOKIE = 'is_from_google' def make_sign_in_cookie(key, passwd, expire_in...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' shared.py all shared db model and related functions. ''' __author__ = 'Michael Liao (askxuefeng@gmail.com)' from google.appengine.ext import db from exweb import context class AppMenu(object): ''' A menu object displayed in management cons...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Model for manage app. ''' import random import hashlib from datetime import datetime from datetime import timedelta from google.appengine.ext import db from framework import store TOKEN_EXPIRED_TIMEDELTA = timedelt...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' Deprecated = True ''' app management for User, global settings. ''' from manage import shared import manage import appconfig def __handle_get_theme(): ''' Display all themes under dir '/theme' ''' theme...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' App interceptor ''' def intercept(kw): pass
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' import unittest from datetime import datetime from datetime import timedelta from framework import gaeunit from manage import model class Test(gaeunit.GaeTestCase): def test_gen_token(self): ...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' class AppMenu(object): ''' A menu object displayed in management console. ''' def __init__(self, title, *menu_items): self.title = title self.items = [] self.items.extend(menu_items...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' app management for user, global settings. ''' import datetime import appconfig import navigation import siteconfig from framework import store from manage import AppMenu from manage import AppMenuItem import runt...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Manage app that supports: signin: both local (email and password), Google account and OpenID login. register: register a local user. manage: manage all things of site. ''' import logging import url...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Photo app that display public photos from picasa, flickr or other sites. ''' __author__ = 'Michael Liao (askxuefeng@gmail.com)'
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- DEPRECATED = True __author__ = 'Michael Liao (askxuefeng@gmail.com)' from google.appengine.ext import db class BlogPostMeta(db.Model): 'meta info for BlogPost' meta_key = db.StringProperty(required=True) meta_values = db.StringListProperty() d...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' from google.appengine.ext import db from framework import store from framework import ApplicationError # post state constants: POST_PUBLISHED = 0 POST_PENDING = 1 POST_DRAFT = 2 POST_DELETED = 3 CATEG...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' App interceptor ''' def intercept(kw): pass
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' import time import unittest from framework.gaeunit import GaeTestCase from framework import store from blog import model def _create_user(): return store.create_user(store.ROLE_ADMINISTRATOR, 'test@emai...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' App "blog" that supports publishing posts and pages. ''' GROUP_OPTIONS = 'blog.post.options' FEED_TITLE = 'feed_title' FEED_PROXY = 'feed_proxy' FEED_ITEMS = 'feed_items' SHOW_ABSTRACT = 'show_abstract' def update_...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Blog app management. ''' import logging from framework import ApplicationError from framework import store from framework.encode import encode_html import blog from blog import model from manage import AppMenu fro...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Michael Liao (askxuefeng@gmail.com)' ''' Blog app that display blog posts. ''' from framework.web import NotFoundError from framework.web import get from framework.web import post from framework import store import blog from blog import model def get_fee...
Python