[web2py] Re: widgets
Thank for your suggest. I am amazed because my code SQLFORM contains two fields, only one with widget that i made. Observing the result html page code there is no evident difference between two fields. Correct id and correct name, but only one exists in form.vars. I thougth that every input tag existing in form becames form.var, but apparently it is false. So, to debug my error, I need know how form.vars are built and where in web2py code. Can you suggest where i can address my attenction? Thanks leone On 13 Giu, 03:44, Iceberg wrote: > On Jun12, 12:47pm, leone wrote: > > > I coded a widget to use with a Field object. > > Because I need some javascript actions i wrote pure html-javascript > > code that my widget returns. > > It runs, but when I accept the form values are in request.vars, but > > not in form.vars. > > How can i store values in form.vars without using input widgets > > defined by SQLFORM.widgets...? > > Thanks in advance > > leone > > You'd better let your widget derive from the default widgets, or you > need to make sure yours contain proper _id and _name etc. > > See alsohttp://web2py.com/book/default/section/7/5?search=widgets
[web2py] Re: widgets
I used your suggest, without success. My code: form = SQLFORM.factory ( Field('test1','string', widget=mywidget, default='...'), Field('test2','string', widget=mywidget, default='...'), ) def mywidget(field, value): _id = '%s_%s' % (field._tablename, field.name) _name = field.name .. lst = _funcxxx(value) script = SCRIPT(..) select = SELECT( lst, _name=_name, _id=_id, _class=field.type, _value=value, _onchange="javascript: getcontent();" ) return DIV(select, script) form.vars ---> after form.accepts values of testx are correctly stored in request.vars Where is my error Thanks On 13 Giu, 04:04, "mr.freeze" wrote: > Here are some examples that may > help:http://www.web2pyslices.com/main/default/search?query=7&criteria=cate... > > As Iceberg says, your widget must have the proper attributes to be > accepted by form.accepts. I like to render the field using the default > widget then modify it. This way I know it has the proper attributes. > > def my_widget(f,v): > inp = SQLFORM.widgets.string.widget(f,v) #or another depending on > field > scr = SCRIPT('...',_type=''text/javascript') > return DIV(inp,scr) > > On Jun 11, 11:47 pm, leone wrote: > > > > > I coded a widget to use with a Field object. > > Because I need some javascript actions i wrote pure html-javascript > > code that my widget returns. > > It runs, but when I accept the form values are in request.vars, but > > not in form.vars. > > How can i store values in form.vars without using input widgets > > defined by SQLFORM.widgets...? > > Thanks in advance > > leone
[web2py] PIL to change images on the fly...
I want to use PIL to change images to be smaller so they render faster, I could do it like this where they are entered into a database and uploaded, but I have up to 8 different sizes to work with,and with a constantly changing design, it would be difficult to make the database changes as well. This was the example I found but it uses the database and a second upload. http://groups.google.com/group/web2py/browse_frm/thread/e2640890d99cf6b5/c213a917b8448ab8?lnk=gst&q=import+image#c213a917b8448ab8 I would like to make it so I can pass a function the file location db.stuff.photo and it would return something I could pass to the view. Hepe that makes sence. Best Regards, Jason Brower
[web2py] Re: flot related help
Thanks, it helps On Jun 9, 4:36 pm, mdipierro wrote: > Although this does not usesflot, it can give an idea. > > http://web2py.com/appliances/default/show/12 > > On Jun 9, 3:20 pm, dbb wrote: > > > Hello: > > I am trying to useflotto draw a graph by reading the data from the > > database > > I am stuck, need an example
[web2py] Re: upgrade rocket error with ssl
Problem solved. Python 2.5 does not include an ssl module and I guess openssl isn't good enough. I had to download the ssl 1.15 package from the python website and manually build & install it. The server now executes as expected. On Jun 12, 4:47 pm, The Czar wrote: > Some additional information: running python-2.5,2 and web2py 1.78.3 > has exactly the same problem. > > On Jun 12, 10:38 am, The Czar wrote: > > > Duh. Sorry - it is the source on FreeBSD > > > On Jun 12, 8:04 am, mdipierro wrote: > > > > did you upgrade the source or binary version? windows or mac? > > > > On Jun 12, 9:36 am, The Czar wrote: > > > > > I just upgraded from 1.76 to 1.79.2 using the built-in upgrade > > > > feature. Attempting to start the server with SSL yields the following > > > > error. Any ideas on what's happening here? BTW - the gluon code looks > > > > redundant - am I missing something? Thanks in advance. > > > > > here is the startup info: > > > > python web2py.py -a -i 192.168.1.2p 8040 -c security/ > > > > ebuyasst.crt -k security/ebuyasst.key > > > > web2py Enterprise Web Framework > > > > Created by Massimo Di Pierro, Copyright 2007-2010 > > > > Version 1.79.2 (2010-06-08 22:45:26) > > > > Database drivers available: SQLite3, MySQL > > > > Starting hardcron... > > > > please visit: > > > > http://192.168.1.2:8040 > > > > use "kill -SIGTERM 30722" to shutdown the web2py server > > > > Traceback (most recent call last): > > > > File "web2py.py", line 20, in > > > > gluon.widget.start(cron=True) > > > > File "/m/content/www/data/ebuyasst.new/gluon/widget.py", line 863, > > > > in start > > > > path=options.folder) > > > > File "/m/content/www/data/ebuyasst.new/gluon/main.py", line 622, in > > > > __init__ > > > > elif not rocket.ssl: > > > > AttributeError: 'module' object has no attribute 'ssl' > > > > > == > > > > > The code in the gluon module looks like this: (line 622 is ***) > > > > if not ssl_certificate or not ssl_private_key: > > > > logging.info('SSL is off') > > > > *** elif not rocket.ssl: > > > > logging.warning('Python "ssl" module unavailable. SSL is > > > > OFF') > > > > if not ssl_certificate or not ssl_private_key: > > > > logging.info('SSL is off') > > > > elif not rocket.ssl: > > > > logging.warning('Python "ssl" module unavailable. SSL is > > > > OFF') > > > > elif not os.path.exists(ssl_certificate): > > > > logging.warning('unable to open SSL certificate. SSL is > > > > OFF') > > > > elif not os.path.exists(ssl_private_key): > > > > logging.warning('unable to open SSL private key. SSL is > > > > OFF') > > > > else: > > > > sock_list.extend([ssl_private_key, ssl_certificate]) > > > > logging.info('SSL is ON')
[web2py] Re: upgrade rocket error with ssl
Problem solved. Python 2.5 does not include an ssl module and I guess openssl isn't good enough. I had to download the ssl 1.15 package from the python website and manually build & install it. The server now executes as expected. On Jun 12, 8:04 am, mdipierro wrote: > did you upgrade the source or binary version? windows or mac? > > On Jun 12, 9:36 am, The Czar wrote: > > > I just upgraded from 1.76 to 1.79.2 using the built-in upgrade > > feature. Attempting to start the server with SSL yields the following > > error. Any ideas on what's happening here? BTW - the gluon code looks > > redundant - am I missing something? Thanks in advance. > > > here is the startup info: > > python web2py.py -a -i 192.168.1.2p 8040 -c security/ > > ebuyasst.crt -k security/ebuyasst.key > > web2py Enterprise Web Framework > > Created by Massimo Di Pierro, Copyright 2007-2010 > > Version 1.79.2 (2010-06-08 22:45:26) > > Database drivers available: SQLite3, MySQL > > Starting hardcron... > > please visit: > > http://192.168.1.2:8040 > > use "kill -SIGTERM 30722" to shutdown the web2py server > > Traceback (most recent call last): > > File "web2py.py", line 20, in > > gluon.widget.start(cron=True) > > File "/m/content/www/data/ebuyasst.new/gluon/widget.py", line 863, > > in start > > path=options.folder) > > File "/m/content/www/data/ebuyasst.new/gluon/main.py", line 622, in > > __init__ > > elif not rocket.ssl: > > AttributeError: 'module' object has no attribute 'ssl' > > > == > > > The code in the gluon module looks like this: (line 622 is ***) > > if not ssl_certificate or not ssl_private_key: > > logging.info('SSL is off') > > *** elif not rocket.ssl: > > logging.warning('Python "ssl" module unavailable. SSL is > > OFF') > > if not ssl_certificate or not ssl_private_key: > > logging.info('SSL is off') > > elif not rocket.ssl: > > logging.warning('Python "ssl" module unavailable. SSL is > > OFF') > > elif not os.path.exists(ssl_certificate): > > logging.warning('unable to open SSL certificate. SSL is > > OFF') > > elif not os.path.exists(ssl_private_key): > > logging.warning('unable to open SSL private key. SSL is > > OFF') > > else: > > sock_list.extend([ssl_private_key, ssl_certificate]) > > logging.info('SSL is ON')
[web2py] Multiple domains one web2py installation.
I posted the following question at WebFaction: One of my customers asked me whether it would be possible to have his domain centralfit.nl reference a page within my web2py app. Is this simply a matter of adding the domain centralfit.nl to the Control Panel, and creating a website that references this single page, by entering a website name 'centralfit', selecting the subdomain www.centralfit.nl which corresponds to the website record and adding a site app where 'customweb2py' is the app and /init/homepage/index/443 is the URL in which 'init' is the application, 'homepage' is the controller, 'index' is the function and '443' is the argument. Or isn't it this simple? There reply reads as follows: If you do what you described, you would end up with your "customweb2py" app available through http://www.centralfit.nl/init/homepage/index/443; no page will be displayed at http://www.centralfit.nl though. You will definitely need a second application if you want http://www.centralfit.nl to show different pages than http://www.fitwise.nl I wonder whether this is a limitation of WebFaction or a limitation in general. I built an application that, based on a company_id, exposes a fully functional web application. If the customers domain cannot reference this application, this idea is useless. Is there a way to solve this problem? Kind regards, Annet.
[web2py] Internationalization of invalidators' error_message
I don't understand why not the invalidators' error_message only use English. eg. class IS_NOT_EMPTY(Validator): def __init__(self, error_message='enter a value', empty_regex=None): why not class IS_NOT_EMPTY(Validator): def __init__(self, error_message=T('enter a value'), empty_regex=None): I don't want to assign every IS_NOT_EMPTY's error_message.
[web2py] Multiple domains one web2py installation.
I posted the following question at WebFaction: One of my customers asked me whether it would be possible to have his domain centralfit.nl reference a page within my web2py app. Is this simply a matter of adding the domain centralfit.nl to the Control Panel, and creating a website that references this single page, by entering a website name 'centralfit', selecting the subdomain www.centralfit.nl which corresponds to the website record and adding a site app where 'customweb2py' is the app and /init/homepage/index/443 is the URL in which 'init' is the application, 'homepage' is the controller, 'index' is the function and '443' is the argument. Or isn't it this simple? There reply reads as follows: If you do what you described, you would end up with your "customweb2py" app available through http://www.centralfit.nl/init/homepage/index/443; no page will be displayed at http://www.centralfit.nl though. You will definitely need a second application if you want http://www.centralfit.nl to show different pages than http://www.fitwise.nl I wonder whether this is a limitation of WebFaction or a limitation in general. I built an application that, based on a company_id, exposes a fully functional web application. If the customers domain cannot reference this application, this idea is useless. Is there a way to solve this problem? Kind regards, Annet.
[web2py] Re: Multiple domains one web2py installation.
To add to the confusion: On my follow up question: So, I would need an installation of web2py for every customer who would like to have his domain reference a function within my application? And this also holds true, if I'd install an application for that customer within web2py? I received this reply: You would need a separate application for each separate domain name that you want to display a different page on, unless the same web2py application can serve different pages, based on the domain name that is used - and I am not aware of such a feature. You might want to check with the web2py developers whether it is possible to serve different pages based on the domain name that is used in the HTTP request. The separate application can be a full fledged web2py installation, or a redirect to the main URL (e.g.to http://www.centralfit.nl/init/homepage/index/443) , or an iframe page used to mask to actual URL, or a simple HTML copy of the page(s) your web2py installation generates, or anything that displays the content you want to see actually. I guess the feature mentioned is routes.py? The second part of the reply doesn't ring a bell at all, I hope one of you can tell me what is being explained here. Kind regards, Annet.
[web2py] Re: widgets
Can you show me the html that is produced by your widget and the html produced by default? On Jun 13, 3:27 am, leone wrote: > I used your suggest, without success. > My code: > > form = SQLFORM.factory ( > Field('test1','string', widget=mywidget, > default='...'), > Field('test2','string', widget=mywidget, > default='...'), > ) > > def mywidget(field, value): > _id = '%s_%s' % (field._tablename, field.name) > _name = field.name > .. > lst = _funcxxx(value) > script = SCRIPT(..) > select = SELECT( > lst, > _name=_name, > _id=_id, > _class=field.type, > _value=value, > _onchange="javascript: getcontent();" > ) > return DIV(select, script) > > form.vars ---> after form.accepts > values of testx are correctly stored in request.vars > > Where is my error > Thanks > > On 13 Giu, 04:04, "mr.freeze" wrote: > > > Here are some examples that may > > help:http://www.web2pyslices.com/main/default/search?query=7&criteria=cate... > > > As Iceberg says, your widget must have the proper attributes to be > > accepted by form.accepts. I like to render the field using the default > > widget then modify it. This way I know it has the proper attributes. > > > def my_widget(f,v): > > inp = SQLFORM.widgets.string.widget(f,v) #or another depending on > > field > > scr = SCRIPT('...',_type=''text/javascript') > > return DIV(inp,scr) > > > On Jun 11, 11:47 pm, leone wrote: > > > > I coded a widget to use with a Field object. > > > Because I need some javascript actions i wrote pure html-javascript > > > code that my widget returns. > > > It runs, but when I accept the form values are in request.vars, but > > > not in form.vars. > > > How can i store values in form.vars without using input widgets > > > defined by SQLFORM.widgets...? > > > Thanks in advance > > > leone > >
Re: [web2py] Re: Multiple domains one web2py installation.
please take a look if that is what you need http://groups.google.com/group/web2py/browse_thread/thread/fac136d7e1120166/b9a4f8eb744e29cb notes: - I also use webfaction - webfaction application is a different thing than a web2py application
[web2py] Re: Multiple domains one web2py installation.
Hi Vasile, > please take a look if that is what you > needhttp://groups.google.com/group/web2py/browse_thread/thread/fac136d7e1... Thanks for pointing me in the right direction. I'll give it a try and let you know if it works. > - webfaction application is a different thing than a web2py application I know, I installed web2py using their custom install script and named the application customweb2py. The web2py applications are located in customweb2py/web2py/applications/ Do you know whether there is a limit to the number of applications you can have within web2py and routes.py. According to webfaction's support people you cannot install only one web2py application in an account, when I install a second web2py called secondweb2py, how do customweb2py and secondweb2py know about each others existence? Kind regards, Annet.
[web2py] Re: upload file -- lot of file in one directory
Aha! So then could you write the following: import random Field('filename','upload', uploadfolder=['c:/web2py/myapp/uploads','d:/extrastorage/myapp/ uploads'][random.randint(0,1)], uploadseparate=2, ) and expect the files to be uniformly distributed across 2 filesystems? That (or its equivalent) would be awesome. On Jun 12, 4:20 pm, szimszon wrote: > No because you can specify the location of uploaded material so it can > be on any filesystem, and uploadseparate work under uploadfolder to... > > On jún. 12, 21:57, weheh wrote: > > > > > One more question -- doesn't this eliminate the need for > > Field(...uploadfolder=pathname,...)? I suppose keeping the > > uploadfolder parameter is a good thing to keep for anyone who wants to > > use it for their own special purpose. But if the issue is about > > storing a gazillion upload files for efficient retrieval, then this > > new method does it for you automatically without having to resort to > > uploadfolder=pathname. Right?- Hide quoted text - > > - Show quoted text -
[web2py] Re: Multiple domains one web2py installation.
On Jun 13, 9:51 am, annet wrote: > Hi Vasile, > > > please take a look if that is what you > > needhttp://groups.google.com/group/web2py/browse_thread/thread/fac136d7e1... > > Thanks for pointing me in the right direction. I'll give it a try and > let you know if it works. > > > - webfaction application is a different thing than a web2py application > > I know, I installed web2py using their custom install script and named > the application customweb2py. The web2py applications are located in > customweb2py/web2py/applications/ > > Do you know whether there is a limit to the number of applications you > can have within web2py and routes.py. Annet - It might be useful for you to draw a diagram. You are talking about two instances of web2py server; Each server can have many applications; >From webfaction's perspective - web2py is an "application"; from web2py's perspective - "welcome" is an application; If you draw a map of client request => dsn-lookup => your apache instance => wsgi => web2py => application you can start to see where things happen more clearly. For example: your client wants to have _their_ xxx.com redirect you annet.com/something/default/index: Where in your map can this be done? One is to have xxx.com (someone elses server) redirect (that then becomes a new request, i.e. a new address+parameters set); Another is to have two dns entries point to the same apache instance - for example, from panel.webfaction.com, menu: Domains/websites >> Websites, you can set more than one domain to point to your single web2py installation ( Domain/websites >> Applications) --- ie. you can have this.foo.com and www.bar.com both point to (for example) customweb2py: /my_web2py_app --- this represents webfaction setting up (in essence) your apache instance for you (through the panel). As you start to ask the questions of "what comes in at this point?" and "what can be done at this level", you will start seeing more clearly what your possibilities are, and then can start asking yourself what the various tradeoffs are for redirections etc. at various points in your map. There are various tools, command line and network monitoring that you can get into if you want to see more details of what is going back and forth, but start by making some model for yourself of what the path is from that web browser to your controller. I hope this is helpful. Regards, - Yarko > > According to webfaction's support people you cannot install only one > web2py application in an account, when I install a second web2py > called secondweb2py, how do customweb2py and secondweb2py know about > each others existence? > > Kind regards, > > Annet.
[web2py] Select the most recent entry from multiple tables
Hi all, it is possible to make a query to the db and sort the elements of multiple tables by date? I will try to be more specific with an example, I have this controller, the structure of the model should be evident: def index(): # This is the index controller dataset_one = db().select(db.dataset_one.id, db.dataset_one.title, orderby= ~db.dataset_one.created_on) dataset_one = dataset_one[:2] # limits to the last two results dataset_two = db().select(db.dataset_two.id, db.dataset_two.title, orderby= ~db.dataset_two.created_on) dataset_two = dataset_two[:2] # limits to the last two results return dict(dataset_one=dataset_one, dataset_two=dataset_two) it return two dictionaries with the last 2 entry for dataset_one and dataset_two (4 total in 2 dict). But what I want to accomplish is to return only one dictionary with the two most recent entry from all dataset, so if the 2 most recent are from dataset_one the query get this results only and ignore dataset_two... To be honest I dont think is possible, but I will happy to be wrong. Sadly, I cant restructure the db... I hope to have made this question clear enough... My english is not very well... Thanks for any help!
[web2py] Re: difference between rows.json() and gluon.serializers.json(rows)
anyone? On Jun 12, 4:52 pm, NickFranceschina wrote: > if I have a records collection (of type Rows) from a select() call > through the DAL... why is the output different between these two > versions ofjsonconversion? > > >>> records.json() > > '[{"description": "my description", "created_by": 1, "id": 1, > "created_on": "2010-06-06 23:21:52", "name": "my name"}, > {"description": "moms community", "created_by": null, "id": 2, > "created_on": "2010-06-11 19:54:06", "name": "mom"}, {"description": > "dads community", "created_by": null, "id": 5, "created_on": > "2010-06-11 20:18:41", "name": "dad"}, {"description": "dads > community", "created_by": null, "id": 6, "created_on": "2010-06-12 > 16:28:19", "name": "dad"}]' > > >>> from gluon.serializers importjson > >>>json(records) > > '{"1": {"created_on": "2010-06-06 23:21:52", "description": "my > description", "name": "my name", "id": 1, "created_by": 1}, "2": > {"created_on": "2010-06-11 19:54:06", "description": "moms community", > "name": "mom", "id": 2}, "5": {"created_on": "2010-06-11 20:18:41", > "description": "dads community", "name": "dad", "id": 5}, "6": > {"created_on": "2010-06-12 16:28:19", "description": "dads community", > "name": "dad", "id": 6}}' > > the former is what I would expect... a list of dictionaries... > > the latter builds a dictionary of dictionaries...
[web2py] Re: difference between rows.json() and gluon.serializers.json(rows)
On Jun 13, 1:00 pm, NickFranceschina wrote: > anyone? > > On Jun 12, 4:52 pm, NickFranceschina > wrote: > > > > > if I have a records collection (of type Rows) from a select() call > > through the DAL... why is the output different between these two > > versions ofjsonconversion? > > > >>> records.json() this is implemented in gluon/dal.py as part of the Rows object, so records.json() returns the json representation for a row (therefore you don't have / see the index); > > > '[{"description": "my description", "created_by": 1, "id": 1, > > "created_on": "2010-06-06 23:21:52", "name": "my name"}, > > {"description": "moms community", "created_by": null, "id": 2, > > "created_on": "2010-06-11 19:54:06", "name": "mom"}, {"description": > > "dads community", "created_by": null, "id": 5, "created_on": > > "2010-06-11 20:18:41", "name": "dad"}, {"description": "dads > > community", "created_by": null, "id": 6, "created_on": "2010-06-12 > > 16:28:19", "name": "dad"}]' > > > >>> from gluon.serializers importjson > > >>>json(records) if you look at gluon/serializers.py, you will see that json() is simply a convenience for simplejson.dumps( item ) --- in this case, a Set - so you have a json representation of the Set (complete with id's). > > > '{"1": {"created_on": "2010-06-06 23:21:52", "description": "my > > description", "name": "my name", "id": 1, "created_by": 1}, "2": > > {"created_on": "2010-06-11 19:54:06", "description": "moms community", > > "name": "mom", "id": 2}, "5": {"created_on": "2010-06-11 20:18:41", > > "description": "dads community", "name": "dad", "id": 5}, "6": > > {"created_on": "2010-06-12 16:28:19", "description": "dads community", > > "name": "dad", "id": 6}}' > > > the former is what I would expect... a list of dictionaries... > > > the latter builds a dictionary of dictionaries...
[web2py] import of web2py modules very complicated
I found that importing modules in Web2py seems to be very complex: http://web2py.com/book/default/section/4/18 I have a module in 'modules' and I do 'import modules.my_module' to import the module in my application. This is working fine with Eclipse Pydev because I have setup the Python path for my application in Eclipse. But outside Eclipse, it does not work because the path is not there. Why should it be more complicated than that? I see this as a bug. I will modify my application to add the path but I believe this is the job of Web2py.
Re: [web2py] import of web2py modules very complicated
On Jun 13, 2010, at 4:46 PM, pierreth wrote: > I found that importing modules in Web2py seems to be very complex: > > http://web2py.com/book/default/section/4/18 > > I have a module in 'modules' and I do 'import modules.my_module' to > import the module in my application. > > This is working fine with Eclipse Pydev because I have setup the > Python path for my application in Eclipse. > > But outside Eclipse, it does not work because the path is not there. > > Why should it be more complicated than that? I see this as a bug. > > I will modify my application to add the path but I believe this is the > job of Web2py. Try local_import instead of import (same manual page).
[web2py] Unable to connect to mysql DB - sql.py mod
For some reason, attempted connection to a mysql v4.1.25 db on FreeBSD fails. The web2py is the latest version - but it happened on earlier versions also. The error & db.py for the application failing looks like this: Error traceback Traceback (most recent call last): File "/m/content/www/data/web2py-1-79-2/gluon/restricted.py", line 178, in restricted exec ccode in environment File "/m/content/www/data/web2py-1-79-2/applications/myapp/models/ db.py", line 15, in db = DAL('mysql://login:pas...@192.168.1.2/myapp') # use mySQL File "/m/content/www/data/web2py-1-79-2/gluon/sql.py", line 3855, in DAL raise RuntimeError, "Failure to connect to DB. Tried 5 times" RuntimeError: Failure to connect to DB. Tried 5 times In file: /m/content/www/data/web2py-1-79-2/applications/myapp/models/ db.py # -*- coding: utf-8 -*- # ## This scaffolding model makes your app work on Google App Engine too # if request.env.web2py_runtime_gae:# if running on Google App Engine db = DAL('gae') # connect to Google BigTable session.connect(request, response, db=db) # and store sessions and tickets there else: # else use a normal relational database db = DAL('mysql://login:pas...@192.168.1.2/myapp') # use mySQL = Now if I comment out line 934 in gluon/sql.py, it connects without error! The line looks like this: self._execute("SET sql_mode='NO_BACKSLASH_ESCAPES';") This has been the case from rel. 1.76 to current 1.79.2. Any ideas about this error & work around. I don't always remember to make the change for new releases and that causes unnecessary delay . Thanks.
[web2py] Insert current datetime in layout.html
Hi, how I can insert in a page not served by a controller (think layout.html in the welcome application) current day and month? I've tested something like this {{import datetime; datetime.datetime.now()}} but even if this worked it will be horrible (import datetime every single page load...)
[web2py] Multiple form submission - is doc wrong?
I have a multiple form submission with a custom form. #controller form1=SQLFORM.factory(db.table,...) form2=SQLFORM.factory(db.table,...) ... if form1.accepts(request.vars,formname='form1',onvalidation=xyz): ... do something ... if form2.accepts(request.vars,formname='form2',onvalidation=xyz): ... do something else ... # view ... form1.custom.begin ...widgets... form1.custom.end form2.custom.begin ... widgets ... form2.custom.end -- The above seems to work OK. However, the input string is at odds with what the doc says on p. 195: 7 When I recast my code as it doesn't work. Is the doc wrong?
[web2py] Re: Internal error
Hi Cory, it's very hard to tell from the info so far. good that you have narrowed it down to a DB issue. have you checked the error files that web2py produces to see what is in there? those "tickets" are often quite helpful. (excuse me if you already checked) my best guess though is that your database connection string is incorrect. cfh On Jun 12, 3:14 pm, Cory Coager wrote: > It seems to be failing on the model. I can't seem to get any DAL > working. If I do a simple hello world test it works fine. If I add > in a model like sqlite or postgresql, it gives "Internal error". > Whats going on here?
[web2py] Re: PIL to change images on the fly...
create a function for serving images, and add the sizes as parameters: http://mysite.com/applciation/images/download/foo.png/ 300/400" /> and in the function do the resize and output the binary data of the image. i'm not 100% sure of the best way to do it out side of google app engine (because they have a special image manipulation library), but i can share some code i used on google app engine to retrieve an image from blobstore, resize, and send to client if you think that will help you. cfh On Jun 13, 1:41 am, Jason Brower wrote: > I want to use PIL to change images to be smaller so they render faster, > I could do it like this where they are entered into a database and > uploaded, but I have up to 8 different sizes to work with,and with a > constantly changing design, it would be difficult to make the database > changes as well. > This was the example I found but it uses the database and a second > upload.http://groups.google.com/group/web2py/browse_frm/thread/e2640890d99cf... > > I would like to make it so I can pass a function the file location > db.stuff.photo and it would return something I could pass to the view. > Hepe that makes sence. > Best Regards, > Jason Brower
[web2py] Re: Internal error
Here is the error when using SQLite: Traceback (most recent call last): File "gluon/restricted.py", line 178, in restricted exec ccode in environment File "/path/to/applications/test/models/db.py", line 15, in ? db = DAL('sqlite://storage.sqlite') File "gluon/sql.py", line 3855, in DAL raise RuntimeError, "Failure to connect to DB. Tried 5 times" RuntimeError: Failure to connect to DB. Tried 5 times The databases directory is chmod 777.
[web2py] Re: Internal error
Here is the error when using PostGreSQL: Traceback (most recent call last): File "gluon/restricted.py", line 178, in restricted exec ccode in environment File "/path/to/applications/test/models/db.py", line 17, in ? db=SQLDB('postgres://user:p...@localhost:5432/database') File "gluon/sql.py", line 967, in __init__ self._execute("SET standard_conforming_strings=on;") File "gluon/sql.py", line 962, in self._execute = lambda *a, **b: self._cursor.execute(*a, **b) OperationalError: parameter "standard_conforming_strings" cannot be changed Looks like web2py isn't compatible with postgres 8.1?
[web2py] Re: Internal error
I did end up getting it working with MySQL although I would have preferred PostGreSQL.
[web2py] Re: python 2.4 support
I found some compatibility problems with web2py 1.79.2 and python 2.4.3. The syntax in gluon/tools.py doesn't appear to work in this version of python so I made to make some modifications to get it working. Here is a diff: 2838,2841c2838,2839 < if not refsearch: < return field < else: < lambda row: row[field.name][format] == value --- > return field == value if not refsearch else \ >lambda row: row[field.name][format] == value 2843,2846c2841,2842 < if not refsearch: < return field != value < else: < lambda row: row[field.name][format] != value --- > return field != value if not refsearch else \ >lambda row: row[field.name][format] != value 2848,2851c2844,2845 < if not refsearch: < return field > value < else: < lambda row: row[field.name][format] > value --- > return field > value if not refsearch else \ >lambda row: row[field.name][format] > value 2853,2856c2847,2848 < if not refsearch: < return field < value < else: < lambda row: row[field.name][format] < value --- > return field < value if not refsearch else \ >lambda row: row[field.name][format] < value 2858,2861c2850,2851 < if not refsearch: < return field.like(value+'%') < else: < lambda row: str(row[field.name][format]).startswith(value) --- > return field.like(value+'%') if not refsearch else \ >lambda row: > str(row[field.name][format]).startswith(value) 2863,2866c2853,2854 < if not refsearch: < return field.like('%'+value) < else: < lambda row: str(row[field.name][format]).endswith(value) --- > return field.like('%'+value) if not refsearch else \ >lambda row: > str(row[field.name][format]).endswith(value) 2868,2871c2856,2857 < if not refsearch: < return field.like('%'+value+'%') < else: < lambda row: value in row[field.name][format] --- > return field.like('%'+value+'%') if not refsearch else \ >lambda row: value in row[field.name][format]
[web2py] Re: python 2.4 support
Found another problem with the welcome application. When attempting to register an account I get this error: Traceback (most recent call last): File "gluon/restricted.py", line 178, in restricted exec ccode in environment File "/path/to/applications/welcome/controllers/default.py", line 57, in ? File "gluon/globals.py", line 96, in self._caller = lambda f: f() File "/path/to/applications/welcome/controllers/default.py", line 34, in user return dict(form=auth()) File "gluon/tools.py", line 966, in __call__ return self.register() File "gluon/tools.py", line 1502, in register onvalidation=onvalidation): File "gluon/sqlhtml.py", line 876, in accepts onvalidation, File "gluon/html.py", line 1452, in accepts status = self._traverse(status) File "gluon/html.py", line 480, in _traverse newstatus = c._traverse(status) and newstatus File "gluon/html.py", line 480, in _traverse newstatus = c._traverse(status) and newstatus File "gluon/html.py", line 480, in _traverse newstatus = c._traverse(status) and newstatus File "gluon/html.py", line 480, in _traverse newstatus = c._traverse(status) and newstatus File "gluon/html.py", line 487, in _traverse newstatus = self._validate() File "gluon/html.py", line 1245, in _validate (value, errors) = validator(value) File "gluon/validators.py", line 2329, in __call__ return (hmac.new(self.key, value, alg).hexdigest(), None) File "/usr/lib64/python2.4/hmac.py", line 107, in new return HMAC(key, msg, digestmod) File "/usr/lib64/python2.4/hmac.py", line 42, in __init__ self.outer = digestmod.new() AttributeError: 'builtin_function_or_method' object has no attribute 'new' Apparently this version of hashlib doesn't work the same as the one in python 2.5.
[web2py] Re: python 2.4 support
Another problem is, I can't launch from the cli because the rocket module doesn't work with python 2.4: -bash-3.2$ python web2py.py -i 127.0.0.1 -p 8001 -a 'password' sh: ifconfig: command not found WARNING:root:unable to import Rocket web2py Enterprise Web Framework Created by Massimo Di Pierro, Copyright 2007-2010 Version 1.79.2 (2010-06-08 22:45:26) Database drivers available: MySQL, PostgreSQL Starting hardcron... please visit: http://127.0.0.1:8001 use "kill -SIGTERM 21185" to shutdown the web2py server Traceback (most recent call last): File "web2py.py", line 20, in ? gluon.widget.start(cron=True) File "/path/to/gluon/widget.py", line 863, in start path=options.folder) File "/path/to/gluon/main.py", line 618, in __init__ rocket.SERVER_NAME = server_name NameError: global name 'rocket' is not defined
[web2py] Re: import of web2py modules very complicated
On 13 juin, 17:54, Jonathan Lundell wrote: > Try local_import instead of import (same manual page). OK :-) I needed that to fix the warning of Pydev. Now I use a template like that at beginning of mvc files: # Fake the imports needed by the static code analyzer. if False: import gluon.languages.translator as T from gluon.cache import Cache from gluon.contrib.gql import GQLDB from gluon.globals import Request from gluon.globals import Response from gluon.globals import Session from gluon.html import * from gluon.http import HTTP from gluon.http import redirect from gluon.sql import DAL from gluon.sql import Field from gluon.sql import SQLDB from gluon.sqlhtml import SQLFORM from gluon.validators import * cache = Cache() request = Request() response = Response() session = Session()
[web2py] Re: working with views or stored procedures.
seems DAL does not support views, yes ? On Jun 13, 10:57 am, Sky wrote: > I need to display data from a VIEW ( not table) of database. > can any one help me ? > i used dein_table, am i correct ? > db.define_table("vwparts_inetflowbase", > SQLField("pyear", "string"), > SQLField("pmonth", "string"), > SQLField("pday", "string"), > SQLField("phour", "string"), > SQLField("portsd","string"), > SQLField("portnumber", "string"),migrate=False) > > my does not have 'id' column. > and when i run "db.vwparts_inetflowbase.portnumber <> 0" query in > "appadmin/select/db" i get > "Invalid Query : column vwparts_inetflowbase.id does not exist" > is this problem occurs for function calls too ? > my database is PostgreSQL. > > thanks :-)
[web2py] Struggling with file upload ... yet again :(
I'm using the latest trunk stuff with the new uploadseparate capability. # model db.define_table('book', Field('filename','upload',autodelete=True, uploadseparate=2, requires=( IS_UPLOAD_FILENAME(extension='pdf|txt|doc'), IS_LENGTH(500,10)) ) #controller form=SQLFORM.factory(db.auth_user,db.book) if form.accepts(request.vars,formname='form',onvalidation=check_form): book_id=create_book(form) # BOOK GETS CREATED OK # THE NEXT LINE ISN'T WORKING AND NO FILE UPLOADED TO uploads FOLDER db.book[book_id].update( filename=db.book.filename.store(request.vars.filename.file,request.vars.filename.filename) Anybody know what the right way is to get db.book.filename to update properly and to get the file to upload? This should be trivial.
[web2py] Unused key variable
How can I fix the 2 unused 'key' variable warning I have with Pydev in web2py/applications/web2pyfun/controllers/appadmin.py? I mean could someone fix it in the web2py code? It is the only warnings I have from web2py.
[web2py] sqlite modeller
Hi everyone, I am looking for the link for a webpage which allow users to draft/ draw database model which then can be exported as sqlite file. I have clicked the link few times (long time ago) which was available from web2py website. However now I couldn't find it anywhere. I totally forgot the name and I'm seeking anyone's help to give me the link. It was a website for which user can just create new table, edit and links the table graphically which is then can be exported as sqlite. If anyone know the link, please do help me. Thanks. (I have look around, but couldn't find it. It's hard to find when I don't the remember the name of this website) Thanks in advance. Best regards, --nhisyam
[web2py] Re: Multiple form submission - is doc wrong?
Your input element has a comma in between 'name' and 'value' attributes. I don't think it belongs there. On Jun 14, 2:50 am, weheh wrote: > I have a multiple form submission with a custom form. > > #controller > form1=SQLFORM.factory(db.table,...) > form2=SQLFORM.factory(db.table,...) > ... > if form1.accepts(request.vars,formname='form1',onvalidation=xyz): > ... do something ... > > if form2.accepts(request.vars,formname='form2',onvalidation=xyz): > ... do something else ... > > # view > ... > form1.custom.begin > ...widgets... > > form1.custom.end > > form2.custom.begin > ... widgets ... > > form2.custom.end > > -- > > The above seems to work OK. However, the input string is at odds with > what the doc says on p. 195: > > 7 > > When I recast my code as > > > > it doesn't work. > > Is the doc wrong?
[web2py] Re: sqlite modeller
The generic www sql modeler is: http://code.google.com/p/wwwsqldesigner/ Not sure if anyone has been tracking this, but the code does have web2py (and sqlite) generation in the source tree. - Yarko On Jun 13, 9:13 pm, nhisyam wrote: > Hi everyone, > > I am looking for the link for a webpage which allow users to draft/ > draw database model which then can be exported as sqlite file. I have > clicked the link few times (long time ago) which was available from > web2py website. However now I couldn't find it anywhere. I totally > forgot the name and I'm seeking anyone's help to give me the link. > > It was a website for which user can just create new table, edit and > links the table graphically which is then can be exported as sqlite. > > If anyone know the link, please do help me. Thanks. > > (I have look around, but couldn't find it. It's hard to find when I > don't the remember the name of this website) > > Thanks in advance. > > Best regards, > --nhisyam
[web2py] Re: Struggling with file upload ... yet again :(
uploadseparate could be only True or False but that is not the problem here... I uploaded files only through forms and did't use store function expicitly... On jún. 14, 05:56, weheh wrote: > I'm using the latest trunk stuff with the new uploadseparate > capability. > > # model > db.define_table('book', > Field('filename','upload',autodelete=True, > uploadseparate=2, > requires=( > IS_UPLOAD_FILENAME(extension='pdf|txt|doc'), > IS_LENGTH(500,10)) > ) > > #controller > form=SQLFORM.factory(db.auth_user,db.book) > > if form.accepts(request.vars,formname='form',onvalidation=check_form): > book_id=create_book(form) # BOOK GETS CREATED OK > # THE NEXT LINE ISN'T WORKING AND NO FILE UPLOADED TO uploads FOLDER > db.book[book_id].update( > > filename=db.book.filename.store(request.vars.filename.file,request.vars.filename.filename) > > Anybody know what the right way is to get db.book.filename to update > properly and to get the file to upload? This should be trivial.
[web2py] Re: upload file -- lot of file in one directory
No the uploadfolder can have only one value c:/web2py/myapp/uploads or d:/extrastorage/myapp/uploads... uploadseparate can have only True or False. ... uploadfolder='c:/web2py/myapp/uploads', uploadseparate=True ... than you have c:/web2py/myapp/uploads/.//... On jún. 13, 17:33, weheh wrote: > Aha! So then could you write the following: > > import random > Field('filename','upload', > uploadfolder=['c:/web2py/myapp/uploads','d:/extrastorage/myapp/ > uploads'][random.randint(0,1)], > uploadseparate=2, > ) > > and expect the files to be uniformly distributed across 2 filesystems? > That (or its equivalent) would be awesome. > > On Jun 12, 4:20 pm, szimszon wrote: > > > No because you can specify the location of uploaded material so it can > > be on any filesystem, and uploadseparate work under uploadfolder to... > > > On jún. 12, 21:57, weheh wrote: > > > > One more question -- doesn't this eliminate the need for > > > Field(...uploadfolder=pathname,...)? I suppose keeping the > > > uploadfolder parameter is a good thing to keep for anyone who wants to > > > use it for their own special purpose. But if the issue is about > > > storing a gazillion upload files for efficient retrieval, then this > > > new method does it for you automatically without having to resort to > > > uploadfolder=pathname. Right?- Hide quoted text - > > > - Show quoted text - > >
Re: [web2py] Re: PIL to change images on the fly...
Yeah I like that approach. I just can't figure out how to make a file like object like this images from PIL to be returned and actually work. :/ Something my brain can fathom. Best Regards, Jason On Sun, 2010-06-13 at 17:37 -0700, howesc wrote: > create a function for serving images, and add the sizes as parameters: > http://mysite.com/applciation/images/download/foo.png/ > 300/400" /> > > and in the function do the resize and output the binary data of the > image. > > i'm not 100% sure of the best way to do it out side of google app > engine (because they have a special image manipulation library), but i > can share some code i used on google app engine to retrieve an image > from blobstore, resize, and send to client if you think that will help > you. > > cfh > > On Jun 13, 1:41 am, Jason Brower wrote: > > I want to use PIL to change images to be smaller so they render faster, > > I could do it like this where they are entered into a database and > > uploaded, but I have up to 8 different sizes to work with,and with a > > constantly changing design, it would be difficult to make the database > > changes as well. > > This was the example I found but it uses the database and a second > > upload.http://groups.google.com/group/web2py/browse_frm/thread/e2640890d99cf... > > > > I would like to make it so I can pass a function the file location > > db.stuff.photo and it would return something I could pass to the view. > > Hepe that makes sence. > > Best Regards, > > Jason Brower
[web2py] Re: Struggling with file upload ... yet again :(
You're right, uploadeseparate is True or False, but this has no impact on what I'm having trouble with. I tried this: db.book[book_id.update(filename=db.book.filename.store(request.vars.filename)) This causes the no_table.filename/8a/no_table.name.8ae28bb9335txt to attempt to be copied to book.filename/80/book.filename.8079f35...txt, however the contents of the file are not copied. For good measure, I'm getting ticketed: Traceback (most recent call last): File "C:\web2py\gluon\restricted.py", line 178, in restricted exec ccode in environment File "C:/web2py/applications/myapp/controllers/book.py", line 261, in File "C:\web2py\gluon\globals.py", line 96, in self._caller = lambda f: f() File "C:/web2py/applications/myapp/controllers/book.py", line 91, in index name=db.book.filename.store(request.vars.filename) File "C:\web2py\gluon\sql.py", line 2714, in store shutil.copyfileobj(file, dest_file) File "C:\Program Files\Python25\Lib\shutil.py", line 26, in copyfileobj buf = fsrc.read(length) File "C:\Program Files\Python25\Lib\cgi.py", line 548, in __getattr__ raise AttributeError, name AttributeError: read So, either I've totally screwed up or there's a deeper problem.
[web2py] Re: Multiple form submission - is doc wrong?
Yah, just typing here in this little box, not real cut and paste. Original code was an INPUT helper, hence the commas.
[web2py] Re: Struggling with file upload ... yet again :(
One more thing is that after I copy the no_table.filename file to the book.filename file, I want to delete the full path to the no_table.filename file. Is there a convenient attribute somewhere with the path to the original no_table.filename or do I have to reconstruct it myself from the no_table.filename?
[web2py] WebFactional restart web2py
Hi, total noob question here.. how do you restart web2py on webfactional? I ssh in and put in python web2py.py -z 5 it seems like it is trying to start another instance of web2py rather than trying to shut it down. Any body has any idea how shut it down and start it back up again? any help is greatly appreciated :) Pai
[web2py] Re: WebFactional restart web2py
On Jun 14, 12:42 am, Pai wrote: > Hi, > > total noob question here.. how do you restart web2py on > webfactional? I ssh in and put in > > python web2py.py -z 5 > > it seems like it is trying to start another instance of web2py rather > than trying to shut it down. Any body has any idea how shut it down > and start it back up again? When you start web2py like this, you are indeed starting it on the built-in server; your "served" webfaction web2py is served thru apache+ mod_wsgi (apache module). RTM:: From: http://docs.webfaction.com/software/django/config.html?highlight=restart%20wsgi#restarting-a-django-application (it's just another wsgi app - everywhere it says django_app in the link above, replace with "web2py_app" application): -- 1/ Open an SSH session. 2/ Switch to the web2py application’s directory. Enter cd ~/webapps/ web2py_app where web2py_app is the name of the web2py application as it appears in the control panel, and press Enter. 3/ Run the restart script. Enter ./apache2/bin/restart and press Enter. Your web2py application restarts over a few seconds. Note Alternatively, you may manually start and stop the Apache instance. To stop the server, enter ./apache2/bin/stop and press Enter. To start the server, enter ./apache2/bin/start and press Enter. - - Yarko > > any help is greatly appreciated :) > > Pai
[web2py] Multiline labels for fields in SQLForm
I would like to have multiline labels for fields in input forms. Is it possible to use SQLForm to produce that or should I do by hand using FORM? Regards Johann -- "Finally, brethren, whatsoever things are true, whatsoever things are honest, whatsoever things are just, whatsoever things are pure, whatsoever things are lovely, whatsoever things are of good report; if there be any virtue, and if there be any praise, think on these things."Philippians 4:8
[web2py] Re: WebFactional restart web2py
ahhh thank you thank you :) I was looking for document about web2py on the webfactional site but only thing I found that that one pager! Pai On Jun 14, 12:56 am, Yarko Tymciurak wrote: > On Jun 14, 12:42 am, Pai wrote: > > > Hi, > > > total noob question here.. how do you restart web2py on > > webfactional? I ssh in and put in > > > python web2py.py -z 5 > > > it seems like it is trying to start another instance of web2py rather > > than trying to shut it down. Any body has any idea how shut it down > > and start it back up again? > > When you start web2py like this, you are indeed starting it on the > built-in server; your "served" webfaction web2py is served thru > apache+ mod_wsgi (apache module). > > RTM:: > From:http://docs.webfaction.com/software/django/config.html?highlight=rest... > > (it's just another wsgi app - everywhere it says django_app in the > link above, replace with "web2py_app" application): > -- > 1/ Open an SSH session. > > 2/ Switch to the web2py application’s directory. Enter cd ~/webapps/ > web2py_app where web2py_app is the name of the web2py application as > it appears in the control panel, and press Enter. > > 3/ Run the restart script. Enter ./apache2/bin/restart and press > Enter. Your web2py application restarts over a few seconds. > > Note > Alternatively, you may manually start and stop the Apache instance. To > stop the server, enter ./apache2/bin/stop and press Enter. To start > the server, enter ./apache2/bin/start and press Enter. > - > > - Yarko > > > > > any help is greatly appreciated :) > > > Pai
[web2py] Re: Pycon APAC and Web2py
Some quick updates: 1) The labnote book is released as an Opensource app and it can be found @ http://cynote.sourceforge.net/ They are actually using the app as a digital journal 2) Met zoom quiet :-) 3) I did a lightning talk on web2py and demo'd just enough web2py. Heard later from some attendees that the zero-install feature is nice and they would be trying out web2py... I had asked the organizers whether all the videos will be uploaded to youtube or blip.tv, they seem to be not certain. FYI, Steve Holden, Graham Dumpleton, Wesley Chun, Mark Hammond were all here and it was time well spent (for us, attendees) Regards Anand On Jun 9, 11:15 pm, "Zoom.Quiet" wrote: > On Tue, Jun 8, 2010 at 02:09, mdipierro wrote: > > send us some slides when done. > > sure, u will sharing voice recoder ;-) > > > On Jun 7, 2:29 am, Anand Vaidya wrote: > >> Pycon APAC 2010 is scheduled to run from 9th to 11th in Singapore. > > >> On the 10th June, 11:10am we have a talk : > > >> "Electronic Laboratory Notebook on the Web2Py Framework (Yong Yao Ng, > >> Maurice HT Ling) " > > >> Maurice Ling is a staff member of the local (Republic) Polytechnic and > >> the Conference Chair. > > >>http://pycon.sit.rp.sg/conference-1 > > >> FYI > > --http://zoomquiet.org人生苦短? Pythonic!
[web2py] Re: Struggling with file upload ... yet again :(
So I'm back to filename=db.book.filename.store(request.vars.filename.file,request.vars.filename.filename). Now it runs without errors, the destination file is properly created, but it's contents are blank.
[web2py] Re: Multiline labels for fields in SQLForm
I believe you ought to be able to do that by setting labels in your models and possibly using the XML() helper to encapsulate the labels that have BR() in them. On Jun 14, 2:14 am, Johann Spies wrote: > I would like to have multiline labels for fields in input forms. Is > it possible to use SQLForm to produce that or should I do by hand > using FORM? > > Regards > Johann > > -- > "Finally, brethren, whatsoever things are true, whatsoever things are > honest, whatsoever things are just, whatsoever things are pure, > whatsoever things are lovely, whatsoever things are of good report; if > there be any virtue, and if there be any praise, think on these > things." Philippians 4:8