Kirill Simonov avatar Kirill Simonov committed 7de1a0b Merge

Merged.

Comments (0)

Files changed (33)

 .*.sw?
 *.egg-info
 *.env
+*.sqlite
 build
 vm-build
 external

demo/django/Makefile

-test: clean serve
-
-clean:
-	-rm -f htsql_demo.sqdb
-	rm -rf htsql_demo/*.pyc htsql_demo/uni/*.pyc
-
-htsql_demo.sqdb:
-	python htsql_demo/manage.py syncdb --noinput
-
-shell: htsql_demo.sqdb
-	htsql-ctl shell sqlite:htsql_demo.sqdb 
-
-serve: htsql_demo.sqdb
-	python serve.py

demo/django/README

-This is an example project for getting HTSQL to work under Django.
-
-This project uses ``twod.wsgi`` in order to run the HTSQL WSGI
-application under Django.  This module wraps Django's application
-object, so you can't use django's manager script.
Add a comment to this file

demo/django/htsql_demo/__init__.py

Empty file removed.

demo/django/htsql_demo/manage.py

-#!/usr/bin/env python
-from twod.wsgi import DjangoApplication
-from django.core.management import execute_manager
-try:
-    import settings # Assumed to be in the same directory.
-except ImportError:
-    import sys
-    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
-    sys.exit(1)
-
-if __name__ == "__main__":
-    execute_manager(settings)

demo/django/htsql_demo/settings.py

-# Django settings for htsql_demo project.
-
-DEBUG = True
-TEMPLATE_DEBUG = DEBUG
-
-ADMINS = (
-    # ('Your Name', 'your_email@domain.com'),
-)
-
-MANAGERS = ADMINS
-
-DATABASES = {
-    'default': {
-        'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': './htsql_demo.sqdb',
-        'USER': '',        
-        'PASSWORD': '',    
-        'HOST': '',        
-        'PORT': '',        
-    }
-}
-
-# Local time zone for this installation. Choices can be found here:
-# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
-# although not all choices may be available on all operating systems.
-# On Unix systems, a value of None will cause Django to use the same
-# timezone as the operating system.
-# If running in a Windows environment this must be set to the same as your
-# system time zone.
-TIME_ZONE = 'America/Chicago'
-
-# Language code for this installation. All choices can be found here:
-# http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = 'en-us'
-
-SITE_ID = 1
-
-# If you set this to False, Django will make some optimizations so as not
-# to load the internationalization machinery.
-USE_I18N = True
-
-# If you set this to False, Django will not format dates, numbers and
-# calendars according to the current locale
-USE_L10N = True
-
-# Absolute filesystem path to the directory that will hold user-uploaded files.
-# Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = ''
-
-# URL that handles the media served from MEDIA_ROOT. Make sure to use a
-# trailing slash if there is a path component (optional in other cases).
-# Examples: "http://media.lawrence.com", "http://example.com/media/"
-MEDIA_URL = ''
-
-# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
-# trailing slash.
-# Examples: "http://foo.com/media/", "/media/".
-ADMIN_MEDIA_PREFIX = '/media/'
-
-# Make this unique, and don't share it with anybody.
-SECRET_KEY = 'htsql_demo'
-
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
-    'django.template.loaders.filesystem.Loader',
-    'django.template.loaders.app_directories.Loader',
-#     'django.template.loaders.eggs.Loader',
-)
-
-MIDDLEWARE_CLASSES = (
-    'django.middleware.common.CommonMiddleware',
-    'django.contrib.sessions.middleware.SessionMiddleware',
-    'django.middleware.csrf.CsrfViewMiddleware',
-    'django.contrib.auth.middleware.AuthenticationMiddleware',
-    'django.contrib.messages.middleware.MessageMiddleware',
-)
-
-ROOT_URLCONF = 'htsql_demo.urls'
-
-TEMPLATE_DIRS = (
-    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
-    # Always use forward slashes, even on Windows.
-    # Don't forget to use absolute paths, not relative paths.
-)
-
-INSTALLED_APPS = (
-    'django.contrib.auth',
-    'django.contrib.contenttypes',
-    'django.contrib.sessions',
-    'django.contrib.sites',
-    'django.contrib.messages',
-    'django.contrib.admin',
-    'django.contrib.admindocs',
-    'htsql_demo.uni'
-)
Add a comment to this file

demo/django/htsql_demo/uni/__init__.py

Empty file removed.

demo/django/htsql_demo/uni/models.py

-from django.db import models
-
-# Note that this schema differs significantly from the HTSQL 
-# regression test schema.  Django doesn't support multiple-column 
-# FKs and has chosen to favor the empty string over NULL.
-
-class School(models.Model):
-    code = models.CharField(max_length=16, primary_key=True,
-                            db_column='code')
-    name = models.CharField(max_length=64, unique=True)
-
-class Department(models.Model):
-    code = models.CharField(max_length=16, primary_key=True,
-                            db_column='code')
-    name = models.CharField(max_length=64, unique=True)
-    school = models.ForeignKey(School, db_column='school_code', 
-                               blank=True, null=True)
-
-class Program(models.Model):
-    DEGREE_CHOICES = (
-        (u'ba', u"Bachelor's of Arts"),
-        (u'bs', u"Bachelor's of Science"),
-        (u'ct', u"Certificate"),
-        (u'pb', u"Postbaccalaureate"),
-        (u'ma', u"Master's of Arts"),
-        (u'ms', u"Master's of Science"),
-        (u'ph', u"Doctor of Philosophy"))
-    school = models.ForeignKey(School, db_column='school_code')
-    code = models.CharField(max_length=16)
-    title = models.CharField(max_length=64, unique=True)
-    degree = models.CharField(max_length=2, 
-                       choices=DEGREE_CHOICES, 
-                       blank=True, null=True)
-    part_of = models.CharField(max_length=16,
-                               blank=True, null=True)
-
-class Course(models.Model):
-    department = models.ForeignKey(Department, db_column='department')
-    no = models.IntegerField()
-    title = models.CharField(max_length=64, unique=True)
-    credits = models.IntegerField(blank=True, null=True)
-    description = models.TextField(blank=True, null=True)
-

demo/django/htsql_demo/uni/sql/course.sql

---  ALTER TABLE uni_course 
---        ADD CONSTRAINT uni_course_primary_uk
---        UNIQUE(department, no);
-
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('astro', 137, 'The Solar System', 3, 'Introductory survey of the solar system, including structure and motion of the planets, properties of the sun, and comparison to extrasolar systems.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('astro', 142, 'Solar System Lab', 2, 'Laboratory studies that complement the lecture course ASTRO 137.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('astro', 155, 'Telescope Workshop', 1, 'Introduction to correct use of the 8-inch Schmidt-Cassegrain type telescope. You will learn about magnification, how to locate an object, and how setting circles work.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('astro', 254, 'Life in the Universe', 3, 'Nature and origin of large numbers in the cosmos, the formation of planets, formation of life, and the anthropic principle.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('mth', 101, 'College Algebra', 5, 'This course, taken mostly by members from the School of Business is a primary graduate student funding vehicle for the the Department of Mathematics.  This is a 1000 person lecture reviews basic concepts taught in high school.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('chem', 100, 'Principles of Chemistry', 3, 'This course offers an introduction to the biological, inorganic, and chemical molecules, with an emphasis on basic principles of atomic and molecular electronic structure.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('chem', 110, 'Organic Chemistry I', 3, 'This course offers a practical introduction to organic chemistry, including a full set of problem sets with solutions. Focus is on the basic principles of understanding the structure and reactivity of organic molecules.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('chem', 115, 'Organic Chemistry Laboratory I', 2, 'Complements Organic Chemistry I. Practical laboratory experiments.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('chem', 314, 'Laboratory Chemistry', 3, 'Experimental chemistry for students who are planning to major in chemistry. Covers principles and applications of chemical laboratory techniques, including preparation and analysis of chemical materials.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('chem', 655, 'Protein Folding Problem', 3, 'Focuses on the mechanisms through which the amino acid sequence of polypeptide chains determine their three-dimensional conformation.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('phys', 211, 'General Physics I', 3, 'This course deals primarily with motions of objects and the forces that underlie these motions, including free fall, collisions between objects, rolling, and spinning.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('phys', 303, 'Relativity & Cosmology', 3, 'The course will describe developments that led to special relativity and its implications about the nature of space and time, as well as general relativity and quantum mechanics.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('phys', 388, 'Experimental Physics I', 2, 'In this course students will perform several experiments in different areas of physics. They will also learn fundamental experimental techniques and how to record and report results and perform analysis.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('phys', 512, 'Quantum Field Theory', 3, 'This course will cover the basic quantization of bosonic and fermionic fields, discrete spacetime symmetries, perturbative methods in QFT, definition of the S-matrix for scattering and decay processes.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('phys', 713, 'Quarks, Nuclei, and Cosmology', 3, 'General topics covered will include the structure of the nucleon, beta decay and weak interactions, and nucleon-nucleon interaction.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('phys', 819, 'Superconductivity', 3, 'This course provides a phenomenological approach to superconductivity, emphasizing super-conducting electronics.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('eng', 101, 'Introduction to Composition', 3, 'Provides students with the fundamental skills to read, interpret, and write critically at the college level.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('eng', 247, 'Boccaccio''s Decameron', 3, 'Follows of the arc of of the career Boccaccio with an emphasis on the Decameron, which is read in light of its cultural density and contextualized in terms of its antecedents, especially the Commedia of Dante.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('eng', 311, 'Writing Styles', 3, 'This practical course aids in understanding and writing non-fiction. We will look at some of the ways that prominent English writers have constructed their sentences and paragraphs. Students will write weekly exercises exploring these stylistic patterns.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('eng', 175, 'College Newspaper', 2, 'Students will perform journalistic writing exercises for publication in the college newspaper.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('eng', 276, 'Introduction to Science Writing', 3, 'This course provides an introduction to science writing. Students will learn about the business of science writing and will become familiar with the craft of making complex scientific research understandable for the general public.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('eng', 412, 'Ecology Writing Workshop', 2, 'This monthly workshop will focus on creation of a course assignment, a feature-length magazine article covering a complex topic in ecology.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('hist', 112, 'The United States in World History', 3, 'Examines the meaning of empire in relationship to the historical development of the United States of America.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('hist', 212, 'Historical Perspective on the Constitution', 3, 'This course covers the development of the constitutional doctrine from 1787 to the present. The Constitution as an experiment in Republicanism.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('hist', 415, 'History of the Family in Global Perspective', 3, 'Has the family really declined? What has changed in the last 1000 years? Drawing on cross-cultural examples, primarily from Latin America, the U.S. and Europe, this seminar explores the varieties of domestic forms.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('hist', 505, 'Science and History', 3, 'Introduces students to approaches and methods in the history of science, technology, and medicine');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('hist', 333, 'History of American Education', 3, 'A study of informal and formal education in American history leading to an understanding of present educational theory and practice.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('lang', 201, 'Introduction to Spanish', 4, 'Introduction to the Spanish language, with an emphasis on every day conversation and basic grammar.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('lang', 203, 'Intermediate Spanish', 3, 'Continuation of fundamental Spanish language learning, including verb tenses, reading skills, and basic conversation.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('lang', 304, 'Spanish Conversation Group', 2, 'Informal weekly conversation group designed to improve understanding of spoken Spanish. Suitable for both majors and casual speakers who wish to improve their skills for personal enjoyment or travel.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('lang', 207, 'Child Second Language Development', 3, 'Examines issues in child second language acquisition, including the critical period hypothesis and universal grammar.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('lang', 305, 'Second Language Syntax', 3, 'This course examines the form and acquisition of nonnative syntax. Consideration of whether nonnative grammars are fundamentally different than native grammars.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('psych', 102, 'General Psychology', 3, 'This course introduces the student to the major topics in scientific psychology as applied to human behavior. Applications of these principles will be made to the human experience.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('psych', 304, 'Introduction to Cognitive Psychology', 3, 'An introduction to the basic concepts of cognitive psychology, including areas such as perception, attention, memory, language, and thought.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('psych', 450, 'Laboratory in Applied Behavioral Science', 4, 'This course will provide students with hands-on training in the application of behavioral research technology to a clinical population.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('psych', 560, 'Examination of Real-Time Language Processing', 4, 'This lab course examines methods for the real-time examination of language processing in normal and disordered  language populations.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('psych', 610, 'Applied Child Psychology', 3, 'Introduction to major concepts and models used in psychological assessment and psychotherapeutic intervention of children. Several modalities of psychotherapy (individual, group, and family) will be reviewed along with research on their efficacy.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('poli', 113, 'American Government and Politics', 3, 'This course examines the structure, services, functions, and problems of government and politics at the national level.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('poli', 347, 'American Foreign Policy', 3, 'Theories, processes, and problem of American foreign policy and the craft of diplomacy, with special attention to contemporary issues.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('poli', 402, 'Government Internship: Semester in Washington', 4, 'Junior or seniors with a 3.0 grade point average or higher may apply for a limited number of internship opportunities in Washington, DC. Interns will live at University House on Capitol Hill and continue their normal class schedule at the DC Campus.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('poli', 644, 'Research Seminar in Middle Eastern Affairs', 3, 'Government and Politics of the Middle East and North Africa Spring. Historical background, contemporary setting, political processes, and major problems of some of the countries of Middle East and North Africa.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('poli', 715, '#5 is the 50 Solution', 3, 'A history of the two-state solution and other approaches to Palestian Statehood');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('poli', 431, 'American Government and Corporate Interests', 3, 'This course will examine the methods by which American business exert influence over legislators and the legislative process.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('comp', 102, 'Introduction to Computer Science', 3, 'This course in an introduction to the discipline of computer science. Topics include algorithmic foundations, hardware concepts, virtual machine concepts, software systems, applications, and social issues.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('comp', 230, 'History of Computing', 3, 'This course will survey the history of the computing field from antiquity to the present, focusing on the era of the electronic digital computer. Topics will include historical developments in hardware, software, and the theoretical foundations of computer science.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('comp', 350, 'Introduction to Signal Processing', 3, 'This course covers the nature of information, signals, transforms, and applications. Topics include analog to digital and digital to analog conversion, data storage (such as the audio format MP3), data transforms, and filters.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('comp', 615, 'Introduction to Automata', 3, 'Theory of computing devices and the languages they recognize.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('comp', 710, 'Laboratory in Computer Science', 4, 'Independent research opportunity using the university computer lab. Requires instructor permission and may be repeated.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('comp', 810, 'Thesis Research', 3, 'Guided research leading to production of the thesis. Requires instructor permission and may be repeated.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('comp', 819, 'Advanced Algorithms in Bioinformatics', 3, 'This course is focused on fundamental algorithmic techniques in Bioinformatics, including classed methods such as dynamic programming, support vector machines and other statistical and learning optimization methods.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('ee', 107, 'Exploration of Electrical Engineering', 3, 'Exploration of electrical engineering through several hands-on activities that cover a broad spectrum of applications and fundamental concepts. ');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('ee', 202, 'Engineering Electromagnetics', 3, 'Static electric and magnetic fields; solutions to static field problems, electromagnetic waves, boundary conditions, engineering applications.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('ee', 412, 'Laboratory in Electrical Engineering', 4, 'Hands-on experience covering areas of optical transforms, electro-optics devices, signal processing, fiber optics transmission, and holography.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('ee', 505, 'Information Theory', 3, 'Mathematical measurement of information; information transfer in discrete systems; redundancy, efficiency, and channel capacity; encoding systems.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('ee', 615, 'Learning and Adaptive Systems', 3, 'Adaptive and learning control systems; system identification; performance indices; gradient, stochastic approximation, controlled random search methods; introduction to pattern recognition.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('me', 111, 'Introduction to Mechanical Engineering', 3, 'Topics include an overview of career opportunities, problem solving processes, an introduction to the basic engineering design process, professionalism, professional registration, and ethics.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('me', 344, 'Undergraduate Research', 4, 'Undergraduates will conduct independent research activities under the direction of their major adviser.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('me', 501, 'Advanced Welding', 3, 'Advanced applications of welding and machine tool technology. Computer numerical control, multi-axis machining set-up, gas tungsten arc welding, and gas metal arch welding.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('me', 627, 'Advanced Heating and Air Conditioning', 4, '');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('me', 712, 'Graphic Communication and Design', 3, 'Sketching and orthographic projection. Covers detail and assembly working drawings, dimensioning, tolerance specification, and design projects.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('be', 112, 'Introduction to Biomedical Engineering', 3, 'This course covers topics in multiple formats ranging from lectures by faculty or guest speakers to presentations by participating students.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('be', 308, 'Fundamentals of Biochemistry', 3, 'Fundamental aspects of human biochemistry are introduced in this course for students in the bioinstrumentation/biosensors, biomechanics, and medical-imaging tracks.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('be', 415, 'Internship in Biomedical Engineering', 8, 'The student will work twenty hours per week in an area firm to gain experience in the application of biomedical engineering principles in an industrial setting.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('be', 509, 'Systems of Drug Delivery', 3, 'The mathematics of diffusion through various types of biological media is discussed.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('arthis', 202, 'History of Art Criticism', 3, 'An introductory survey course on Prehistoric through late-Medieval art history.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('arthis', 712, 'Museum and Gallery Management', 4, 'Supervised independent field experience and practical work in all areas of Art Museum management in the university and greater metropolitan area communities.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('arthis', 340, 'Arts of Asia', 3, 'An introduction to the history and criticism of Far Eastern art, including the art of China and Japan, fine and decorative arts.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('arthis', 710, 'Methods in Art History', 3, 'This seminar focuses on basic types of art-historical method. Some meetings focus on a single author who exemplifies a particular approach.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('arthis', 809, 'Materials and Construction in European Art', 3, 'A scientific examination of the materials and manufacturing techniques employed in Europe over the last two centuries.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('arthis', 623, 'Contemporary Latin American Art', 3, 'A survey of the last twenty years of Latin American art with a focus on the Caribbean and Central America.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('stdart', 714, 'Peer Portfolio Review', 0, 'An opportunity to practice giving and receiving constructive criticism.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('stdart', 411, 'Underwater Basket Weaving', 4, 'This course provides a novel perspective on the traditional art of basketry as it is experienced in reduced gravity and in the context of fluid dynamics. Requires instructor permission and a valid c-card.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('stdart', 512, 'Art in Therapy', 3, 'Surveys methods and results of using art and craft therapy with developmentally disabled adults.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('stdart', 614, 'Drawing Master Class', 5, 'For fine arts majors only, an intensive studio study including field trips to local parks and museums and a final group art show.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('stdart', 509, 'Twentieth Century Printmaking', 4, 'Development of personalized concepts and individual aesthetic expression in printmaking with reference to various styles and trends in Twentieth Century printmaking.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('stdart', 333, 'Drawing', 3, 'Exploration of the structure and interrelationships of visual form in drawing, painting, and sculpture. Principal historical modes of drawing are examined.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('tched', 122, 'Theory and Practice of Early Childhood Education', 3, 'Emphasis on the skills and processes needed for the design and implementation of optimal learning environments. Exploration of issues related to societal and cultural influences on the education of young children.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('tched', 155, 'Methods of Early Science Education', 3, 'A study of the curriculum methods, concepts, techniques, and materials in the teaching of general science to children in the early grades.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('tched', 367, 'Problems in Education Management', 3, 'This course is designed to assist the student to prepare for management of educational organizations and programs. Emphasis will be placed upon identifying specific problems and developing specific techniques by which to solve them.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('tched', 501, 'Challenges of Teaching the Gifted and Talented', 3, 'The nature and needs of the talented and gifted in all areas of development are explored.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('tched', 609, 'Supervised Internship in Education', 4, 'Supervised Internship I provides on-site, supervised instructional experience within a public school setting under the leadership of an appropriate, competent professional.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('edpol', 202, 'Technology in the Classroom', 3, 'Theories and practice of using educational technologies to support problem-based learning.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('edpol', 551, 'Classroom Visit', NULL, 'Elective visit to a local classroom for observation.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('stdart', 119, 'Spring Basket Weaving Workshop', NULL, 'A just-for-fun chance to learn the basics of basket weaving.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('edpol', 313, 'Technology, Society and Schools', 3, 'Examination of theories and history of interaction of society and technology with implications for instructional technology and schooling. Resources for constructing personal definitions of technology.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('edpol', 505, 'Qualitative Research for Educators', 3, 'This course provides an introduction to qualitative research at the Master level.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('edpol', 617, 'Educational Policy Analysis', 3, 'Frameworks for analyzing, designing policy proposals, and implementing plans.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('corpfi', 234, 'Accounting Information Systems', 3, 'This course bridges the gap between two disciplines critical to business operations.  This course of study teaches students to design and deploy information technology to improve the accounting systems of an organization.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('corpfi', 404, 'Corporate Financial Management', 3, 'This course covers advanced topics in corporate financial management, including its role in corporate governance.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('corpfi', 601, 'Case Studies in Corporate Finance', 3, 'A course designed to use case studies and financial analysis to further knowledge and ability to make financial management decisions.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('acc', 100, 'Practical Bookkeeping', 2, NULL);
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('acc', 200, 'Principles of Accounting I', 3, 'The initial course in the theory and practice of financial accounting. Topics emphasized include the preparation, reporting, and analysis of financial data.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('acc', 315, 'Financial Accounting', 5, 'Integration of the conceptual and computational aspects of asset, liability and stockholders equity accounting.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('acc', 426, 'Corporate Taxation', 3, 'Concepts and methods of determining federal tax liability of corporations.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('acc', 527, 'Advanced Accounting', 3, 'Theory and practical applications of accounting for consolidated entities and partnerships; includes foreign currency transactions, hedging and derivatives.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('acc', 606, 'Corporate Financial Law', 3, 'Law governing business corporations; fiduciary duties of managers and directors in situations such as mergers, acquisitions, securities offerings, market domination, litigation.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('capmrk', 712, 'International Financial Markets', 3, 'Offers an understanding of the international financial structure and studies its impact on business and individuals in various nations.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('capmrk', 808, 'Principles of Portfolio Management', 3, 'Comprehensive coverage of the theory and practice of money management as well as in-depth analysis of the theory and practice involved when securities are combined into portfolios.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('capmrk', 818, 'Financial Statement Analysis', 3, 'This course presents techniques for analyzing current and projected financial statements for the purposes of credit analysis, security analysis, and internal financial analysis, and cash flow forecasting.');
-INSERT INTO uni_course (department, no, title, credits, description) VALUES
-    ('capmrk', 756, 'Capital Risk Management', 3, 'This course introduces fundamental principles and techniques of financial risk management.');

demo/django/htsql_demo/uni/sql/department.sql

-INSERT INTO uni_department (code, name, school) VALUES
-    ('astro', 'Astronomy', 'ns');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('chem', 'Chemistry', 'ns');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('phys', 'Physics', 'ns');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('mth', 'Mathematics', 'ns');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('eng', 'English', 'la');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('lang', 'Foreign Languages', 'la');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('hist', 'History', 'la');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('psych', 'Psychology', 'la');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('poli', 'Political Science', 'la');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('comp', 'Computer Science', 'eng');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('ee', 'Electrical Engineering', 'eng');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('me', 'Mechanical Engineering', 'eng');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('be', 'Bioengineering', 'eng');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('arthis', 'Art History', 'art');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('stdart', 'Studio Art', 'art');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('tched', 'Teacher Education', 'edu');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('edpol', 'Educational Policy', 'edu');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('corpfi', 'Corporate Finance', 'bus');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('acc', 'Accounting', 'bus');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('capmrk', 'Capital Markets', 'bus');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('voc', 'Vocals', 'mus');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('pia', 'Piano', 'mus');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('win', 'Wind', 'mus');
-INSERT INTO uni_department (code, name, school) VALUES
-    ('str', 'Strings', 'mus');
--- Non-Academic Departments
-INSERT INTO uni_department (code, name, school) VALUES
-    ('bursar', 'Bursar''s Office', NULL);
-INSERT INTO uni_department (code, name, school) VALUES
-    ('career', 'Career Development', NULL);
-INSERT INTO uni_department (code, name, school) VALUES
-    ('parent', 'Parents & Alumni', NULL);

demo/django/htsql_demo/uni/sql/program.sql

---  ALTER TABLE uni_program 
---        ADD CONSTRAINT uni_program_primary_uk
---        UNIQUE(school, code);
---  ALTER TABLE uni_program 
---        ADD CONSTRAINT uni_program_part_of_fk
---        FOREIGN KEY (school, part_of ) 
---        REFERENCES uni_program(school, code);
-
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('ns', 'uastro', 'Bachelor of Science in Astronomy', 'bs', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('ns', 'uchem', 'Bachelor of Science in Chemistry', 'bs', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('ns', 'uphys', 'Bachelor of Science in Physics', 'bs', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('ns', 'pmth', 'Doctorate of Science in Mathematics', 'ph', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('ns', 'gmth', 'Masters of Science in Mathematics', 'bs', 'pmth');
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('ns', 'umth', 'Bachelor of Science in Mathematics', 'bs', 'gmth');
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('la', 'upsych', 'Bachelor of Arts in Psychology', 'ba', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('la', 'upolisci', 'Bachelor of Arts in Political Science', 'ba', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('la', 'gscitch', 'Master of Arts in Science Teaching', 'ma', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('la', 'psciwri', 'Science Writing', 'ct', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('la', 'gengl', 'Master of Arts in English', 'ma', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('la', 'uengl', 'Bachelor of Arts in English', 'ba', 'gengl');
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('la', 'uhist', 'Bachelor of Arts in History', 'ba', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('la', 'uspan', 'Bachelor of Arts in Spanish', 'ba', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('la', 'glang', 'Master of Arts in Modern Languages', 'ma', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('eng', 'gbuseng', 'M.S. in Business and Engineering', 'ms', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('eng', 'gee', 'M.S. in Electrical Engineering', 'ms', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('eng', 'gme', 'M.S. in Mechanical Engineering', 'ms', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('eng', 'gbe', 'M.S. in Bioengineering', 'ms', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('eng', 'uelec', 'B.S. in Electrical Engineering', 'bs', 'gee');
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('eng', 'umech', 'B.S. in Mechanical Engineering', 'bs', 'gme');
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('eng', 'ubio', 'B.S. in Bioengineering', 'bs', 'gbe');
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('eng', 'ucompsci', 'B.S. in Computer Science', 'bs', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('edu', 'umath', 'Bachelor of Arts in Math Education', 'ba', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('edu', 'usci', 'Bachelor of Arts in Science Education', 'ba', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('edu', 'psci', 'Certificate in Science Teaching', 'ct', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('edu', 'glited', 'Master of Arts in Literacy Education', 'ma', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('edu', 'gedlead', 'Master of Arts in Education Leadership', 'ma', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('edu', 'gedu', 'M.S. in Education', 'ms', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('edu', 'gtch', 'Master of Arts in Teaching', 'ma', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('bus', 'uacct', 'B.S. in Accounting', 'bs', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('bus', 'ucorpfi', 'B.S. in Corporate Finance', 'bs', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('bus', 'ubusad', 'B.S. in Business Administration', 'bs', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('bus', 'pacc', 'Graduate Certificate in Accounting', 'ct', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('bus', 'pcap', 'Certificate in Capital Markets', 'ct', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('art', 'gart', 'Post Baccalaureate in Art History', 'pb', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('art', 'uhist', 'Bachelor of Arts in Art History', 'ba', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('art', 'ustudio', 'Bachelor of Arts in Studio Art', 'ba', NULL);
-INSERT INTO uni_program (school, code, title, degree, part_of) VALUES
-    ('ph', 'phd', 'Honorary PhD', NULL, NULL);
-

demo/django/htsql_demo/uni/sql/school.sql

-INSERT INTO uni_school (code, name) VALUES
-    ('ns', 'School of Natural Sciences');
-INSERT INTO uni_school (code, name) VALUES
-    ('sc', 'School of Continuing Studies');
-INSERT INTO uni_school (code, name) VALUES
-    ('la', 'School of Arts and Humanities');
-INSERT INTO uni_school (code, name) VALUES
-    ('eng', 'School of Engineering');
-INSERT INTO uni_school (code, name) VALUES
-    ('art', 'School of Art and Design');
-INSERT INTO uni_school (code, name) VALUES
-    ('edu', 'College of Education');
-INSERT INTO uni_school (code, name) VALUES
-    ('bus', 'School of Business');
-INSERT INTO uni_school (code, name) VALUES
-    ('ph', 'Public Honorariums');
-INSERT INTO uni_school (code, name) VALUES
-    ('mus', 'School of Music & Dance');

demo/django/htsql_demo/uni/tests.py

-"""
-This file demonstrates two different styles of tests (one doctest and one
-unittest). These will both pass when you run "manage.py test".
-
-Replace these with more appropriate tests for your application.
-"""
-
-from django.test import TestCase
-
-class SimpleTest(TestCase):
-    def test_basic_addition(self):
-        """
-        Tests that 1 + 1 always equals 2.
-        """
-        self.failUnlessEqual(1 + 1, 2)
-
-__test__ = {"doctest": """
-Another way to test that 1 + 1 is equal to 2.
-
->>> 1 + 1 == 2
-True
-"""}
-

demo/django/htsql_demo/uni/views.py

-# Create your views here.
-
-

demo/django/htsql_demo/urls.py

-from django.conf.urls.defaults import *
-
-# Uncomment the next two lines to enable the admin:
-from django.contrib import admin
-admin.autodiscover()
-
-from twod.wsgi import make_wsgi_view
-from htsql import HTSQL
-htsql_app = HTSQL("sqlite:htsql_demo.sqdb")
-
-urlpatterns = patterns('',
-    # Example:
-    # (r'^htsql_demo/', include('htsql_demo.foo.urls')),
-
-    (r'^htsql(/.*)$', make_wsgi_view(htsql_app)),
-
-    # Uncomment the admin/doc line below to enable admin documentation:
-    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
-
-    # Uncomment the next line to enable the admin:
-    (r'^admin/', include(admin.site.urls)),
-)

demo/django/serve.py

-from os import environ
-environ['DJANGO_SETTINGS_MODULE'] = "htsql_demo.settings"
-from twod.wsgi import DjangoApplication
-from django.core.servers.basehttp import AdminMediaHandler
-from wsgiref.simple_server import make_server
-httpd = make_server('', 8080, AdminMediaHandler(DjangoApplication(),''))
-print "HTSQL Wrapper is at http://127.0.0.1:8080/htsql/"
-httpd.serve_forever()

demo/django/tutorial/manage.py

+#!/usr/bin/env python
+import os
+import sys
+
+if __name__ == "__main__":
+    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tutorial.settings")
+
+    from django.core.management import execute_from_command_line
+
+    execute_from_command_line(sys.argv)
Add a comment to this file

demo/django/tutorial/polls/__init__.py

Empty file added.

demo/django/tutorial/polls/admin.py

+from polls.models import Poll, Choice
+from django.contrib import admin
+
+class ChoiceInline(admin.TabularInline):
+    model = Choice
+    extra = 3
+
+class PollAdmin(admin.ModelAdmin):
+    fieldsets = [
+        (None,               {'fields': ['question']}),
+        ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}),
+    ]
+    inlines = [ChoiceInline]
+    list_display = ('question', 'pub_date', 'was_published_recently')
+    list_filter = ['pub_date']
+    search_fields = ['question']
+    date_hierarchy = 'pub_date'
+
+admin.site.register(Poll, PollAdmin)

demo/django/tutorial/polls/models.py

+from django.db import models
+import datetime
+from django.utils import timezone
+
+class Poll(models.Model):
+    question = models.CharField(max_length=200)
+    pub_date = models.DateTimeField('date published')
+
+    def was_published_recently(self):
+        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
+    was_published_recently.admin_order_field = 'pub_date'
+    was_published_recently.boolean = True
+    was_published_recently.short_description = 'Published recently?'
+
+    def __unicode__(self):
+        return self.question
+
+class Choice(models.Model):
+    poll = models.ForeignKey(Poll)
+    choice = models.CharField(max_length=200)
+    votes = models.IntegerField()
+
+    def __unicode__(self):
+        return self.choice
+

demo/django/tutorial/polls/tests.py

+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+    def test_basic_addition(self):
+        """
+        Tests that 1 + 1 always equals 2.
+        """
+        self.assertEqual(1 + 1, 2)

demo/django/tutorial/polls/urls.py

+from django.conf.urls import patterns, include, url
+from django.views.generic import DetailView, ListView
+from polls.models import Poll
+
+urlpatterns = patterns('',
+    url(r'^$',
+        ListView.as_view(
+            queryset=Poll.objects.order_by('-pub_date')[:5],
+            context_object_name='latest_poll_list',
+            template_name='polls/index.html')),
+    url(r'^(?P<pk>\d+)/$',
+        DetailView.as_view(
+            model=Poll,
+            template_name='polls/detail.html')),
+    url(r'^(?P<pk>\d+)/results/$',
+        DetailView.as_view(
+            model=Poll,
+            template_name='polls/results.html'),
+        name='poll_results'),
+    url(r'^(?P<poll_id>\d+)/vote/$', 'polls.views.vote'),
+)

demo/django/tutorial/polls/views.py

+from django.shortcuts import get_object_or_404, render_to_response
+from django.http import HttpResponseRedirect, HttpResponse
+from django.core.urlresolvers import reverse
+from django.template import RequestContext
+from polls.models import Choice, Poll
+
+def index(request):
+    latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
+    return render_to_response('polls/index.html', {'latest_poll_list': latest_poll_list})
+
+
+def detail(request, poll_id):
+    p = get_object_or_404(Poll, pk=poll_id)
+    return render_to_response('polls/detail.html', {'poll': p},
+                               context_instance=RequestContext(request))
+
+def results(request, poll_id):
+    p = get_object_or_404(Poll, pk=poll_id)
+    return render_to_response('polls/results.html', {'poll': p})
+
+def vote(request, poll_id):
+    p = get_object_or_404(Poll, pk=poll_id)
+    try:
+        selected_choice = p.choice_set.get(pk=request.POST['choice'])
+    except (KeyError, Choice.DoesNotExist):
+        # Redisplay the poll voting form.
+        return render_to_response('polls/detail.html', {
+            'poll': p,
+            'error_message': "You didn't select a choice.",
+        }, context_instance=RequestContext(request))
+    else:
+        selected_choice.votes += 1
+        selected_choice.save()
+        # Always return an HttpResponseRedirect after successfully dealing
+        # with POST data. This prevents data from being posted twice if a
+        # user hits the Back button.
+        return HttpResponseRedirect(reverse('poll_results', args=(p.id,)))
+

demo/django/tutorial/templates/polls/detail.html

+<h1>{{ poll.question }}</h1>
+
+{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
+
+<form action="/polls/{{ poll.id }}/vote/" method="post">
+{% csrf_token %}
+{% for choice in poll.choice_set.all %}
+    <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
+    <label for="choice{{ forloop.counter }}">{{ choice.choice }}</label><br />
+{% endfor %}
+<input type="submit" value="Vote" />
+</form>

demo/django/tutorial/templates/polls/index.html

+{% if latest_poll_list %}
+    <ul>
+    {% for poll in latest_poll_list %}
+        <li><a href="/polls/{{ poll.id }}/">{{ poll.question }}</a></li>
+    {% endfor %}
+    </ul>
+{% else %}
+    <p>No polls are available.</p>
+{% endif %}

demo/django/tutorial/templates/polls/results.html

+<h1>{{ poll.question }}</h1>
+
+<ul>
+{% for choice in poll.choice_set.all %}
+    <li>{{ choice.choice }} -- {{ choice.votes }} vote{{ choice.votes|pluralize }}</li>
+{% endfor %}
+</ul>
+
+<a href="/polls/{{ poll.id }}/">Vote again?</a>
Add a comment to this file

demo/django/tutorial/tutorial/__init__.py

Empty file added.

demo/django/tutorial/tutorial/settings.py

+# Django settings for tutorial project.
+
+import os.path
+
+PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+    # ('Your Name', 'your_email@example.com'),
+)
+
+MANAGERS = ADMINS
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
+        'NAME': os.path.join(PROJECT_ROOT, '../tutorial.sqlite'),                      # Or path to database file if using sqlite3.
+        'USER': '',                      # Not used with sqlite3.
+        'PASSWORD': '',                  # Not used with sqlite3.
+        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
+        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
+    }
+}
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# On Unix systems, a value of None will cause Django to use the same
+# timezone as the operating system.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'America/Chicago'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale.
+USE_L10N = True
+
+# If you set this to False, Django will not use timezone-aware datetimes.
+USE_TZ = True
+
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+# Example: "/home/media/media.lawrence.com/media/"
+MEDIA_ROOT = ''
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash.
+# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
+MEDIA_URL = ''
+
+# Absolute path to the directory static files should be collected to.
+# Don't put anything in this directory yourself; store your static files
+# in apps' "static/" subdirectories and in STATICFILES_DIRS.
+# Example: "/home/media/media.lawrence.com/static/"
+STATIC_ROOT = ''
+
+# URL prefix for static files.
+# Example: "http://media.lawrence.com/static/"
+STATIC_URL = '/static/'
+
+# Additional locations of static files
+STATICFILES_DIRS = (
+    # Put strings here, like "/home/html/static" or "C:/www/django/static".
+    # Always use forward slashes, even on Windows.
+    # Don't forget to use absolute paths, not relative paths.
+)
+
+# List of finder classes that know how to find static files in
+# various locations.
+STATICFILES_FINDERS = (
+    'django.contrib.staticfiles.finders.FileSystemFinder',
+    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
+)
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 'v@i)i=lwcb8pwnw@&amp;*a9re5)5e*bf+81!_##ydws90%k^8r%dr'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+    'django.template.loaders.filesystem.Loader',
+    'django.template.loaders.app_directories.Loader',
+#     'django.template.loaders.eggs.Loader',
+)
+
+MIDDLEWARE_CLASSES = (
+    'django.middleware.common.CommonMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+    # Uncomment the next line for simple clickjacking protection:
+    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+)
+
+ROOT_URLCONF = 'tutorial.urls'
+
+# Python dotted path to the WSGI application used by Django's runserver.
+WSGI_APPLICATION = 'tutorial.wsgi.application'
+
+TEMPLATE_DIRS = (
+    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+    # Always use forward slashes, even on Windows.
+    # Don't forget to use absolute paths, not relative paths.
+    os.path.join(PROJECT_ROOT, '../templates'),
+)
+
+INSTALLED_APPS = (
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.sites',
+    'django.contrib.messages',
+    'django.contrib.staticfiles',
+    # Uncomment the next line to enable the admin:
+    'django.contrib.admin',
+    # Uncomment the next line to enable admin documentation:
+    # 'django.contrib.admindocs',
+    'polls',
+    'htsql_django',
+)
+
+# A sample logging configuration. The only tangible logging
+# performed by this configuration is to send an email to
+# the site admins on every HTTP 500 error when DEBUG=False.
+# See http://docs.djangoproject.com/en/dev/topics/logging for
+# more details on how to customize your logging configuration.
+LOGGING = {
+    'version': 1,
+    'disable_existing_loggers': False,
+    'filters': {
+        'require_debug_false': {
+            '()': 'django.utils.log.RequireDebugFalse'
+        }
+    },
+    'handlers': {
+        'mail_admins': {
+            'level': 'ERROR',
+            'filters': ['require_debug_false'],
+            'class': 'django.utils.log.AdminEmailHandler'
+        }
+    },
+    'loggers': {
+        'django.request': {
+            'handlers': ['mail_admins'],
+            'level': 'ERROR',
+            'propagate': True,
+        },
+    }
+}
+
+HTSQL_CONFIG = {
+    'tweak.shell.default': None,
+}
+

demo/django/tutorial/tutorial/urls.py

+from django.conf.urls import patterns, include, url
+
+# Uncomment the next two lines to enable the admin:
+from django.contrib import admin
+admin.autodiscover()
+
+urlpatterns = patterns('',
+    # Examples:
+    # url(r'^$', 'tutorial.views.home', name='home'),
+    # url(r'^tutorial/', include('tutorial.foo.urls')),
+
+    # Uncomment the admin/doc line below to enable admin documentation:
+    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
+
+    # Uncomment the next line to enable the admin:
+    url(r'^admin/', include(admin.site.urls)),
+    url(r'^htsql/', include('htsql_django.urls')),
+)

demo/django/tutorial/tutorial/wsgi.py

+"""
+WSGI config for tutorial project.
+
+This module contains the WSGI application used by Django's development server
+and any production WSGI deployments. It should expose a module-level variable
+named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
+this application via the ``WSGI_APPLICATION`` setting.
+
+Usually you will have the standard Django WSGI application here, but it also
+might make sense to replace the whole Django WSGI application with a custom one
+that later delegates to the Django one. For example, you could introduce WSGI
+middleware here, or combine a Django application with an application of another
+framework.
+
+"""
+import os
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tutorial.settings")
+
+# This application object is used by any WSGI server configured to use this
+# file. This includes Django's development server, if the WSGI_APPLICATION
+# setting points here.
+from django.core.wsgi import get_wsgi_application
+application = get_wsgi_application()
+
+# Apply WSGI middleware here.
+# from helloworld.wsgi import HelloWorldApplication
+# application = HelloWorldApplication(application)

src/htsql_django/__init__.py

+#
+# Copyright (c) 2006-2012, Prometheus Research, LLC
+#
+
+from htsql import HTSQL
+from django.conf import settings
+
+CONFIG = getattr(settings, 'HTSQL_CONFIG', {})
+DEFAULT_CONFIG = {
+        'tweak.django': {},
+}
+
+instance = HTSQL(None, CONFIG, DEFAULT_CONFIG)
+produce = instance.produce
+

src/htsql_django/urls.py

+#
+# Copyright (c) 2006-2012, Prometheus Research, LLC
+#
+
+from django.conf.urls import patterns, url
+
+urlpatterns = patterns('',
+    url(r'', 'htsql_django.views.gateway'),
+)
+

src/htsql_django/views.py

+#
+# Copyright (c) 2006-2012, Prometheus Research, LLC
+#
+
+from django.contrib.auth.decorators import login_required
+from django.http import HttpResponse
+from django.core.urlresolvers import reverse
+from django.db import transaction
+from . import instance
+
+def to_environ(request):
+    environ = request.META.copy()
+    prefix = reverse(gateway)
+    if prefix.endswith('/'):
+        prefix = prefix[:-1]
+    if isinstance(environ['PATH_INFO'], unicode):
+        environ['PATH_INFO'] = environ['PATH_INFO'].encode('utf-8')
+    if isinstance(environ['SCRIPT_NAME'], unicode):
+        environ['SCRIPT_NAME'] = environ['SCRIPT_NAME'].encode('utf-8')
+    assert environ['PATH_INFO'].startswith(prefix)
+    assert environ['SCRIPT_NAME'] == ''
+    environ['SCRIPT_NAME'] = prefix
+    environ['PATH_INFO'] = environ['PATH_INFO'][len(prefix):]
+    return environ
+
+@login_required
+@transaction.commit_manually
+def gateway(request):
+    class output:
+        status = None
+        headers = None
+        body = None
+    environ = to_environ(request)
+    def start_response(status, headers, exc_info=None):
+        output.status = status
+        output.headers = headers
+    output.body = ''.join(instance(environ, start_response))
+    response = HttpResponse(output.body, status=int(output.status.split()[0]))
+    for header, value in output.headers:
+        response[header] = value
+    return response
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.