-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
459 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
0.0 | ||
--- | ||
|
||
- Initial version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
CURDIR=$(PWD) | ||
TEST=$(PWD)/bin/nosetests | ||
|
||
all: git clean test html | ||
|
||
develop: | ||
python2.6 bootstrap.py --distribute | ||
bin/buildout | ||
|
||
git: | ||
git submodule foreach git pull origin master | ||
|
||
doc: | ||
html: | ||
cd pyramid_formalchemy/docs; $(MAKE) html | ||
cd formalchemy/docs; $(MAKE) html | ||
cd fa.jquery/docs; $(MAKE) html | ||
cd docs; $(MAKE) html | ||
|
||
test: | ||
cd pyramid_formalchemy; $(TEST) | ||
cd formalchemy; bin/test | ||
cd fa.jquery; $(TEST) | ||
|
||
clean: | ||
rm -Rf pyramid_formalchemy/docs/_build | ||
rm -Rf formalchemy/docs/_build | ||
rm -Rf fa.jquery/docs/_build | ||
rm -Rf docs/_build | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
formalchemy_project README | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule fa.jquery
updated
35 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
# | ||
from pyramid.config import Configurator | ||
from sqlalchemy import engine_from_config | ||
|
||
from formalchemy_project.models import initialize_sql | ||
import pyramid_formalchemy | ||
|
||
def main(global_config, **settings): | ||
""" This function returns a Pyramid WSGI application. | ||
""" | ||
engine = engine_from_config(settings, 'sqlalchemy.') | ||
initialize_sql(engine) | ||
config = Configurator(settings=settings) | ||
pyramid_formalchemy.include_jquery(config) | ||
pyramid_formalchemy.configure(config, package='formalchemy_project', use_jquery=True) | ||
return config.make_wsgi_app() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
from formalchemy_project import models | ||
from formalchemy import config as fa_config | ||
from formalchemy import templates | ||
from formalchemy import validators | ||
from formalchemy import fields | ||
from formalchemy import forms | ||
from formalchemy import tables | ||
from formalchemy.ext.fsblob import FileFieldRenderer | ||
from formalchemy.ext.fsblob import ImageFieldRenderer | ||
import fa.jquery as jq | ||
|
||
fa_config.encoding = 'utf-8' | ||
fa_config.engine = jq.TemplateEngine() | ||
|
||
## Use jquery renderers | ||
forms.FieldSet.default_renderers.update(jq.default_renderers) | ||
#forms.FieldSet.default_renderers['dropdown'] = jq.relations() | ||
|
||
class FieldSet(forms.FieldSet): | ||
pass | ||
|
||
class Grid(tables.Grid): | ||
pass | ||
|
||
## Initialize fieldsets | ||
|
||
Widgets = FieldSet(models.Widgets) | ||
Widgets.configure() | ||
Widgets.autocomplete.set(renderer=jq.autocomplete(['%sanux' % s for s in 'BCDFGHJKLMNP'])) | ||
|
||
## Initialize grids | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
"""The application's model objects""" | ||
import transaction | ||
import logging | ||
|
||
from sqlalchemy import Column | ||
from sqlalchemy import Integer | ||
from sqlalchemy import Unicode | ||
from sqlalchemy import Date | ||
from sqlalchemy import DateTime | ||
|
||
from sqlalchemy.exc import IntegrityError | ||
from sqlalchemy.ext.declarative import declarative_base | ||
|
||
from sqlalchemy.orm import scoped_session | ||
from sqlalchemy.orm import sessionmaker | ||
|
||
from zope.sqlalchemy import ZopeTransactionExtension | ||
|
||
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) | ||
Base = declarative_base() | ||
|
||
from fa.jquery.utils import HTML, Color, Slider | ||
from datetime import datetime | ||
|
||
class Article(Base): | ||
__tablename__ = 'articles' | ||
|
||
id = Column(Integer, primary_key=True) | ||
title = Column(Unicode) | ||
text = Column(HTML) | ||
publication_date = Column(Date, default=datetime.now) | ||
|
||
|
||
class Widgets(Base): | ||
__tablename__ = 'widgets' | ||
|
||
id = Column(Integer, primary_key=True) | ||
autocomplete = Column(Unicode) | ||
slider = Column(Slider, default=0) | ||
color = Column(Color) | ||
date = Column(Date) | ||
date_time = Column(DateTime, default=datetime.now) | ||
|
||
def populate(): | ||
import random | ||
session = DBSession() | ||
for i in range(50): | ||
article = Article( | ||
title='Article %s' % i, | ||
text='''Heading | ||
===================== | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent consectetur | ||
imperdiet porta. Pellentesque habitant morbi tristique senectus et netus et | ||
malesuada fames ac turpis egestas. Proin sollicitudin, mi sit amet blandit | ||
dignissim, lacus ante sagittis est, in congue lectus nulla non urna. Nunc a | ||
justo ut lacus laoreet facilisis. Nullam blandit posuere mauris semper | ||
pellentesque. Sed leo neque, vulputate sed pharetra vel, rhoncus at nisl. | ||
Aenean eget nibh turpis. Quisque semper lacus sodales libero dictum pretium. | ||
Phasellus euismod, odio sit amet vehicula pharetra, nunc diam imperdiet dui, | ||
non malesuada neque erat ac augue. Sed elit ipsum, placerat vitae accumsan | ||
quis, tempor in tellus. Vestibulum tempus consequat libero, sit amet | ||
pellentesque lacus interdum in. Vestibulum in nunc at nulla ultrices laoreet. | ||
* Morbi id orci augue, porta malesuada mi. | ||
* Proin rhoncus tellus non orci iaculis pretium. | ||
* Praesent aliquet commodo urna, vitae laoreet arcu porttitor ut. | ||
* Nullam sollicitudin blandit risus, eu luctus nisl scelerisque eget. | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent consectetur | ||
imperdiet porta. Pellentesque habitant morbi tristique senectus et netus et | ||
malesuada fames ac turpis egestas. Proin sollicitudin, mi sit amet blandit | ||
dignissim, lacus ante sagittis est, in congue lectus nulla non urna. Nunc a | ||
justo ut lacus laoreet facilisis. Nullam blandit posuere mauris semper | ||
pellentesque. Sed leo neque, vulputate sed pharetra vel, rhoncus at nisl. | ||
Aenean eget nibh turpis. Quisque semper lacus sodales libero dictum pretium. | ||
Phasellus euismod, odio sit amet vehicula pharetra, nunc diam imperdiet dui, | ||
non malesuada neque erat ac augue. Sed elit ipsum, placerat vitae accumsan | ||
quis, tempor in tellus. Vestibulum tempus consequat libero, sit amet | ||
pellentesque lacus interdum in. Vestibulum in nunc at nulla ultrices laoreet. | ||
''', | ||
publication_date = datetime.utcnow()) | ||
session.add(article) | ||
|
||
for i in range(100): | ||
widgets = Widgets( | ||
autocomplete=random.choice(['%sanux' % s for s in 'BCDFGHJKLMNP']+['']), | ||
color = random.choice(["#EEEEEE", "#FFFF88", "#FF7400", "#CDEB8B", "#6BBA70"]), | ||
slider = random.choice(range(0, 100, 10)), | ||
) | ||
session.add(widgets) | ||
transaction.commit() | ||
|
||
|
||
def initialize_sql(engine): | ||
DBSession.configure(bind=engine) | ||
Base.metadata.bind = engine | ||
Base.metadata.create_all(engine) | ||
try: | ||
populate() | ||
except IntegrityError, e: | ||
DBSession.rollback() |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
* html img, | ||
* html .png{position:relative;behavior:expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none", | ||
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "',sizingMethod='image')", | ||
this.src = "static/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''), | ||
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "',sizingMethod='crop')", | ||
this.runtimeStyle.backgroundImage = "none")),this.pngSet=true) | ||
);} | ||
#wrap{display:table;height:100%} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.