本文整理汇总了Python中users.User.open方法的典型用法代码示例。如果您正苦于以下问题:Python User.open方法的具体用法?Python User.open怎么用?Python User.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.User
的用法示例。
在下文中一共展示了User.open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Playlist
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import open [as 别名]
class Playlist():
queryGetPlaylist = """
SELECT name, description
FROM playlist_settings
WHERE id = %s AND i_user = %s
"""
queryGetSongs = """
SELECT i_song
FROM playlists
WHERE listnum = %s AND i_user = %s
"""
queryCountSongs = """
SELECT COUNT(*)
FROM playlists
WHERE listnum = %s AND i_user = %s
"""
def __init__(self, i_playlist=0, i_user=0, config=None):
self.id = 0
self.name = False
self.description = False
self.i_user = 0
self.owner = User()
self.songs = []
self.count = 0;
if config:
self.Config = config
else:
self.Config = Config()
if i_user:
self.i_user = i_user
if i_playlist:
self.open(i_playlist)
def open(self, i_playlist, i_user=0, get_songs=False):
self.id = i_playlist
if i_user > 0:
self.i_user = i_user
if self.i_user:
self.owner.open(self.i_user)
self.get_song_count()
self.get_playlist_info()
if get_songs:
self.get_songs()
def get_playlist_info(self):
try:
db = conn.cursor()
except NameError:
conn = DB()
db = conn.cursor()
db.execute(self.queryGetPlaylist, (self.id, self.i_user))
row = db.fetchone()
try:
self.description = row[1]
self.name = row[0]
except:
self.id = 0
self.name = False
self.description = False
self.i_user = 0
self.owner.open(0)
def get_songs(self):
try:
db = conn.cursor()
except NameError:
conn = DB()
db = conn.cursor()
db.execute(self.queryGetSongs, (self.id, self.i_user))
rows = db.fetchall()
for row in rows:
song = Song(row[0], self.Config)
self.songs.append(song)
def get_song_count(self):
try:
db = conn.cursor()
except NameError:
conn = DB()
db = conn.cursor()
db.execute(self.queryCountSongs, (self.id, self.i_user))
row = db.fetchone()
#.........这里部分代码省略.........