Package lastfm :: Package mixins :: Module sharable

[hide private]
[frames] | no frames]

# Source Code for Module lastfm.mixins.sharable

     1  #!/usr/bin/env python
     2
     3  __author__ = "Abhinav Sarkar <abhinav@abhinavsarkar.net>"
     4  __version__ = "0.2"
     5  __license__ = "GNU Lesser General Public License"
     6
     7  from lastfm.decorators import authenticate
     8
     9 -class Sharable(object):
    10 -    def init(self, api):
    11          self._api = api
    12
    13      @authenticate
    14 -    def share(self, recipient, message = None):
    15          from lastfm.user import User
    16          params = self._default_params({'method': '%s.share' % self.__class__.__name__.lower()})
    17          if message is not None:
    18              params['message'] = message
    19
    20          if not isinstance(recipient, list):
    21              recipient = [recipient]
    22
    23          for i in xrange(len(recipient)):
    24              if isinstance(recipient[i], User):
    25                  recipient[i] = recipient[i].name
    26          params['recipient'] = ",".join(recipient)
    27          self._api._post_data(params)
    28
    29 -    def _default_params(self, extra_params = {}):
    30          return extra_params
    31