Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4df9a51ad3
Fetching contributors…

Cannot retrieve contributors at this time

file 34 lines (25 sloc) 0.927 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
from facepy import GraphAPI

class Entity(object):
    """Entities are the base class for anything on Facebook."""

    oauth_token = None
    """A string describing an OAuth token."""

    _cache = None
    """Graph API cache for this object."""

    def __init__(self, id, oauth_token=None, **attributes):
        """
Get the entity with the given id.

:param id: An integer or string describing the Facebook id of the entity.
:param oauth_token: A string describing an OAuth token.
"""
        self.oauth_token = oauth_token
        self.id = id

        self.__dict__.update(attributes)

    @property
    def cache(self):
        """Query or return the Graph API representation of this resource."""
        if not self._cache:
            self._cache = self.graph.get('%s' % self.id)

        return self._cache

    @property
    def graph(self):
        return GraphAPI(self.oauth_token)
Something went wrong with that request. Please try again.