def test_keys(self):
        test_key = ndb.Key(MessageModelTest, '123')

        WidgetMessage = protopigeon.model_message(MessageModelTest)
        assert hasattr(WidgetMessage, 'id')

        m = WidgetMessage(id=test_key.urlsafe())
        assert protopigeon.to_entity(m, MessageModelTest).key == test_key

        WidgetMessage = protopigeon.model_message(MessageModelTest, key_field='key')
        assert hasattr(WidgetMessage, 'key')

        m = WidgetMessage(key=test_key.urlsafe())
        assert protopigeon.to_entity(m, MessageModelTest, key_field='key').key == test_key
    def test_keys(self):
        test_key = ndb.Key(MessageModelTest, '123')

        WidgetMessage = protopigeon.model_message(MessageModelTest)
        assert hasattr(WidgetMessage, 'id')

        m = WidgetMessage(id=test_key.urlsafe())
        assert protopigeon.to_entity(m, MessageModelTest).key == test_key

        WidgetMessage = protopigeon.model_message(MessageModelTest, key_field='key')
        assert hasattr(WidgetMessage, 'key')

        m = WidgetMessage(key=test_key.urlsafe())
        assert protopigeon.to_entity(m, MessageModelTest, key_field='key').key == test_key
    def __init__(self, controller):
        from ferris.core.scaffold import Scaffolding

        self.controller = controller
        self.transform = False

        # Make sure scaffold is ahead of us
        if Scaffolding in controller.Meta.components:
            if controller.Meta.components.index(Messaging) < controller.Meta.components.index(Scaffolding):
                raise ValueError("Scaffolding must come before Messaging in the component list for controller %s" % controller.name)

        # Create a Message class if needed
        if not hasattr(self.controller.meta, 'Message'):
            if not hasattr(self.controller.meta, 'Model'):
                raise ValueError('Controller.Meta must have a Message or Model class.')
            setattr(self.controller.meta, 'Message', model_message(self.controller.meta.Model))

        # Prefixes to automatically treat as messenging views
        if not hasattr(self.controller.meta, 'messaging_prefixes'):
            setattr(self.controller.meta, 'messaging_prefixes', ('api',))

        # Variable names to check for data
        if not hasattr(self.controller.meta, 'messaging_variable_names'):
            setattr(self.controller.meta, 'messaging_variable_names', ('data',))

        if hasattr(self.controller, 'scaffold'):
            self.controller.meta.messaging_variable_names += (self.controller.scaffold.plural, self.controller.scaffold.singular)

        # Events
        self.controller.events.before_startup += self._on_before_startup
        self.controller.events.before_render += self._on_before_render
    def make_test_model(self):
        WidgetMessage = protopigeon.model_message(MessageModelTest)

        widget = MessageModelTest(
            string='a',
            repeatedString=['a', 'b', 'c'],
            keyProp=ndb.Key('Moew', 'Test'),
            repeatedKey=[ndb.Key('One', 'Cat'), ndb.Key('Two', 'Cat')],
            text='a',
            repeatedText=['a', 'b', 'c'],
            blob='abc',
            repeatedBlob=['abc', 'abc', '123'],
            boolean=True,
            repeatedBoolean=[False, True, False],
            integer=5,
            repeatedInteger=[1, 2, 3, 4, 5],
            float=3.14,
            repeatedFloat=[3.14, 1.23, 10.4],
            datetime=datetime.datetime.utcnow(),
            date=datetime.date.today(),
            time=datetime.datetime.utcnow().time(),
            repeatedDatetime=[datetime.datetime.utcnow(), datetime.datetime.now()],
            geopt=ndb.GeoPt(5, 5),
            repeatedGeopt=[ndb.GeoPt(5, 7), ndb.GeoPt(7, 8)],
            blobkey=ndb.BlobKey('oEFRyChdYLJbRk6cKXuniZfFtHct1wzDcnvVSgay91N7SoOCWTAWbDU8YcwQQbdn'),
            repeatedBlobkey=[ndb.BlobKey('oEFRyChdYLJbRk6cKXuniZfFtHct1wzDcnvVSgay91N7SoOCWTAWbDU8YcwQQbdn'), ndb.BlobKey('vQHMoSU5zK2zBxMA_fcP7A==')],
            structured=InnerModel(one='One', two=2),
            repeatedStructured=[InnerModel(one='One', two=2), InnerModel(one='Name', two=1)]
        )

        widget.put()

        return WidgetMessage, widget
    def __init__(self, controller):
        self.controller = controller
        self.transform = False

        # Create a Message class if needed
        if not hasattr(self.controller.meta, 'Message'):
            if not hasattr(self.controller.meta, 'Model'):
                raise ValueError(
                    'Controller.Meta must have a Message or Model class.')
            setattr(self.controller.meta, 'Message',
                    model_message(self.controller.meta.Model))

        # Prefixes to automatically treat as messenging views
        if not hasattr(self.controller.meta, 'messaging_prefixes'):
            setattr(self.controller.meta, 'messaging_prefixes', ('api', ))

        # Variable names to check for data
        if not hasattr(self.controller.meta, 'messaging_variable_names'):
            setattr(self.controller.meta, 'messaging_variable_names',
                    ('data', ))

        if hasattr(self.controller, 'scaffold'):
            self.controller.meta.messaging_variable_names += (
                self.controller.scaffold.singular,
                self.controller.scaffold.plural)

        # Events
        self.controller.events.before_startup += self._on_before_startup
        self.controller.events.after_dispatch += self._on_after_dispatch
    def make_test_model(self):
        WidgetMessage = protopigeon.model_message(MessageModelTest)

        widget = MessageModelTest(
            string='a',
            repeatedString=['a', 'b', 'c'],
            keyProp=ndb.Key('Moew', 'Test'),
            repeatedKey=[ndb.Key('One', 'Cat'), ndb.Key('Two', 'Cat')],
            text='a',
            repeatedText=['a', 'b', 'c'],
            blob='abc',
            repeatedBlob=['abc', 'abc', '123'],
            boolean=True,
            repeatedBoolean=[False, True, False],
            integer=5,
            repeatedInteger=[1, 2, 3, 4, 5],
            float=3.14,
            repeatedFloat=[3.14, 1.23, 10.4],
            datetime=datetime.datetime.utcnow(),
            date=datetime.date.today(),
            time=datetime.datetime.utcnow().time(),
            repeatedDatetime=[datetime.datetime.utcnow(), datetime.datetime.now()],
            geopt=ndb.GeoPt(5, 5),
            repeatedGeopt=[ndb.GeoPt(5, 7), ndb.GeoPt(7, 8)],
            blobkey=ndb.BlobKey('oEFRyChdYLJbRk6cKXuniZfFtHct1wzDcnvVSgay91N7SoOCWTAWbDU8YcwQQbdn'),
            repeatedBlobkey=[ndb.BlobKey('oEFRyChdYLJbRk6cKXuniZfFtHct1wzDcnvVSgay91N7SoOCWTAWbDU8YcwQQbdn'), ndb.BlobKey('vQHMoSU5zK2zBxMA_fcP7A==')],
            structured=InnerModel(one='One', two=2),
            repeatedStructured=[InnerModel(one='One', two=2), InnerModel(one='Name', two=1)]
        )

        widget.put()

        return WidgetMessage, widget
Beispiel #7
0
    def test_model_message(self):
        WidgetMessage = protopigeon.model_message(MessageModelTest)

        properties = MessageModelTest._properties.keys()
        fields = dir(WidgetMessage)

        for prop in properties:
            assert prop in fields
    def test_model_message(self):
        WidgetMessage = protopigeon.model_message(MessageModelTest)

        properties = MessageModelTest._properties.keys()
        fields = dir(WidgetMessage)

        for prop in properties:
            assert prop in fields
    def __init__(self, controller):
        from ferris.core.scaffold import Scaffolding

        self.controller = controller
        self.transform = False

        # Make sure scaffold is ahead of us
        if Scaffolding in controller.Meta.components:
            if controller.Meta.components.index(
                    Messaging) < controller.Meta.components.index(Scaffolding):
                raise ValueError(
                    "Scaffolding must come before Messaging in the component list for controller %s"
                    % controller.name)

        # Create a Message class if needed
        if not hasattr(self.controller.meta, 'Message'):
            if not hasattr(self.controller.meta, 'Model'):
                raise ValueError(
                    'Controller.Meta must have a Message or Model class.')
            setattr(self.controller.meta, 'Message',
                    model_message(self.controller.meta.Model))

        # Prefixes to automatically treat as messenging views
        if not hasattr(self.controller.meta, 'messaging_prefixes'):
            setattr(self.controller.meta, 'messaging_prefixes', ('api', ))

        # Variable names to check for data
        if not hasattr(self.controller.meta, 'messaging_variable_names'):
            setattr(self.controller.meta, 'messaging_variable_names',
                    ('data', ))

        if hasattr(self.controller, 'scaffold'):
            self.controller.meta.messaging_variable_names += (
                self.controller.scaffold.plural,
                self.controller.scaffold.singular)

        # Events
        self.controller.events.before_startup += self._on_before_startup
        self.controller.events.before_render += self._on_before_render
    def __init__(self, controller):
        self.controller = controller
        self.transform = False

        # Create a Message class if needed
        if not hasattr(self.controller.meta, 'Message'):
            if not hasattr(self.controller.meta, 'Model'):
                raise ValueError('Controller.Meta must have a Message or Model class.')
            setattr(self.controller.meta, 'Message', model_message(self.controller.meta.Model))

        # Prefixes to automatically treat as messenging views
        if not hasattr(self.controller.meta, 'messaging_prefixes'):
            setattr(self.controller.meta, 'messaging_prefixes', ('api',))

        # Variable names to check for data
        if not hasattr(self.controller.meta, 'messaging_variable_names'):
            setattr(self.controller.meta, 'messaging_variable_names', ('data',))

        if hasattr(self.controller, 'scaffold'):
            self.controller.meta.messaging_variable_names += (self.controller.scaffold.plural, self.controller.scaffold.singular)

        # Events
        self.controller.events.before_startup += self._on_before_startup
        self.controller.events.before_render += self._on_before_render
Beispiel #11
0
import ferris3 as f3
import protopigeon
import logging
from protorpc import messages
from google.appengine.ext import ndb
from ferris3 import Model, Service, hvild, auto_service
from app.models.city import City



SubMsg = protopigeon.model_message(City)

MultiMessage = protopigeon.list_message(SubMsg)



@auto_service
class CityService(Service):
	list = hvild.list(City)
	get = hvild.get_by_keyname(City)
	delete = hvild.delete(City)
	insert = hvild.insert_with_keyname(City)
	update = hvild.update(City)


		
Beispiel #12
0
from google.appengine.api import urlfetch
from twilio.rest import TwilioRestClient
from ferris3 import Model, Service, hvild, auto_service
from app.models.message import PushMessage
from app.models.channel import Channel
from app.models.subscriber import Subscriber

"""
mszxzS42wKud0ojfP0jJr8klsNCT9k8Js9JMf6ZW8 remove the 8
83BHgK79PTFlYGAec9nIG2dtkFoyXoFGJEVplMW add a Q
"""
twilio_acc ='ACdeb5d6152c18963a8ec4889adf23d2f6'
twilio_tkn=  'bd6c2ceb49775ddcbc1a4fc33cf1f631'
parse_appid='mszxzS42wKud0ojfP0jJr8klsNCT9k8Js9JMf6ZW'
parse_apikey='83BHgK79PTFlYGAec9nIG2dtkFoyXoFGJEVplMWQ'
MessageMsg = protopigeon.model_message(PushMessage)

MultiMessage = protopigeon.list_message(MessageMsg)


@auto_service
class MessagesService(Service):
	list = hvild.list(PushMessage)
	get = hvild.get(PushMessage)
	delete = hvild.delete(PushMessage)
	insert = hvild.insert(PushMessage)
	update = hvild.update(PushMessage)



	@f3.auto_method(returns= MessageMsg, http_method="POST", name="create_and_notify")
Beispiel #13
0
import logging
from protorpc import messages
from random import randint
from Crypto.Hash import SHA256
from google.appengine.ext import ndb
from google.appengine.api import mail
from twilio.rest import TwilioRestClient
from ferris3 import Model, Service, hvild, auto_service
from app.models.message import PushMessage
from app.models.channel import Channel
from app.models.subscriber import Subscriber

twilio_acc ='ACdeb5d6152c18963a8ec4889adf23d2f6'
twilio_tkn=  'bd6c2ceb49775ddcbc1a4fc33cf1f631'

SubMsg = protopigeon.model_message(Subscriber)
Verification_URL= "http://urban-feed.appspot.com/console/index.html#/email_validation?";
MultiMessage = protopigeon.list_message(SubMsg)
class BooleanMessage(messages.Message):
    subscriber_value = messages.BooleanField(1)

def random_with_N_digits(n):
    range_start = 10**(n-1)
    range_end = (10**n)-1
    return randint(range_start, range_end)

@auto_service
class SubscribersService(Service):
	
	get = hvild.get(Subscriber)	
	
Beispiel #14
0
from protorpc import messages
from ferris3 import auto_service, auto_method, Service
import ferris3 as f3
import protopigeon
from google.appengine.ext import ndb

from app.models.ccp import User, Links
from app.messages.ccp_messages import UserMessage, UserLogginMessage

GenericLink = protopigeon.model_message(Links, exclude="id")
UserMessageP = protopigeon.model_message(User)
PublicLinkMessages = protopigeon.model_message(Links, exclude=("link_6", "link_7", "link_8", "link_9", "link_10"))
PrivateLinkMessages = protopigeon.model_message(Links, exclude=("link_1", "link_2", "link_3", "link_4", "link_5"))


class ParamsMessage(messages.Message):
    user = messages.StringField(1, required=True)


@auto_service(endpoint="ferris", path="collections")
class CcpService(Service):
    @auto_method(returns=UserMessage, path='auth/login', name="login", http_method="POST")
    def login(self, request=(UserLogginMessage,)):
        if getattr(request, 'username') is not None and getattr(request, 'password') is not None:
            query = User.query(
                User.username == getattr(request, 'username'),
                User.password == getattr(request, 'password'))
            user = query.get()
            if user is not None:
                if user.is_active:
                    return UserMessage(
Beispiel #15
0
from google.appengine.api import mail
from google.appengine.api import urlfetch
from twilio.rest import TwilioRestClient
from ferris3 import Model, Service, hvild, auto_service
from app.models.message import PushMessage
from app.models.channel import Channel
from app.models.subscriber import Subscriber
"""
mszxzS42wKud0ojfP0jJr8klsNCT9k8Js9JMf6ZW8 remove the 8
83BHgK79PTFlYGAec9nIG2dtkFoyXoFGJEVplMW add a Q
"""
twilio_acc = 'ACdeb5d6152c18963a8ec4889adf23d2f6'
twilio_tkn = 'bd6c2ceb49775ddcbc1a4fc33cf1f631'
parse_appid = 'mszxzS42wKud0ojfP0jJr8klsNCT9k8Js9JMf6ZW'
parse_apikey = '83BHgK79PTFlYGAec9nIG2dtkFoyXoFGJEVplMWQ'
MessageMsg = protopigeon.model_message(PushMessage)

MultiMessage = protopigeon.list_message(MessageMsg)


@auto_service
class MessagesService(Service):
    list = hvild.list(PushMessage)
    get = hvild.get(PushMessage)
    delete = hvild.delete(PushMessage)
    insert = hvild.insert(PushMessage)
    update = hvild.update(PushMessage)

    @f3.auto_method(returns=MessageMsg,
                    http_method="POST",
                    name="create_and_notify")