web2py

Reading file content from uploaded text file

[亡魂溺海] 提交于 2019-12-07 15:06:34
I have an uploaded file in uploads folder and i need to read the contents from it in the controller for processing it further. I have very basic knowledge of web2py and couldn't understand how to do it. Anthony You can do something like: import os filename = db.mytable(record_id).myfile content = open(os.path.join(request.folder, 'uploads', filename), 'rb').read() UPDATE: Here is a somewhat simpler approach. 来源: https://stackoverflow.com/questions/26968216/reading-file-content-from-uploaded-text-file

How to pass a JSON object to web2py using JQuery Ajax

十年热恋 提交于 2019-12-07 12:49:49
问题 I've used this method in .NET to pass data back and forth between client and server using JSON objects (both ways). I really liked the method and am looking to do something similar with web2py. Web2py supports returning json objects and supports jsonrpc. I haven't however been able to make it parse a JSON object. My client call looks like this: var testObject = {}; testObject.value1 = "value1value!"; testObject.value2 = "value2value!"; var DTO = { 'testObject' : testObject }; var data = $

Processing ember.js tagged html with python

孤街醉人 提交于 2019-12-07 12:41:44
问题 I have the following scenario: We are using web2py in the server side We are serving some ember.js pages Currently those ember.js pages are inside an iframe, because ember.js and web2py conflict with template {{ }} marks. That means we can not easily mix web2py templates and ember.js templates. So I have implemented the helper class solution: class em(DIV) Now I want to process the original ember-tagged html files, and produce the em-tagged files, integrating ember.js and web2py templating

Formatting date in Web2py Python

蹲街弑〆低调 提交于 2019-12-07 12:40:49
问题 I'm looking for a function to format a date in order to get day, month and year. Dates are being stored in my database in the following format 2012-09-26. 回答1: If your goal is to display on web2py template, so you have to use pure Python to format {{=row.datetime_field.strftime("%d/%m/%Y")}} The above will generate 25/09/2012 Tale a look at Python strftime documentations. If you want to show only the day. {{=row.datetime_field.date}} Also you can set it as a representation for that field db

web2py git integration - localhost & pythonanywhere

为君一笑 提交于 2019-12-07 12:12:32
问题 I have absolutely no idea how to integrate Github into web2py. I have web2py installed on a usb and also on pythonanywhere. The web2py overview document chapter3 http://web2py.com/books/default/chapter/29/03/overview says : Git integration The admin app also includes git integration. Python git libraries are required, e.g. pip install gitpython This doesn't mean a thing to me!!? I am just getting into programming and trying to make sure everything is set up properly! Any help would be really

How do I get the current url in web2py?

北城余情 提交于 2019-12-07 08:35:31
问题 In web2py how do I get the complete url of the current page? I want the (possibly rewritten) url that appears in the browser address bar. e.g. http://www.example.com/products/televisions?sort=price&page=2 回答1: The easiest method to generate this is probably: URL(args=request.args, vars=request.get_vars, host=True) You could also assemble the URL this way: '%s://%s%s' % (request.env.wsgi_url_scheme, request.env.http_host, request.env.web2py_original_uri) 回答2: I know this is an old thread -

can we use java code in web2py application code?

戏子无情 提交于 2019-12-07 04:57:25
I have to implement one web2py application which has to access java code (which has code to connect to the remote machine) but not sure whether we can do it in web2py or not.My PC has Java 1.6, Python2.7 ,web2py ,eclipse installed. Use case is : I have created one button in web2py application and upon clicking the button, it should instantiate the java object and invoke particular method of that java object which will further connect to the remote machine. Doubts are: Can we deploy that particular java class to web2py server so web2py application can easily access it? Is it possible to import

Web2py: downloading files / displaying images

巧了我就是萌 提交于 2019-12-07 00:30:01
I've recently jumped into Web2py framework which I find very good. However, I'm now stuck with a 'basic' problem. Context The website I'm building is an interface for scientific code: people fills-in a form and submit it. The data (written in a file inside a shared folder) is then being processed by the code, running as a daemon in the background (the code has no link with the website, excepts this shared folder and a JSONRPC link between code->website ). The code generates files and images that I would like to make available to the website users (ie. returning them back the results they asked

Multi-Column Unique Constraint with web2py

喜你入骨 提交于 2019-12-06 23:35:16
问题 It is possible to mark a particular column as unique=true. What is the most correct way to handle multi-column unique constraints in web2py? For example, say I have an exchange rate table. It could have columns from-currency, to-currency and the exchange rate. It would not make sense to have two rows with the same from and to currencies. What would be the most elegant or correct way to make the from/to combination unique? 回答1: Assuming the data will be entered via a form, you could use a form

Asynchronous background processes with web2py

青春壹個敷衍的年華 提交于 2019-12-06 23:01:36
问题 I need to to handle a large (time and memory-consuming) process asynchronously in a web2py application called inside a controller method. My specific use case is to call a process via stdlib.subprocess and wait for it to exit without blocking the web server, but I am open to alternative methods. Hands-on examples would be a plus. 3rd party library recommendations are welcome. CRON scheduling is not required/wanted. 回答1: Assuming you'll need to start multiple, possibly simultaneous, instances