Skip to content

Instantly share code, notes, and snippets.

from websauna.system.http import Request
from websauna.utils.slug import slug_to_uuid
from websauna.system.core.route import simple_route
from pyramid.request import Response
from pyramid.httpexceptions import HTTPNotFound
from . import models
@simple_route("/questions/{question_uuid}", route_name="detail", renderer="myapp/detail.html")
def detail(request):
# Convert base64 encoded UUID string from request path to Python UUID object
@mazz
mazz / views.py
Created January 7, 2017 05:09
sqlalchemy.orm.exc.DetachedInstanceError: Instance <Media at 0x10949c0b8> is not bound to a Session
from pyramid.httpexceptions import HTTPNotFound, HTTPFound
from websauna.utils.slug import uuid_to_slug
from websauna.utils.slug import slug_to_uuid
from websauna.system.core import messages
from websauna.system.http import Request
from websauna.system.core.route import simple_route
from .models import Media
import pafy
import transaction
@mazz
mazz / views.py
Created January 8, 2017 01:10
websauna mailer logs email sending as OK, never arrives. Confirmed postfix is working locally.
from pyramid.httpexceptions import HTTPNotFound, HTTPFound
from websauna.utils.slug import uuid_to_slug
from websauna.utils.slug import slug_to_uuid
from websauna.system.core import messages
from websauna.system.http import Request
from websauna.system.core.route import simple_route
from email.header import Header
from email.utils import formataddr
from websauna.system.mail import send_templated_mail
from .models import Media
@mazz
mazz / development.ini
Created January 8, 2017 01:32
hearit/conf/development.ini
# pserve and command line configuration for a local development machine
[includes]
include_ini_files =
resource://websauna/conf/development.ini
resource://hearit/conf/base.ini
resource://websauna/conf/base.ini
[app:main]
websauna.site_id = hearit_dev
@mazz
mazz / views.py
Created January 8, 2017 05:41
my_task.apply_async() not firing?
from pyramid.httpexceptions import HTTPNotFound, HTTPFound
from websauna.utils.slug import uuid_to_slug
from websauna.utils.slug import slug_to_uuid
from websauna.system.core import messages
from websauna.system.http import Request
from websauna.system.core.route import simple_route
from email.header import Header
from email.utils import formataddr
from websauna.system.mail import send_templated_mail
from .models import Media
@mazz
mazz / models.py
Created January 12, 2017 03:30
websauna admin does not detect audiostream table
"""Place your SQLAlchemy models in this file."""
import datetime
from uuid import uuid4
from sqlalchemy import Column, Unicode, String, Integer, ForeignKey, UnicodeText
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import relationship
from websauna.system.model.meta import Base
@mazz
mazz / gist:353152b512c35f414622892471166073
Created January 22, 2017 01:21 — forked from miohtama/gist:0f64104fc8aefde8360f0c70cf46b950
SMS based login for React and Websauna app
"""
allows users to sign up and login with their phone number, if that number is assoicated with an
existing customer record.
"""
import logging
import colander
from cornice.service import Service
from pyramid.exceptions import HTTPBadRequest
from pyramid_sms.utils import normalize_us_phone_number
"""App entry point and configuration."""
from pyramid.authorization import ACLAuthorizationPolicy
import websauna.system
class Initializer(websauna.system.Initializer):
"""An initialization configuration used for starting xact.
Override parent class methods to customize application behavior.
"""App entry point and configuration."""
import pem
from pyramid.authorization import ACLAuthorizationPolicy
import websauna.system
class Initializer(websauna.system.Initializer):
"""An initialization configuration used for starting xact.
Override parent class methods to customize application behavior.
~/src/ansible/websauna.ansible (master ✔) ᐅ ansible-playbook -i hosts.ini playbook-myapp.yml -k -K -s
SSH password:
SUDO password[defaults to SSH password]:
PLAY [myapp_development] *******************************************************
TASK [setup] *******************************************************************
ok: [myapp_development]
TASK [include_vars] ************************************************************