当前位置: 首页>>代码示例>>Python>>正文


Python Stream.query方法代码示例

本文整理汇总了Python中stream.Stream.query方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.query方法的具体用法?Python Stream.query怎么用?Python Stream.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stream.Stream的用法示例。


在下文中一共展示了Stream.query方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def get(self):
        url = self.request.url
        stream_name = re.findall('searchStream=(\S+)',url)
        if len(stream_name) == 0:
            self.response.write(url)
        else:
            stream_name = re.findall('searchStream=(\S+)',url)[0]
            streams = Stream.query().fetch()
            nameList = list()
            for stream in streams:
                nameList.append(stream.name)

            index = list()
            for i in xrange(len(nameList)):
                index.append(LCS(nameList[i], stream_name))
            tmp = zip(index, nameList)
            tmp.sort(reverse = True)
            #we only show five most relation streams
            if len(tmp) < 5:
                showNum = len(tmp)
            else:
                showNum = 5
            self.response.write(SEARCH_PAGE_TEMPLATE)
            self.response.write('<p>%d results for <b>%s</b>,<br>  click on image to view stream</p>' % (showNum,stream_name))
            for i in xrange(showNum):
                stream = Stream.query(Stream.name==tmp[i][1]).fetch()[0]
                #self.response.write(stream.numberofpictures)
                if stream.numberofpictures > 0:
                    pictures=db.GqlQuery("SELECT * FROM Picture " +"WHERE ANCESTOR IS :1 "+"ORDER BY uploaddate DESC",db.Key.from_path('Stream',stream.name))
                    self.response.write('<table border="1" style="width:100%"><table style = "width:10%">')
                    self.response.out.write('<td><div style = "position:relative;"><a href = "%s"><img src="img?img_id=%s" ></img><div style = "position: absolute; left:150px; top:20px"></a>%s</div></div></td>' % (stream.url, pictures[0].key(),stream.name))
                    self.response.write('</table>')
                else:
                    self.response.out.write('<td><div style = "position:relative;"><a href = "%s"><img src="http://www.estatesale.com/img/no_image.gif" ></img><div style = "position: absolute; left:150px; top:20px"></a>%s</div></div></td>' % (stream.url, stream.name))
开发者ID:xiangkundai,项目名称:Mini1_APT,代码行数:36,代码来源:search.py

示例2: get

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def get(self):
        search_item = self.request.get("search_item")
        print(search_item)
        streams = Stream.query().fetch()
        nameList = list()
        cover_list = []
        stream_list = []
        for stream in streams:
            nameList.append(stream.name)

        index = list()
        for i in xrange(len(nameList)):
            index.append(LCS(nameList[i], search_item))
        tmp = zip(index, nameList)
        tmp.sort(reverse=True)
        # we only show five most relation streams
        for i in xrange(len(tmp)):
            stream = Stream.query(Stream.name == tmp[i][1]).fetch()[0]
            stream_list.append(stream.name)
            # self.response.write(stream.numberofpictures)
            # if stream.numberofpictures > 0:
            #   pictures=db.GqlQuery("SELECT * FROM Picture " +"WHERE ANCESTOR IS :1 "+"ORDER BY uploaddate DESC",db.Key.from_path('Stream',stream.name))
            cover_list.append(stream.coverurl)

        dictPassed = {"streamList": stream_list, "displayCovers": cover_list}
        jsonObj = json.dumps(dictPassed, sort_keys=True, indent=4, separators=(",", ": "))
        print("write json")
        self.response.write(jsonObj)
开发者ID:xiangkundai,项目名称:ConnexUs,代码行数:30,代码来源:search.py

示例3: get

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def get(self):
        status = (0,0)

        stream_name=re.findall('%3D(.*)',self.request.url)[0]

        #Change!# stream=Stream.query(Stream.name==stream_name, Stream.author==users.get_current_user()).fetch()[0]
        stream=Stream.query(Stream.name==stream_name).fetch()[0]


        if(stream.author==users.get_current_user()):
            status = (1,1)
        elif(users.get_current_user()):
            status = (1,0)
        else:
            self.redirect(users.create_login_url(self.request.url))

        pictures=db.GqlQuery("SELECT *FROM Picture " + "WHERE ANCESTOR IS :1 " +"ORDER BY uploaddate DESC LIMIT 3" , db.Key.from_path('Stream',stream_name))

        uploadurl = blobstore.create_upload_url('/upload')
        showmoreurl=urllib.urlencode({'showmore': stream.name+"=="+users.get_current_user().nickname()})
        geoviewurl=urllib.urlencode({'geoview': stream.name+"=="+users.get_current_user().nickname()})
        template_values = {
            'user_name':users.get_current_user().nickname(),
            'showmoreurl': showmoreurl,
            'stream_name': stream_name,
            'pictures':pictures,
            'status':status,
            'uploadurl':uploadurl,
            'geoviewurl': geoviewurl

        }
        template = JINJA_ENVIRONMENT.get_template('viewsinglestream_index.html')
        self.response.write(template.render(template_values))
开发者ID:erwenzhang,项目名称:ConnexUs,代码行数:35,代码来源:viewsinglestream.py

示例4: get

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def get(self):
        status = (0, 0)

        stream_name = re.findall("%3D(.*)", self.request.url)[0]

        # Change!# stream=Stream.query(Stream.name==stream_name, Stream.author==users.get_current_user()).fetch()[0]
        stream = Stream.query(Stream.name == stream_name).fetch()[0]

        if stream.author == users.get_current_user():
            status = (1, 1)
        elif users.get_current_user():
            status = (1, 0)
        else:
            self.redirect(users.create_login_url(self.request.url))

        pictures = db.GqlQuery(
            "SELECT *FROM Picture " + "WHERE ANCESTOR IS :1 " + "ORDER BY uploaddate DESC LIMIT 3",
            db.Key.from_path("Stream", stream_name),
        )

        uploadurl = blobstore.create_upload_url("/upload")
        showmoreurl = urllib.urlencode({"showmore": stream.name + "==" + users.get_current_user().nickname()})
        geoviewurl = urllib.urlencode({"geoview": stream.name + "==" + users.get_current_user().nickname()})
        template_values = {
            "user_name": users.get_current_user().nickname(),
            "showmoreurl": showmoreurl,
            "stream_name": stream_name,
            "pictures": pictures,
            "status": status,
            "uploadurl": uploadurl,
            "geoviewurl": geoviewurl,
        }
        template = JINJA_ENVIRONMENT.get_template("viewsinglestream_index.html")
        self.response.write(template.render(template_values))
开发者ID:xiangkundai,项目名称:ConnexUs,代码行数:36,代码来源:viewsinglestream.py

示例5: post

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def post(self):
        original_url0 = self.request.headers['Referer']
        original_url = original_url0
        if "%3D" not in original_url:
            original_url += '%3D%3D'
            original_url += users.get_current_user().nickname()

        stream_name=re.findall('=(.*)%3D%3D',original_url)
        if(len(stream_name)<1):
            stream_name=re.findall('%3D(.*)%3D%3D',original_url)[0]
        else:
            stream_name=stream_name[0]

        user_name=re.findall('%3D%3D(.*)\?',original_url)
        if(len(user_name)<1):
            user_name=re.findall('%3D%3D(.*)',original_url)[0]
        else:
            user_name=user_name[0]

        user_name=user_name.split('%40')
        if(len(user_name)>1):
            user_name=user_name[0]+'@'+user_name[1]
        else:
            user_name=user_name[0]

        #Change!# stream=Stream.query(Stream.name==stream_name, Stream.author_name==user_name).fetch()[0]
        stream=Stream.query(Stream.name==stream_name).fetch()[0]

        if users.get_current_user():
            #stream.subscribers.append(users.get_current_user().nickname())
            stream.subscribers.append(users.get_current_user().email())
        stream.put()

        self.redirect(original_url0)
开发者ID:erwenzhang,项目名称:ConnexUs,代码行数:36,代码来源:viewsinglestream.py

示例6: post

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def post(self):
        original_url0 = self.request.headers["Referer"]
        original_url = original_url0
        if "%3D" not in original_url:
            original_url += "%3D%3D"
            original_url += users.get_current_user().nickname()

        stream_name = re.findall("=(.*)%3D%3D", original_url)
        if len(stream_name) < 1:
            stream_name = re.findall("%3D(.*)%3D%3D", original_url)[0]
        else:
            stream_name = stream_name[0]

        user_name = re.findall("%3D%3D(.*)\?", original_url)
        if len(user_name) < 1:
            user_name = re.findall("%3D%3D(.*)", original_url)[0]
        else:
            user_name = user_name[0]

        user_name = user_name.split("%40")
        if len(user_name) > 1:
            user_name = user_name[0] + "@" + user_name[1]
        else:
            user_name = user_name[0]

        # Change!# stream=Stream.query(Stream.name==stream_name, Stream.author_name==user_name).fetch()[0]
        stream = Stream.query(Stream.name == stream_name).fetch()[0]

        if users.get_current_user():
            # stream.subscribers.append(users.get_current_user().nickname())
            # users.get_current_user().email() = users.get_current_user().email().lower()
            stream.subscribers.append(users.get_current_user().email().lower())
        stream.put()

        self.redirect(original_url0)
开发者ID:xiangkundai,项目名称:ConnexUs,代码行数:37,代码来源:viewsinglestream.py

示例7: get

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def get(self, photoIndexes, currentLocation):
        passedInCoord = currentLocation.split('_')
        lat = float(passedInCoord[0])
        lon = float(passedInCoord[1])

        displayImageObjs = []
        # displayPhotoList = []

        stream_query = Stream.query()
        for stream in stream_query:
            photos = db.GqlQuery("SELECT * FROM Picture " + "WHERE ANCESTOR IS :1 " +"ORDER BY uploaddate DESC" , db.Key.from_path('Stream', stream.name))
            for photo in photos:
                photoUrl = images.get_serving_url(photo.imgkey)
                photoUrl = str(photoUrl) + "=s500"

                photoDict = {}
                photoDict["photoServingURL"] = photoUrl
                photoDict["date"] = str(photo.uploaddate)
                photoDict["loc"] = str(photo.loc)
                photoDict["streamName"] = str(stream.name)
                # photoDict["streamID"] = str(stream.key.id())
                photoCoord = str(photo.loc).split(',')
                plat = float(photoCoord[0])
                plon = float(photoCoord[1])
                R = 6373.0

                lat1 = radians(lat)
                lon1 = radians(lon)
                lat2 = radians(plat)
                lon2 = radians(plon)

                dlon = lon2 - lon1
                dlat = lat2 - lat1
                a = (sin(dlat / 2)) ** 2 + cos(lat1) * cos(lat2) * (sin(dlon / 2)) ** 2
                c = 2 * atan2(sqrt(a), sqrt(1-a))
                distance = R * c
                photoDict["actualDistance"] = distance
                if distance > 10:
                    photoDict["strDistance"] = str(distance).split('.', 1)[0] + 'km'
                else:
                    photoDict["strDistance"] = str(distance * 1000).split('.', 1)[0] + 'm'
                displayImageObjs.append(photoDict)

        displayImageObjs = sorted(displayImageObjs, key = lambda k: k['actualDistance'])
        passedPhotos = []
        morePhotos = "False"
        indexURL = photoIndexes
        indexList = str(photoIndexes).split('_')
        if len(displayImageObjs) - 1 > int(indexList[1]):
            for i in range(int(indexList[0]), int(indexList[1]) + 1):
                passedPhotos.append(displayImageObjs[i])
            indexURL = str(int(indexList[0]) + 16) + '_' + str(int(indexList[1]) + 16)
            morePhotos = "True"
        else:
            for i in range(int(indexList[0]), len(displayImageObjs)):
                passedPhotos.append(displayImageObjs[i])

        dictPassed = {'user': None, 'morePhotos': morePhotos, 'indexURL': indexURL,'displayImageObjs': passedPhotos}#'displayPhotoList' : displayStreamList
        jsonObj = json.dumps(dictPassed, sort_keys=True, indent=4, separators=(',', ': '))
        self.response.write(jsonObj)
开发者ID:erwenzhang,项目名称:ConnexUs,代码行数:62,代码来源:view.py

示例8: post

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def post(self):
        email = self.request.get("email")
        final_picture = []
        displayImages = []
        caption = []
        streams = Stream.query().fetch()
        #print streams
        #print streams[0]
        #print type(users.get_current_user().nickname())

        #print users.get_current_user()
     #   for stream in streams:

      #      if(users.get_current_user().nickname() in stream.subscribers):
       #         print stream.name
        for stream in streams:
            #print "user0: "+user
           # print type(user)
            print email
            print stream.subscribers
            #print type(stream.subscribers[0])
            if(email in stream.subscribers):
              #  print "user1: "+user
                print "1"
                pictures=db.GqlQuery("SELECT *FROM Picture " + "WHERE ANCESTOR IS :1 " +"ORDER BY uploaddate DESC" , db.Key.from_path('Stream',stream.name))
                for pic in pictures:
                    if len(final_picture) < 16:
                      #  print ("user2",pic.uploaddate)
                     #   print("user2",pic.imgkey)
                        final_picture.append(pic)
                        continue
                    else:
                   #     print "user3: "+user
                        print pic.uploaddate
                        print final_picture[15].uploaddate
                        if pic.uploaddate > final_picture[15].uploaddate:
                            final_picture.pop()
                            final_picture.append(pic)
                            final_picture.sort(key=lambda pic:pic.uploaddate, reverse=True)
                            print final_picture

        final_picture.sort(key=lambda pic:pic.uploaddate, reverse=True)
        for f_pic in final_picture:
            #print f_pic.uploaddate
            #f = "http://aptmini3.appspot.com/view_photo/"+f_pic.imgkey
           # f.get_serving_url()
            caption.append(f_pic.caption)
            url = images.get_serving_url(f_pic.imgkey)
            url = url + "=s400"
            displayImages.append(url)
            print url

           # print f_pic.uploaddate


        dictPassed = {'displayImages':displayImages,'caption':caption}
        jsonObj = json.dumps(dictPassed, sort_keys=True,indent=4, separators=(',', ': '))
        self.response.write(jsonObj)
开发者ID:xiangkundai,项目名称:ConnexUs,代码行数:60,代码来源:view.py

示例9: post

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
 def post(self):
     original_url=self.request.headers['Referer']
     stream_name=re.findall('=(.*)%3D%3D',original_url)[0]
     stream=Stream.query(Stream.name==stream_name, Stream.author==users.get_current_user()).fetch()[0]
     dellsts=self.request.get_all("status")
     pictures=db.GqlQuery("SELECT * FROM Picture " +"WHERE ANCESTOR IS :1 AND id IN :2",db.Key.from_path('Stream',stream_name),dellsts)
     db.delete(pictures)
     stream.numberofpictures=stream.numberofpictures-len(dellsts)
     stream.put()
     self.redirect(original_url)
开发者ID:xiangkundai,项目名称:Mini1_APT,代码行数:12,代码来源:viewsinglestream.py

示例10: get

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
 def get(self):
     original_url = self.request.headers["Referer"]
     dellsts = self.request.get_all("status")
     if len(dellsts) > 0:
         streams = Stream.query(Stream.name.IN(dellsts), Stream.author == users.get_current_user()).fetch()
         for stream in streams:
             pictures = db.GqlQuery(
                 "SELECT * FROM Picture " + "WHERE ANCESTOR IS :1", db.Key.from_path("Stream", stream.name)
             )
             db.delete(pictures)
         ndb.delete_multi(ndb.put_multi(streams))
     self.redirect(original_url)
开发者ID:xiangkundai,项目名称:Mini1_APT,代码行数:14,代码来源:management.py

示例11: get

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def get(self):
        self.response.write(VIEW_SINGLE_STREAM_TEMPLATE)

        stream_name=re.findall('%3D(.*)',self.request.url)[0]

        self.response.write('<h2 >%s</h2>' %stream_name)
        #Change!# stream=Stream.query(Stream.name==stream_name, Stream.author==users.get_current_user()).fetch()[0]
        stream=Stream.query(Stream.name==stream_name).fetch()[0]

        pictures=db.GqlQuery("SELECT *FROM Picture " + "WHERE ANCESTOR IS :1 " +"ORDER BY uploaddate DESC LIMIT 3" , db.Key.from_path('Stream',stream_name))

        self.response.write('<table border="1" style="width:100%"><tr>')
        for picture in pictures:
            self.response.out.write('<td><img src="img?img_id=%s"></img></td>' %picture.key())

        self.response.write('</tr></table>')

        # url=urllib.urlencode({'showmore': stream.name+"=="+users.get_current_user().nickname()})
        # self.response.write('<form action="%s" ,method="post"><input type="submit" value="More Pictures"></form>' %url)

        #Change! Added if-else#
        # if stream.author==users.get_current_user():
        if users.get_current_user() and stream.author==users.get_current_user():
            url=urllib.urlencode({'showmore': stream.name+"=="+users.get_current_user().nickname()})
            self.response.write('<form action="%s" ,method="post"><input type="submit" value="More Pictures"></form>' %url)

            upload_url = blobstore.create_upload_url('/upload')
            self.response.out.write('<form action="/upload" method="post" enctype="multipart/form-data">')
            self.response.out.write("""Upload File: <input type="file"  name="file" ><br> <input type="submit" name="submit" value="Submit"> </form>""")
        else:
            #Change! Added#
            stream = Stream.query(Stream.name==stream_name).fetch()[0]
            count=CountViews.query(CountViews.name==stream.name,ancestor=ndb.Key('User',stream.author_name)).fetch()[0]
            count.numbers=count.numbers+1
            count.totalviews=count.totalviews+1
            count.put()

            url=urllib.urlencode({'showmore': stream.name+"=="+users.get_current_user().nickname()})
            self.response.write('<form action="%s" ,method="post"><input type="submit" value="More Pictures"></form>' %url)
            self.response.write('<form action="subscribe" method="post"><input type="submit" value="Subscribe"></form>')
开发者ID:xiangkundai,项目名称:Mini1_APT,代码行数:42,代码来源:viewsinglestream.py

示例12: post

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def post(self):
        stream_name=self.request.get("streamname")
        if len(stream_name)==0:
            stream_name="untitledstream"
        stream_tags=self.request.get("streamtags").split(',')
        stream_subscribers=self.request.get("subscribers").split(';')
        stream_url=self.request.get("url")
        emailContext = self.request.get("context")
        emailSubject = "Stream Update Info with UserID: " + users.get_current_user().nickname()
        emailSender = users.get_current_user().email()


        #Change! # streams=Stream.query(Stream.name==stream_name, Stream.author==users.get_current_user()).fetch()

        streams=Stream.query(Stream.name==stream_name).fetch()

        if (len(streams)<1):
            stream=Stream()
            count=CountViews(parent=ndb.Key('User',users.get_current_user().nickname()))
            pic_num = Count_pic(parent = ndb.Key('Stream',stream_name))
            pic_num.numbers = 0
            pic_num.put()
            stream.name=stream_name
            count.name=stream_name
            count.numbers=0
            count.totalviews = 0
            count.put()
            stream.numberofpictures=0
            stream.total=0
            stream.author=users.get_current_user()
            stream.author_name=users.get_current_user().nickname()
            stream.url=urllib.urlencode({'streamname': stream.name})
            stream.guesturl=urllib.urlencode({'showmore': stream.name+"=="+users.get_current_user().nickname()})
            default_context = "Notice: " + users.get_current_user().nickname() + " add a new stream named '" + stream_name +"' and the link to the stream is: "+"http://mini1-test1.appspot.com/"+stream.guesturl+"\n\n"

            if len(stream_tags) > 0:
                stream.tag=stream_tags
            if len(stream_subscribers[0])>0:
                stream.subscribers=stream_subscribers
                for emailReceiver in stream.subscribers:
                    mail.send_mail(sender = emailSender, to = emailReceiver, subject = emailSubject, body = default_context + emailContext)

            if len(stream_url) > 0:
                stream.coverurl = stream_url
            else:
                stream.coverurl = "https://pbs.twimg.com/profile_images/3207366683/25547cceacb728c382e49cd34d9e800a.png"


            stream.put()
            self.redirect('/management',permanent=False)
        else:
            self.redirect('/error', permanent = False)
开发者ID:xiangkundai,项目名称:ConnexUs,代码行数:54,代码来源:createstream.py

示例13: get

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def get(self):

        self.response.write(TRENDING_TEMPLATE)
        gl=Global.query(Global.name=="global").fetch()
        if(len(gl)>0):
            gl=gl[0]
        #streams=Stream.query(Stream.author==users.get_current_user()).order(-Stream.views).fetch(3)
        counts=CountViews.query().order(-CountViews.numbers).fetch(3)

        self.response.write('<table style = "width:70%">')
        for count in counts:
            stream=Stream.query(Stream.name==count.name).fetch()
            if (len(stream)>0):
                stream = stream[0]
                self.response.out.write('<td><div style = "position:relative;"><a href="%s"><img src="%s" ></img><div style = "position: absolute; left:0px; top:0px">%s</div></a></div><div>%s views in the past hour</div></td>' % (stream.url,stream.coverurl,stream.name,count.numbers))

        self.response.write('</table>')

        self.response.write('<form action="/update" method="post">')
        self.response.write('<input type="radio" name="frequency" value="no">No reports<br>')
        self.response.write('<input type="radio" name="frequency" value="5m">Every 5 minutes<br>')
        self.response.write('<input type="radio" name="frequency" value="1h">Every 1 hour<br>')
        self.response.write('<input type="radio" name="frequency" value="1d">Every day<br>')
        self.response.write('<input type="submit" value="Update rate"></form>')

        gl=Global.query(Global.name=="global").fetch()
        if(len(gl)>0):
            gl=gl[0]
            fre=gl.limit
            if fre==0:
                str="No reports"
            if fre==1:
                str="Every 5 Minutes"
            if fre==12:
                str="Every 1 hour"
            if fre==288:
                str="Every day"
            self.response.write("Current Update Frequency: "+ str)
开发者ID:xiangkundai,项目名称:Mini1_APT,代码行数:40,代码来源:trending.py

示例14: get

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import query [as 别名]
    def get(self):
        print("test!!")
        dellsts=self.request.get_all("status")
        if (len(dellsts) > 0):
            streams=Stream.query(Stream.name.IN(dellsts), Stream.author==users.get_current_user()).fetch()
            counts=CountViews.query(CountViews.name.IN(dellsts), ancestor=ndb.Key('User', users.get_current_user().nickname())).fetch()
            for stream in streams:
                pictures=db.GqlQuery("SELECT * FROM Picture " +"WHERE ANCESTOR IS :1",db.Key.from_path('Stream',stream.name))
                for pic in pictures:
                    images.delete_serving_url(pic.imgkey)
                    blobstore.delete(pic.imgkey)
                db.delete(pictures)
                pic_count= Count_pic.query(ancestor=ndb.Key('Stream',stream.name))
                ndb.delete_multi(ndb.put_multi(pic_count))
                #print pic_count
            ndb.delete_multi(ndb.put_multi(streams))
            ndb.delete_multi(ndb.put_multi(counts))
        dellsts=self.request.get_all("status1")
        #self.response.write(len(dellsts))
        if (len(dellsts) > 0):
            streams=Stream.query(Stream.name.IN(dellsts)).fetch()
            for stream in streams:
                if(users.get_current_user() and users.get_current_user().nickname() in stream.subscribers):
                    stream.subscribers.remove(users.get_current_user().nickname())
                    stream.put()



        picNum_list = []
        streams_1=Stream.query(Stream.author==users.get_current_user()).order(-Stream.creattime).fetch()
        for stream in streams_1:
           pic_count= Count_pic.query(ancestor=ndb.Key('Stream',stream.name)).fetch()[0]
           pictures=db.GqlQuery("SELECT * FROM Picture " +"WHERE ANCESTOR IS :1 "+"ORDER BY uploaddate DESC",db.Key.from_path('Stream',stream.name))
          # print (stream.name, pic_count.numbers)
          # picNum_list.append(pic_count.numbers)
           picNum_list.append(pictures.count())
        streams = Stream.query().fetch()
        streams_2 = []
        count_list = []
        user_name = users.get_current_user().nickname()
       # url =users.create_login_url('/')
      #  if(users.get_current_user()):
            #user_name = users.get_current_user().nickname()
        url = users.create_logout_url('/')
        for stream in streams:
            if(users.get_current_user().email().lower() in stream.subscribers):
                count=CountViews.query(CountViews.name==stream.name,ancestor=ndb.Key('User',stream.author_name)).fetch()[0]
                pictures=db.GqlQuery("SELECT * FROM Picture " +"WHERE ANCESTOR IS :1 "+"ORDER BY uploaddate DESC",db.Key.from_path('Stream',stream.name))

                stream.numberofpictures = pictures.count()
                streams_2.append(stream)
                count_list.append(count.numbers)

        #else:
         #   self.redirect(url,permanent=False)

        template_values = {
                'user_name':user_name,
                'streams_1': streams_1,
                'streams_2': streams_2,
                'count_list': count_list,
                'url': url,
            "picNum_list":picNum_list
        }

        template = JINJA_ENVIRONMENT.get_template('management_index.html')
        self.response.write(template.render(template_values))
开发者ID:xiangkundai,项目名称:ConnexUs,代码行数:69,代码来源:management.py


注:本文中的stream.Stream.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。