什么是Python中的DeprecationWarning?

时间:2019-03-13 14:05:56

标签: python flask

尝试使用Flask开发Python应用程序,以使用OData服务连接到SAP HANA。尝试打开url时,整个应用程序崩溃,并且我收到DeprecationWarning。弃用警告的目的是什么?

from flask import Flask, render_template, request
from pyslet.odata2.client import Client
from pyslet.http.auth import BasicCredentials
from pyslet.http.client import Client as http
from pyslet.http.client import ClientRequest

app = Flask(__name__)

@app.route('/')
def test():
    return('test')

@app.route('/odata')
def hello():
    table = testClient()
    return render_template('odata.html', table=table)

def testClient():
    c = MyAuthenticatedClient('link to xso data')
    table = c.feeds['MarketShareFSet'].OpenCollection()
    tablenames = []
    for t in table.iteritems():
        c1 = p['ID'].value
        c2 = p['Country'].value
        c3 = p['Hub'].value
        c4 = p['Division'].value
        tablenames.append((c1, c2,c3,c4))

    return tablenames
127.0.0.1 - - [13/Mar/2019 13:59:40] "GET / HTTP/1.1" 200 -
main.py:23: DeprecationWarning: EntitySet.OpenCollection is deprecated, use open instead
  table = c.feeds['MarketShareFSet'].OpenCollection()

1 个答案:

答案 0 :(得分:0)

来自维基百科:

  

在某些领域,弃用是不鼓励使用某些术语,功能,设计或实践,通常是因为已被取代或不再被认为是有效或安全的,而没有完全删除或禁止使用。

警告您,OpenCollection()方法现在不是使用的最佳选择(无论出于何种原因),最佳实践是改为使用open()方法。

通常,在软件中,事物会贬值,然后在以后的发行版中不再受支持或删除。