我有view_xx.py和view_yy.py,我也有一个共同的views.py 我想验证一下request.page_size是否小于或等于request.registry.settings [“ max_page_size”]
如何在通用views.py中执行此操作? 是否可以使用上下文?
我不确定如何放置上下文,以便它首先根据URL转到view_xx.py,然后转到通用视图函数以验证页面大小,然后再次返回view_xx.py视图以进行进一步的操作。
答案 0 :(得分:0)
最简单的方法是在设置/计算import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
public class AsyncExample extends Activity{
private String url="http://www.google.co.in";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
apiCall();
}
private void apiCall() {
new AsyncCaller().execute();
}
private class AsyncCaller extends AsyncTask<Void, Void, Void>
{
ProgressDialog pdLoading = new ProgressDialog(AsyncExample.this);
@Override
protected void onPreExecute() {
super.onPreExecute();
//this method will be running on UI thread
pdLoading.setMessage("\tLoading...");
pdLoading.show();
}
@Override
protected Void doInBackground(Void... params) {
//this method will be running on background thread so don't update UI frome here
//do your long running http tasks here,you dont want to pass argument and u can access the parent class' variable url over here
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
//this method will be running on UI thread
pdLoading.dismiss();
}
}
}
时执行该检查。