这个问题在这里已有答案:
尝试使用Flask开发Python应用程序,以使用OData服务连接到SAP HANA。当试图打开网址时,整个应用程序崩溃,我得到一个DeprecationWarning。 DeprecationWarnings的目的是什么?
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()
来自维基百科:
在一些领域,弃用是对某些术语,特征,设计或实践的使用的阻碍,通常是因为它已被取代或不再被认为是有效或安全的,没有完全删除它或禁止使用它。
它警告你,OpenCollection()
方法现在不是最好的选择(无论出于何种原因),最佳做法是使用open()
方法代替。
通常在软件中,事物会变得折旧,然后在以后的版本中不再支持或删除。