-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working example due to rearranging directory structure and fixing doc…
…kerfile/docker-compose volumes to not overwrite egg
- Loading branch information
Raj
committed
Jan 22, 2019
1 parent
a95d0cc
commit 2c2c111
Showing
18 changed files
with
244 additions
and
82 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
File renamed without changes.
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,23 +4,26 @@ MAINTAINER Raj <[email protected]> | |
ENV VENV=/app | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
RUN mkdir /config /app | ||
COPY /services_config/requirements.pip /config/requirements.pip | ||
#COPY /volumes/src/testsite_config/development.ini /app/development.ini | ||
COPY /volumes/src /app | ||
#COPY /volumes/src/testsite_config/setup.py /app/setup.py | ||
RUN mkdir /app | ||
COPY /volumes/testsite /app/testsite | ||
COPY /services_config/pyramid_app_config/setup.py /app/setup.py | ||
COPY /services_config/pyramid_app_config/development.ini /app/testsite_config/development.ini | ||
COPY /services_config/pyramid_app_config/requirements.pip /app/testsite_config/requirements.pip | ||
|
||
RUN apt-get -yqq update && apt-get install -yqq python python-dev python-pip python-virtualenv | ||
RUN mkdir /app/venv | ||
RUN echo "hello" | ||
|
||
RUN virtualenv /app/venv | ||
RUN ls /app/venv | ||
#RUN source /app/venv/bin/activate | ||
RUN /app/venv/bin/pip install -r /config/requirements.pip | ||
RUN /app/venv/bin/pip install -e /app/testsite_config | ||
RUN /app/venv/bin/pserve /app/testsite_config/development.ini --reload | ||
RUN source /app/venv/bin/activate | ||
RUN /app/venv/bin/pip install -r /app/testsite_config/requirements.pip | ||
# RUN /app/venv/bin/pip install -e /app/testsite_config | ||
RUN /app/venv/bin/pip install -e "./app[testing]" | ||
# RUN /app/venv/bin/pserve /app/testsite_config/development.ini --reload | ||
WORKDIR /app | ||
# RUN source /app/venv/bin/activate | ||
RUN which python | ||
RUN ls -a | ||
|
||
#RUN /app/venv/bin/pserve /app/testsite_config/development.ini --reload | ||
#CMD ["python", "app.py"] |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,53 @@ | ||
from pyramid.config import Configurator | ||
|
||
from sqlalchemy import engine_from_config | ||
from testsite.models import initialize_sql | ||
from pyramid.registry import Registry | ||
#from pyramid_jinja2 import _get_or_build_default_environment # ?#?#? | ||
from pyramid.response import Response | ||
from pyramid.authentication import AuthTktAuthenticationPolicy | ||
from pyramid.authorization import ACLAuthorizationPolicy | ||
|
||
from pyramid_redis_sessions import session_factory_from_settings | ||
#from pyramid_beaker import session_factory_from_settings | ||
#from pyramid.session import UnencryptedCookieSessionFactoryConfig | ||
#from pyramid_redis_sessions import session_factory_from_settings | ||
from testsite.security import groupfinder | ||
|
||
registry = Registry() | ||
|
||
|
||
def hello_world(request): | ||
print('Incoming request') | ||
return Response('<body><h1>Hello World!</h1></body>') | ||
|
||
|
||
def main(global_config, **settings): | ||
""" This function returns a Pyramid WSGI application. | ||
""" | ||
engine = engine_from_config(settings, 'sqlalchemy.') | ||
initialize_sql(engine) | ||
|
||
session_factory = session_factory_from_settings(settings) #redis | ||
# session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet') | ||
|
||
authn_policy = AuthTktAuthenticationPolicy(secret='s0secret', | ||
callback=groupfinder) | ||
authz_policy = ACLAuthorizationPolicy() | ||
|
||
config = Configurator( | ||
settings=settings, | ||
root_factory='testsite.security.RootFactory', | ||
authentication_policy=authn_policy, | ||
authorization_policy=authz_policy, | ||
session_factory=session_factory, | ||
) | ||
# jinja_env = _get_or_build_default_environment(config.registry) # ?#?#? | ||
#config.set_request_factory(RequestWithUserAttribute) | ||
|
||
config.add_route('hello', '/') | ||
config.add_view(hello_world, route_name='hello') | ||
|
||
|
||
config.scan() | ||
return config.make_wsgi_app() |
Binary file not shown.
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,96 @@ | ||
import transaction | ||
import datetime | ||
|
||
from sqlalchemy import Column, Table, ForeignKey | ||
from sqlalchemy import Integer, Unicode, Date, DateTime, Boolean | ||
from sqlalchemy import event, func | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from sqlalchemy.ext.hybrid import hybrid_property | ||
from sqlalchemy.orm import scoped_session, sessionmaker, synonym | ||
from sqlalchemy.orm import relationship, backref, relation | ||
from sqlalchemy.orm import configure_mappers, validates | ||
from zope.sqlalchemy import ZopeTransactionExtension | ||
from pyramid.security import Everyone, Authenticated, Allow | ||
|
||
from sqlalchemy import Column, Integer, String | ||
from sqlalchemy.types import DateTime | ||
|
||
|
||
class BaseModel(object): | ||
def __json__(self, request=None): | ||
## creates and returns a dict object | ||
props = {} | ||
# for key in self.__dict__: | ||
# if not key.startswith(('_', '_sa_')): | ||
# obj = getattr(self, key) | ||
for key in self.__table__.columns: | ||
if not key.name.startswith(('_', '_sa_')): | ||
obj = getattr(self, key.name) | ||
if isinstance(obj, datetime.datewhich): | ||
props[key.name] = obj.isoformat() | ||
else: | ||
props[key.name] = obj | ||
return props | ||
|
||
|
||
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) | ||
Base = declarative_base(cls=BaseModel) | ||
|
||
|
||
class Signups(Base): | ||
""" | ||
Example Signups table | ||
""" | ||
__tablename__ = 'signups' | ||
id = Column(Integer, primary_key=True) | ||
name = Column(String(256)) | ||
email = Column(String(256), unique=True) | ||
date_signed_up = Column(DateTime()) | ||
|
||
|
||
########################################## | ||
def initialize_sql(engine): ## | ||
DBSession.configure(bind=engine) ## | ||
Base.metadata.bind = engine ## | ||
Base.metadata.create_all(engine) ## | ||
########################################## | ||
|
||
|
||
|
||
|
||
class User(Base): | ||
__tablename__ = 'users' | ||
id = Column(Integer, primary_key=True) | ||
title = Column(Unicode(255)) | ||
first_name = Column(Unicode(255)) | ||
middle_names = Column(Unicode(255)) | ||
last_name = Column(Unicode(255)) | ||
email = Column(Unicode(255), unique=True, nullable=False) | ||
username = Column(Unicode(255)) | ||
sex = Column(Integer, default=0) | ||
dob = Column(Date) | ||
marital_status = Column(Unicode(255)) | ||
currenttown = Column(Unicode(255)) | ||
hometown = Column(Unicode(255)) | ||
tz = Column(Unicode(255), nullable=False) | ||
join_date = Column(DateTime, default=datetime.datetime.utcnow) | ||
|
||
confirm_status = Column(Integer, nullable=False) | ||
_confirm_code = Column(Unicode(16)) | ||
_password = Column(Unicode(60), nullable=False) | ||
|
||
# unconfirmed = 0 | ||
# confirmed = 1 | ||
# invited = 2 | ||
|
||
######################################################### | ||
# Hashing the password #################################### | ||
def _get_password(self): #### #### | ||
return self._password # ## # #### | ||
def _set_password(self, password): #### #### | ||
self._password = hash_password(password) #### | ||
#### | ||
password = property(_get_password, _set_password) #### | ||
password = synonym('_password', descriptor=password) #### | ||
########################################################### | ||
######################################################### |
Binary file not shown.
Oops, something went wrong.