Example #1
0
 def __new__(mcs, name, bases, dct):
     cls = super(ObjectMetaclass, mcs).__new__(mcs, name, bases, dct)
     # attr check must be here because of specific six.with_metaclass implemetantion where metaclass is used also for
     # internal NewBase which hasn't set_endpoint_root method
     if hasattr(cls, 'set_endpoint_root'):
         cls.set_endpoint_root()
         cls.Query = QueryManager(cls)
     return cls
Example #2
0

class Installation(ParseResource):
    ENDPOINT_ROOT = '/'.join([API_ROOT, 'installations'])


class Push(ParseResource):
    ENDPOINT_ROOT = '/'.join([API_ROOT, 'push'])

    @classmethod
    def _send(cls, data, where=None, **kw):
        if where:
            kw['where'] = where

            # allow channels to be specified even if "where" is as well
            if "channels" in kw:
                kw['where']["channels"] = kw.pop("channels")

        return cls.POST('', data=data, **kw)

    @classmethod
    def alert(cls, data, where=None, **kw):
        cls._send(data, where=where, **kw)

    @classmethod
    def message(cls, message, where=None, **kw):
        cls._send({'alert': message}, where=where, **kw)


Installation.Query = QueryManager(Installation)
Example #3
0
 def __new__(mcs, name, bases, dct):
     cls = super(ObjectMetaclass, mcs).__new__(mcs, name, bases, dct)
     cls.Query = QueryManager(cls)
     return cls
Example #4
0
    def className(self):
        return '_User'

    def __repr__(self):
        return '<User:%s (Id %s)>' % (getattr(self, 'username', None), self.objectId)
    
    def removeRelation(self, key, className, objectsId):
        self.manageRelation('RemoveRelation', key, className, objectsId)

    def addRelation(self, key, className, objectsId):
        self.manageRelation('AddRelation', key, className, objectsId)

    def manageRelation(self, action, key, className, objectsId):
        objects = [{
                    "__type": "Pointer",
                    "className": className,
                    "objectId": objectId
                    } for objectId in objectsId]

        payload = {
            key: {
                 "__op": action,
                 "objects": objects
                }
            }
        self.__class__.PUT(self._absolute_url, **payload)
        self.__dict__[key] = ''


User.Query = QueryManager(User)
Example #5
0
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.


from parse_rest.connection import API_ROOT
from parse_rest.datatypes import Object
from parse_rest.query import QueryManager


class Role(Object):
    '''
    A Role is like a regular Parse object (can be modified and saved) but
    it requires additional methods and functionality
    '''
    ENDPOINT_ROOT = '/'.join([API_ROOT, 'roles'])

    @property
    def className(self):
        return '_Role'

    def __repr__(self):
        return '<Role:%s (Id %s)>' % (getattr(self, 'name', None), self.objectId)

    @classmethod
    def set_endpoint_root(cls):
        return cls.ENDPOINT_ROOT


Role.Query = QueryManager(Role)