text stringlengths 0 828 |
|---|
All this really does is add some functions that forward to the mapped |
database class. |
"""""" |
if not issubclass(cls, Storable): |
raise ValueError( |
""%s is not a subclass of gludb.datab.Storage"" % repr(cls) |
) |
cls.ensure_table = classmethod(_ensure_table) |
cls.find_one = classmethod(_find_one) |
cls.find_all = classmethod(_find_all) |
cls.find_by_index = classmethod(_find_by_index) |
cls.save = _save |
cls.delete = _delete |
return cls" |
1607,"def _find_playlist(self): |
"""""" |
Internal method to populate the object given the ``id`` or |
``reference_id`` that has been set in the constructor. |
"""""" |
data = None |
if self.id: |
data = self.connection.get_item( |
'find_playlist_by_id', playlist_id=self.id) |
elif self.reference_id: |
data = self.connection.get_item( |
'find_playlist_by_reference_id', |
reference_id=self.reference_id) |
if data: |
self._load(data)" |
1608,"def _to_dict(self): |
"""""" |
Internal method that serializes object into a dictionary. |
"""""" |
data = { |
'name': self.name, |
'referenceId': self.reference_id, |
'shortDescription': self.short_description, |
'playlistType': self.type, |
'id': self.id} |
if self.videos: |
for video in self.videos: |
if video.id not in self.video_ids: |
self.video_ids.append(video.id) |
if self.video_ids: |
data['videoIds'] = self.video_ids |
[data.pop(key) for key in data.keys() if data[key] == None] |
return data" |
1609,"def _load(self, data): |
"""""" |
Internal method that deserializes a ``pybrightcove.playlist.Playlist`` |
object. |
"""""" |
self.raw_data = data |
self.id = data['id'] |
self.reference_id = data['referenceId'] |
self.name = data['name'] |
self.short_description = data['shortDescription'] |
self.thumbnail_url = data['thumbnailURL'] |
self.videos = [] |
self.video_ids = data['videoIds'] |
self.type = data['playlistType'] |
for video in data.get('videos', []): |
self.videos.append(pybrightcove.video.Video( |
data=video, connection=self.connection))" |
1610,"def save(self): |
"""""" |
Create or update a playlist. |
"""""" |
d = self._to_dict() |
if len(d.get('videoIds', [])) > 0: |
if not self.id: |
self.id = self.connection.post('create_playlist', playlist=d) |
else: |
data = self.connection.post('update_playlist', playlist=d) |
if data: |
self._load(data)" |
1611,"def delete(self, cascade=False): |
"""""" |
Deletes this playlist. |
"""""" |
if self.id: |
self.connection.post('delete_playlist', playlist_id=self.id, |
cascade=cascade) |
self.id = None" |
1612,"def find_all(connection=None, page_size=100, page_number=0, |
sort_by=DEFAULT_SORT_BY, sort_order=DEFAULT_SORT_ORDER): |
"""""" |
List all playlists. |
"""""" |
return pybrightcove.connection.ItemResultSet(""find_all_playlists"", |
Playlist, connection, page_size, page_number, sort_by, sort_order)" |
1613,"def find_by_ids(ids, connection=None, page_size=100, page_number=0, |
sort_by=DEFAULT_SORT_BY, sort_order=DEFAULT_SORT_ORDER): |
"""""" |
List playlists by specific IDs. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.