How to search a word in a file from a cakephp view?
I am working on an app designed on cakephp framework which is taking data from twitter. I have to check the relevancy of the location, if the data in the location section is really 开发者_开发技巧relevant (city or a country). For this I have a python file (.py) which has all the reowned cities and all the country names, I have to search from a view file. Can any1 suggest me how to do this. Thanks
You do not do any logic from a view file. Views are only meant to render data already present. You are supposed to gather your data within a Controller.
In CakePHP you won't be able to call Python directly. It is possible though to:
- Call the Python interpreter directly, i.e. use system or exec call.
- Communicate with the running Python program via SOAP or REST (e.g. cURL).
- If you are on a Unix box, you have can do IPC via named pipes.
精彩评论