Ejemplo n.º 1
0
 def test_new_type(self):
     serializer.register(self.Foo, lambda foo: foo.x)
     assert '5' == json.dumps(self.Foo(5), cls=serializer)
     assert '6' == json.dumps(self.Foo(6), cls=serializer)
Ejemplo n.º 2
0
 def test_new_type_subclass(self):
     serializer.register(self.Foo, lambda foo: 'Hello World!')
     serializer.register(self.Bar, lambda bar: 'Hello Kitty!')
     assert '"Hello World!"' == json.dumps(self.Foo(5), cls=serializer)
     assert '"Hello Kitty!"' == json.dumps(self.Bar(6), cls=serializer)
Ejemplo n.º 3
0
 def test_new_type_subclass(self):
     serializer.register(self.Foo, lambda foo: 'Hello World!')
     serializer.register(self.Bar, lambda bar: 'Hello Kitty!')
     assert '"Hello World!"' == json.dumps(self.Foo(5), cls=serializer)
     assert '"Hello Kitty!"' == json.dumps(self.Bar(6), cls=serializer)
Ejemplo n.º 4
0
 def test_new_type(self):
     serializer.register(self.Foo, lambda foo: foo.x)
     assert '5' == json.dumps(self.Foo(5), cls=serializer)
     assert '6' == json.dumps(self.Foo(6), cls=serializer)
Ejemplo n.º 5
0
 def test_new_type(self):
     serializer.register(self.Foo, lambda foo: foo.x)
     self.assertEqual('5', json.dumps(self.Foo(5), cls=serializer))
     self.assertEqual('6', json.dumps(self.Foo(6), cls=serializer))
Ejemplo n.º 6
0
from pytz import UTC
from sqlalchemy.ext import associationproxy

from pockets.autolog import log
from residue import CoerceUTF8 as UnicodeText, UTCDateTime, UUID
from sideboard.lib import serializer

from uber.config import c
from uber.models import MagModel
from uber.models.admin import AdminAccount
from uber.models.email import Email
from uber.models.types import Choice, DefaultColumn as Column, MultiChoice

__all__ = ['PageViewTracking', 'Tracking']

serializer.register(associationproxy._AssociationList, list)


class PageViewTracking(MagModel):
    when = Column(UTCDateTime, default=lambda: datetime.now(UTC))
    who = Column(UnicodeText)
    page = Column(UnicodeText)
    what = Column(UnicodeText)

    @classmethod
    def track_pageview(cls):
        url, query = cherrypy.request.path_info, cherrypy.request.query_string
        # Track any views of the budget pages
        if "budget" in url:
            what = "Budget page"
        else:
Ejemplo n.º 7
0
from pytz import UTC
from sqlalchemy.ext import associationproxy

from pockets.autolog import log
from residue import CoerceUTF8 as UnicodeText, UTCDateTime, UUID
from sideboard.lib import serializer

from uber.config import c
from uber.models import MagModel
from uber.models.admin import AdminAccount
from uber.models.email import Email
from uber.models.types import Choice, DefaultColumn as Column, MultiChoice

__all__ = ['PageViewTracking', 'Tracking']

serializer.register(associationproxy._AssociationList, list)


class PageViewTracking(MagModel):
    when = Column(UTCDateTime, default=lambda: datetime.now(UTC))
    who = Column(UnicodeText)
    page = Column(UnicodeText)
    what = Column(UnicodeText)

    @classmethod
    def track_pageview(cls):
        url, query = cherrypy.request.path_info, cherrypy.request.query_string
        # Track any views of the budget pages
        if "budget" in url:
            what = "Budget page"
        else: