Skip to content

Instantly share code, notes, and snippets.

View atroche's full-sized avatar

Alistair Roche atroche

View GitHub Profile
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
ERROR: test_staff_can_moderate (frontend.conversation.tests.ConversationViews)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/notroot/streetlife/frontend/conversation/tests.py", line 56, in setUp
self.message.save()
File "/home/notroot/.virtualenvs/streetbook/lib/python2.6/site-packages/mongoengine/document.py", line 102, in save
doc = self.to_mongo()
File "/home/notroot/.virtualenvs/streetbook/lib/python2.6/site-packages/mongoengine/base.py", line 749, in to_mongo
data[field.db_field] = field.to_mongo(value)
File "/home/notroot/.virtualenvs/streetbook/lib/python2.6/site-packages/mongoengine/base.py", line 291, in to_mongo
changed_fields = document._get_changed_fields()
for field in changed_fields:
keys = field.split('.')
if (len(keys) == 3 and keys[0] == "comments"
and keys[2] in document.revision_fields):
comment_index = int(keys[1])
old_comment = old_message.comments[comment_index]
new_comment = document.comments[comment_index]
revision = Revision.create(old_comment, new_comment, [keys[2]],
user)
def get_context_variable(self, name):
"""
Returns a variable from the context passed to the
template. Only works if your version of Flask
has signals support (0.6+) and blinker is installed.
Raises a ContextVariableDoesNotExist exception if does
not exist in context.
:param name: name of variable
def get_context_variable(self, name):
"""
Returns a variable from the context passed to the
template. Only works if your version of Flask
has signals support (0.6+) and blinker is installed.
Raises a ContextVariableDoesNotExist exception if does
not exist in context.
:param name: name of variable
from flask import (request, redirect, render_template, abort, url_for,
current_app)
from mongoengine.queryset import DoesNotExist
from streetlife import current_user as user
from streetlife.frontend.conversation.forms import BucketMessageForm
from streetlife.frontend.home.models import FollowedMessages
from streetlife.helpers.views import login_required, BaseView
@property
def centroid(self):
lat_sum = 0
lon_sum = 0
point_count = 0
for point in self.locations_points:
lat_sum += point[0]
lon_sum += point[1]
point_count += 1
from mongoengine import *
connect("test")
class Thing(EmbeddedDocument):
count = IntField()
class User(Document):
thing = EmbeddedDocumentField(Thing)
from werkzeug import find_modules, import_string
def find_secure_views():
modules = [import_string(module_name) for module_name in
find_modules("streetbook", include_packages=True, recursive=True)
if 'views' in module_name]
for module in modules:
for k, v in module.__dict__.items():
from flask import current_app, request
from streetlife.helpers.tests import TestCase
from streetlife.helpers.views import BaseView
from streetlife.helpers.https import secure_required, redirect_https_to_http
__all__ = ("HttpsTests", )
class TestSecureView(BaseView):