Re: [web2py] Re: SQLTABLE(query) produces different SQL than SQLFORM.grid(query)

2012-11-14 Thread Johann Spies
On 15 November 2012 04:04, howesc  wrote:

> isn't there an option on grid to not show the ID?  i know that grid uses
> the ID for allowing you to click links to edit and such...
>
>
Yes.  It will show only the fields listed in 'fields' if that argument is
present.  The problem is that it adds the id to the list of fields to be
selected even if it is not displaying it.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





Re: [web2py] Re: Migrating with postgres

2012-11-14 Thread Johann Spies
I am using the trunk code updated daily on my development computer and
recently have had to kill web2py processes manually because of migration
issues. I am also using postgresql and this happened regularly while
experimenting with  temporary tables.

Example:  I use 'create table x as select ... from ...' for some queries in
postgresql to create temporary tables.

When an error occurs in communicating with postgesql usually related to
some migration issue, I have to kill the web2py process on operating system
level using the -9 switch because of no response from web2py.  Ctrl-C will
do nothing and a normal kill also has no effect.

Now I use migrate=False with fake-migrate to manage those tables.

Regards
Johann

-- 





[web2py] REF: lambda table variable passing error

2012-11-14 Thread Teddy Nyambe
Hi,

I have the following action in the controller, doing a join to display
"office name" and a reference to department of "department name" to
which office belongs...but i have an error in the link since I have a
modal window am opening to edit/add/delete details...this is the
error:

 'Row' object has no attribute 'id'


def office():
db.office.id.readable = False
query = ((db.office.department == db.department.id))
#((db.contact.date_of_birth < “1990-11-18”))
fields = (db.office.name, db.department.name)
link =  [lambda row: A('Edit', _class='btn', _role='button',
_onclick='dept_edit('+str(row.office.id)+');',**{'_data-toggle':'modal'})
,lambda row: A('Delete', _class='btn', _role='button',
_onclick='dept_delete('+str(row.id)+');',**{'_data-toggle':'modal'})]
headers = {'db.office.name': 'Office Name','db.department.name':
'Department'}
default_sort_order=[db.office.name]

form = SQLFORM.grid(query=query, headers=headers,
orderby=default_sort_order ,links=link, create=False, deletable=True,
editable=False, maxtextlength=64, paginate=25)
return dict(form=form)

How do I pass an id of a row in lambda for the link parameter of the
SQLFORM.grid.

Been stuck with this error for a day now!!

Kind regards,

Teddy L.

-- 





Re: [web2py] Re: Migrating with postgres

2012-11-14 Thread Richard Baron Penman
I am still on web2py 1.99.4. Perhaps that is the reason.
For now my solution was to manually update the postgres database and
use fake_migrate to create the corresponding .table files.
http://web2py.com/books/default/chapter/29/06#Fixing-broken-migrations

I also develop with sqlite and migrations work there fine.


On Thu, Nov 15, 2012 at 4:00 PM, LightDot  wrote:
> I use postgre on almost all web2py projects and migrations work as expected.
> I'm not really sure what combination of options are you looking for... I
> generally recommend a simple approach - during the development, keep
> migration settings at default. Once the database schema is finalized, turn
> the migrations off to speed web2py up. That's it, nothing else to do...
> Unless one has specific needs, this simple approach should work for almost
> any project.
>
> When there's a need to change the db schema afterwards, simply turn the
> migrations back on temporarily and then turn them back off when done. I had
> situations when I needed to use fake migrations in order to incorporate some
> manual db changes, etc... and this always worked as expected too.
>
> Just to note - I do quick prototyping with sqlite but I switch to my final
> db of choice as soon as possible, in order to properly set up indices, etc.
> and test everything as extensively as possible. DAL is great, but there are
> still differences between databases themselves and I wouldn't want to
> discover an unexpected one on the last day of the project...
>
> Anyway, could you be more specific as to what's the current state of your
> database and what would you like to achieve? Why did you need to use fake
> migrations in the first place? I assume this is on web2py 2.2.1?
>
> Regards,
> Ales
>
>
>
>
> On Thursday, November 15, 2012 4:24:39 AM UTC+1, Richard Penman wrote:
>>
>> Having trouble migrating with postgres.
>>
>> With fake_migrate=True the the .table files are created.
>>
>> If migrate=True then error: auth_user already exists.
>>
>> Tried all combinations of these and deleting and removing .table files,
>> but no joy.
>>
>> Is web2py meant to support modify the tables with postgres? If so which
>> combination of options would you recommend?
>> With sqlite this works fine.
>
> --
>
>
>

-- 





[web2py] Re: Migrating with postgres

2012-11-14 Thread LightDot
 I use postgre on almost all web2py projects and migrations work as 
expected. I'm not really sure what combination of options are you looking 
for... I generally recommend a simple approach - during the development, 
keep migration settings at default. Once the database schema is finalized, 
turn the migrations off to speed web2py up. That's it, nothing else to 
do... Unless one has specific needs, this simple approach should work for 
almost any project.

When there's a need to change the db schema afterwards, simply turn the 
migrations back on temporarily and then turn them back off when done. I had 
situations when I needed to use fake migrations in order to incorporate 
some manual db changes, etc... and this always worked as expected too.

Just to note - I do quick prototyping with sqlite but I switch to my final 
db of choice as soon as possible, in order to properly set up indices, etc. 
and test everything as extensively as possible. DAL is great, but there are 
still differences between databases themselves and I wouldn't want to 
discover an unexpected one on the last day of the project...

Anyway, could you be more specific as to what's the current state of your 
database and what would you like to achieve? Why did you need to use fake 
migrations in the first place? I assume this is on web2py 2.2.1?

Regards,
Ales



On Thursday, November 15, 2012 4:24:39 AM UTC+1, Richard Penman wrote:
>
> Having trouble migrating with postgres.
>
> With fake_migrate=True the the .table files are created.
>
> If migrate=True then error: auth_user already exists.
>
> Tried all combinations of these and deleting and removing .table files, 
> but no joy.
>
> Is web2py meant to support modify the tables with postgres? If so which 
> combination of options would you recommend?
> With sqlite this works fine.
>

-- 





[web2py] Importing installed modules

2012-11-14 Thread Richard Penman
I installed a module with pip to:
/home/www/lib/python2.6/M2Crypto-0.21.1-py2.6-linux-i686.egg

When using python directly I can import this module. How should I help 
web2py find this?

For now I have this in my model:
import sys
sys.path.append('/home/www/lib/python2.6/M2Crypto-0.21.1-py2.6-linux-i686.egg')

-- 





[web2py] Migrating with postgres

2012-11-14 Thread Richard Penman
Having trouble migrating with postgres.

With fake_migrate=True the the .table files are created.

If migrate=True then error: auth_user already exists.

Tried all combinations of these and deleting and removing .table files, but 
no joy.

Is web2py meant to support modify the tables with postgres? If so which 
combination of options would you recommend?
With sqlite this works fine.

-- 





[web2py] Re: SQLTABLE(query) produces different SQL than SQLFORM.grid(query)

2012-11-14 Thread howesc
isn't there an option on grid to not show the ID?  i know that grid uses 
the ID for allowing you to click links to edit and such...

On Tuesday, November 13, 2012 11:15:17 PM UTC-8, Johann Spies wrote:
>
> The following code:
>
> fields = [db.rjoernaal.so, db.rpublisher.pu, db.rpublisher.pi]
> query = ((db.rjoernaal.uuid == db.rpub_rj.rj_id) &
>  (db.rpub_rj.rpub_id == db.rpublisher.id))
>   
> data = SQLTABLE(db(query).select(db.rjoernaal.so, db.rpublisher.pu, db
> .rpublisher.pi,
>  groupby = db.rjoernaal.so | db.rpublisher
> .pu | db.rpublisher.pi))
>
> produces the following SQL
>
> SELECT  rjoernaal.so, rpublisher.pu, rpublisher.pi 
> FROM rpublisher, rpub_rj, rjoernaal 
> WHERE ((rjoernaal.uuid = rpub_rj.rj_id) AND (rpub_rj.rpub_id = rpublisher.
> id)) 
> GROUP BY rjoernaal.so, rpublisher.pu, rpublisher.pi;
>
> which is correct.
>
> But when I replace the 'data = ' section in the above code to use 
>
>
> data = SQLFORM.grid(query,
> fields = fields,
> maxtextlength=120,
> editable = False,
> deletable = False,
> groupby = db.rjoernaal.so | db.rpublisher.pu | db.
> rpublisher.pi)
>
>
>
> The result is:
>
> SELECT  rjoernaal.so, rpublisher.pu, rpublisher.pi, rpublisher.id 
> FROM rpublisher, rpub_rj, rjoernaal 
> WHERE ((rjoernaal.uuid = rpub_rj.rj_id) AND (rpub_rj.rpub_id = rpublisher.
> id)) 
> GROUP BY rjoernaal.so, rpublisher.pu, rpublisher.pi;
>
> Note the addition of 'rpublisher.id'.  
>
> This screws up the effect of the groupby-clause and produces an invalid 
> query on postgresql.
>
> Regards
> Johann
>
>
>
>

-- 





Re: [web2py] Re: Multi-language website with GAE + parameter-based system

2012-11-14 Thread howesc
the error is not obvious to me. :(  can you verify that your regex matches 
your URL?

On Tuesday, November 13, 2012 6:01:09 AM UTC-8, David Sorrentino wrote:
>
> Hi howesc,
>
> Thanks for your reply!
>
> I tried to set the regex for my needs, but I guess that I am wrong in 
> something.
> I edited the regex in this way:
>
>> - url: /(?P.+?)/static/\w\{2}?/(?P.+)
>>   static_files: applications/\1/static/\2
>>   upload: applications/(.+?)/static/(.+)
>>   secure: optional
>>
>
> Now, instead of an error, I get 2 warnings for each static file:
>
> WARNING  2012-11-13 13:54:19,604 dev_appserver_import_hook.py:595] 
>> Blocking access to static file 
>> "/home/dapids/web2py/applications/myapp/static/en/css/bootstrap-responsive.min.css"
>
>
> WARNING  2012-11-13 13:54:19,604 dev_appserver_import_hook.py:595] 
>> Blocking access to static file 
>> "/home/dapids/web2py/applications/myapp/static/css/bootstrap-responsive.min.css"
>>
>
> Any thoughts?
>
> Cheers,
> David
>
>
> On 12 November 2012 23:03, howesc > wrote:
>
>> i don't know the full deal with the routerbut it looks like the path 
>> to the static files is incorrect (notice the 'en' in the path).  you can 
>> strip this out in app.yaml (my example strips out a random cache busting 
>> param after the 'static/' in the path, you can modify the regex to meet 
>> your needs):
>>
>> - url: /(?P.+?)/static/.*?/(?P.+)
>>   static_files: applications/\1/static/\2
>>   upload: applications/(.+?)/static/(.+)
>>   secure: optional
>>   expiration: "1d"
>>
>> cfh
>>
>>
>> On Monday, November 12, 2012 7:19:32 AM UTC-8, David Sorrentino wrote:
>>>
>>> Hello everybody! :)
>>>
>>> I am developing a multi-language website deployed on GAE.
>>> For my routes.py I would like to use this configuration, shown on the 
>>> online book (http://web2py.com/books/**default/chapter/29/04#**
>>> Parameter-based-system
>>> ):
>>>
>>> routers = dict(
>>>   BASE  = dict(default_application='**myapp'),
>>>   myapp = dict(languages=['en', 'it', 'jp'], default_language='en'),
>>> )
>>>
>>> However, it looks like I am having some troubles with loading the static 
>>> files. Indeed static files are not loaded and the console shows the 
>>> following error:
>>> [Errno 2] No such file or directory: '/home/dapids/web2py/**
>>> applications/myapp/en/static/**css/bootstrap-responsive.min.**css'
>>>
>>> Am I doing something wrong?
>>>
>>> Cheers,
>>> David
>>>
>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: Placing the database of a web2py app on the cloud

2012-11-14 Thread howesc
VP might very well be using an EC2 instance, but his DB might be an RDS 
instance or something that is not on the EC2 instancethe cross-server 
connection still needs to be setup in that case as well. :)

On Wednesday, November 14, 2012 1:28:26 AM UTC-8, Tim Richardson wrote:
>
> I'm curious about why you wouldn't not just deploy the app on the EC2 
> instance?

-- 





[web2py] Re: How to open a ticket on the web2py itself?

2012-11-14 Thread Tim Richardson


On Thursday, 15 November 2012 01:22:46 UTC+11, Massimo Di Pierro wrote:
>
>
> http://code.google.com/p/web2py/issues/list
>
> I agree this should be more prominent in the web site.
>

+1 :)

-- 





Re: [web2py] Re: web2py as Windows service

2012-11-14 Thread Tim Richardson


> use something external, web2py binary and services doesn't really get 
> along. I use personally the http://nssm.cc/ package and I'm really happy 
> with that. 
> I "voted" for removing services support within web2py, the code (as all 
> code around windows services with python programs) is a copy-paste of a 
> copy-paste of a copy-paste of Mark Hammond's original recipe (and that was 
> for XP). 
> After all, programs like nssm can be more productive and are a piece of 
> sotware that basically deals with all the unconsistencies of the Win API.
>
> Well, this nssm is something new for me, and I will look into it. The 
service script works well for web2py, but getting the scheduler running as 
a service is not supported by web2py. I hacked something but not very well 
.. the scheduler service runs but I couldn't work out how to make it hang 
around and provide status updates, so my service tells the service manager 
it has stopped while in fact it is still running. Solving this needs me to 
understand how web2py starts the scheduler. 
 

-- 





[web2py] Re: New error after installing 2.2.1 version

2012-11-14 Thread Julien Courteau
Hello Massimo!

I send you the complete traceback (see the attach file).

Thanks a lot for web2py and your kindness for taking the time to look at 
that strange problem!

-- 




web2py™ administrative interface

Site
Edit
About
Errors
Versioning
Logout
Debug
Help

Error ticket for "mm"
Ticket ID

127.0.0.1.2012-11-14.19-52-34.bbc92967-4c0f-4038-8129-5e4e912b404f
 format requires a mapping
Version
web2py™ (2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable')
Python  Python 2.7.3: /usr/bin/python
Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.



Traceback (most recent call last):
  File "/home/julien/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
  File "/home/julien/web2py/applications/mm/controllers/default.py", line 291, 
in 
  File "/home/julien/web2py/gluon/globals.py", line 188, in 
self._caller = lambda f: f()
  File "/home/julien/web2py/applications/mm/controllers/default.py", line 210, 
in user
return dict(form=auth())
  File "/home/julien/web2py/gluon/tools.py", line 1235, in __call__
return getattr(self, args[0])()
  File "/home/julien/web2py/gluon/tools.py", line 2095, in login
self.log_event(log, user)
  File "/home/julien/web2py/gluon/tools.py", line 1692, in log_event
origin=origin, user_id=user_id)
  File "/home/julien/web2py/gluon/dal.py", line 7806, in insert
ret =  self._db._adapter.insert(self,self._listify(fields))
  File "/home/julien/web2py/gluon/dal.py", line 1155, in insert
query = self._insert(table,fields)
  File "/home/julien/web2py/gluon/dal.py", line 1151, in _insert
values = ','.join(self.expand(v,f.type) for f,v in fields)
  File "/home/julien/web2py/gluon/dal.py", line 1151, in 
values = ','.join(self.expand(v,f.type) for f,v in fields)
  File "/home/julien/web2py/gluon/dal.py", line 1306, in expand
return str(self.represent(expression,field_type))
  File "/home/julien/web2py/gluon/dal.py", line 1720, in represent
if obj == '' and not fieldtype[:2] in ['st', 'te', 'pa', 'up']:
  File "/home/julien/web2py/gluon/languages.py", line 363, in __eq__
return str(self) == str(other)
  File "/home/julien/web2py/gluon/languages.py", line 360, in __str__
self.T.translate(self.m, self.s))
  File "/home/julien/web2py/gluon/languages.py", line 878, in translate
message = self.params_substitution(message, symbols)
  File "/home/julien/web2py/gluon/languages.py", line 855, in 
params_substitution
message = message % symbols
TypeError: format requires a mapping

Error snapshot help

(format requires a mapping)

inspect attributes
Frames

File /home/julien/web2py/gluon/restricted.py in restricted at line 212 code 
arguments variables

File /home/julien/web2py/applications/mm/controllers/default.py in  
at line 291 code arguments variables

File /home/julien/web2py/gluon/globals.py in  at line 188 code 
arguments variables

File /home/julien/web2py/applications/mm/controllers/default.py in user at 
line 210 code arguments variables

File /home/julien/web2py/gluon/tools.py in __call__ at line 1235 code 
arguments variables

File /home/julien/web2py/gluon/tools.py in login at line 2095 code 
arguments variables

File /home/julien/web2py/gluon/tools.py in log_event at line 1692 code 
arguments variables

File /home/julien/web2py/gluon/dal.py in insert at line 7806 code arguments 
variables

File /home/julien/web2py/gluon/dal.py in insert at line 1155 code arguments 
variables

File /home/julien/web2py/gluon/dal.py in _insert at line 1151 code 
arguments variables

File /home/julien/web2py/gluon/dal.py in  at line 1151 code 
arguments variables

File /home/julien/web2py/gluon/dal.py in expand at line 1306 code arguments 
variables

File /home/julien/web2py/gluon/dal.py in represent at line 1720 code 
arguments variables

File /home/julien/web2py/gluon/languages.py in __eq__ at line 363 code 
arguments variables

File /home/julien/web2py/gluon/languages.py in __str__ at line 360 code 
arguments variables

File /home/julien/web2py/gluon/languages.py in translate at line 878 code 
arguments variables

File /home/julien/web2py/gluon/languages.py in params_substitution at line 
855 code arguments variables
Function argument list

(self=, message='User %(id)s Logged-in', 
symbols=("",))
Code listing

850.
851.
852.
853.
854.
855.

856.
857.
858.
859.



if part == s:
part = regex_plural_dict.sub(sub_dict, s)
if part == s:
return m.group(0)
return part
message = message % symbols

message = regex_plural.sub(sub_plural, message)
return message

def translate(self, message, symbols):

Variables

Re: [web2py] Re: web2py as Windows service

2012-11-14 Thread Derek
The log file should tell you what the issue is. You might also want to look 
in the windows event logs, it may have more details as to what failed.

On Wednesday, November 14, 2012 12:30:38 AM UTC-7, David Sorrentino wrote:
>
> Hello Derek and Tim,
>
> First of all thanks for your reply. :)
>
> @Derek: I do not see any log in the logs folder, but logging is not 
> enabled. This morning I will enable it and tell you the results.
>
> @Tim: I am testing my app on Windows 7. I did not install any Python 
> distribution on Windows, since I have the need of using the .exe install.
> However the application has been compiled and packed on Linux (archlinux), 
> with web2py version 2.2.1 and Python 2.7.3 .
>
> Can I help more?
>
> I wish you a wonderful day.
> David
>
>
> On 14 November 2012 03:27, Tim Richardson 
> > wrote:
>
>> what kind of Windows is it? How did you install Python, and which 
>> distribution is it? 
>> Is your Web2py a source code install, or the .exe install?
>>
>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: How do you deal with obsolete uploaded files?

2012-11-14 Thread Cliff Kachinske
You need two functions.  The first will get the name of the old upload. 
 The second deletes it.

If using FORM or SQLFORM

def edit():
   form = SQLFORM(db.sometable, somerecord, ...)
   ## the onvalidation function fires before SQLFORM commits the change but 
after field validation.
   if form.process(onvalidation=).accepted()
   ## this function fires after SQLFORM has committed your changes
  
  whatever ...


If using crud

def edit():
  form = crud.update(db.sometable, somerecord, onvalidation=, onaccept= ...)

See "Forms and Validators" in the manual for details about onvalidation and 
onaccept.

On Monday, November 12, 2012 2:29:03 PM UTC-5, David Marko wrote:
>
> How do you deal with obsolete uploaded files? I have a table definition 
> with upload file field. When user uploads the file to document and later 
> reedit the document and upload the different file then the former file is 
> left in uploads folder. Is there a way how to delete this obsolete file 
> when new one is being uploaded?
>
> David
>

-- 





[web2py] Error in Facebook Login using OAuth

2012-11-14 Thread juaneduardo
Hi web2py users:
I have configure the the auth.settings.login exactly from the book

from gluon.contrib.login_methods.oauth20_account import OAuthAccount
auth.settings.login_form=OAuthAccount(YOUR_CLIENT_ID,YOUR_CLIENT_SECRET)

I have replaced YOUR_CLIENT_ID and YOUR_CLIENT_SECRET from my app settings 
in developer Facebook

When I run my web2py application raise this exception:

 Following args are mandatory: client_id, 
client_secret, auth_url, token_url. 

Can anyone help me to discover where is the error.

Thanks in advance

-- 





[web2py] Re: request args

2012-11-14 Thread Cliff Kachinske
I always just use.

*
Rows = db(db.bike.id==request.args(0)).select()
*

This assumes you are constructing the URLs correctly.

localhost:8000///tag/1


I never reassign request.args() unless I'm going to use it a 
lot and want to save some typing. Same with request.vars.  

On Tuesday, November 13, 2012 6:28:59 PM UTC-5, Paul Rykiel wrote:
>
> Hi just learning WEB2py and I have a question:
>  
> why do i get an error on this code
>  This code errors out, but when I replace "tag_no" with 1 for record 
> id 1, it works, also the variable "tag_no" has a 1 as a value when i type 
> in an argument 1 on the end of the URL *
>  
> def tag():
> tag_no = request.args(0) 
> Title = "For Sale"
>   *  Rows = db(db.bike.id==tag_no).select()   *
> for row in Rows:
>  serial = row.serial
>  make = row.make
>  model = row.model
>  size = row.size
>  color = row.color
>  style = row.style
>  date_of_receipt = row.date_of_receipt
>  repairs = row.repairs_done
>  price = row.price
> return locals()
>

-- 





Re: [web2py] Re: DB insert confusion

2012-11-14 Thread Mike Anson
Thanks very much for your help Niphlod.

On Wednesday, 14 November 2012 16:10:35 UTC-5, Niphlod wrote:
>
>
> Yes I understand your point. The reason it is currently like this is 
>> because if I use your suggestion (which I obviously had originally)
>>
>> {"id": 1, "method": "savemessage", "params": { "*message*": 
>> "variableholdingmessage", "*uid*" : "variableholdingmail"}}
>>
>> I get message and uid as the values in the DB. So I switched them.
>>
>> {"id": 1, "method": "savemessage", "params": { "variableholdingmessage": 
>> "mymessage", "variableholdinguid" : "myemail@localhost"}}
>>
>> The result means that variableholdingmessage is saved as the message and 
>> not the expected "mymessage". Exactly the same for uid.
>>
>> Unfortunately jsonrpc call method has a bug. in web2py 2.2.1, in 
> gluon/tools.py, line 4231 should be 
>
> s = methods[method](**params)
>
> instead of
>
> s = methods[method](*params)
>
>
> sending a patch to Massimo right now!
>  
>
>>
>> re: PS -- haha yes I know. I did try it with single quotes and it crapped 
>> out?? So just kept the doubles. It's not that bad!
>>
>> re: PS2 -- have you any recommendations to solve this special character 
>> potential problem?
>>
>>  
> Normally with jsonrpc you use something that is not curl, e.g. a 
> programming language that supports json (python?!)
> Escaping on bash without awk, sed, etc is always problematic but if 
> you're willing to have as only limitation the " character that is less 
> frequent to use within a message, why don't you use one of the methods not 
> requiring a json body to be posted ? e.g. @service.xml, @service.csv or 
> @service.json
>
> curl -v --get --data-urlencode \"uid=$uid\" --data-urlencode 
> \"message=$message\" $url
>
> here curl takes care of urlencoding the message and the uid parameters.
>
>
>  
>

-- 





[web2py] Re: postgres problem with crud.update

2012-11-14 Thread Cliff Kachinske
It looks like Postgres is trying to cascade your delete and complaining 
because it can't find a related record.

what is mk_taggable_eq?  I don't get what you are trying to do there.  Why 
not use the more common usage?

form = crud.update(sometable, somerecord ...)
return dict(form=form)


On Wednesday, November 14, 2012 4:50:37 AM UTC-5, andrej burja wrote:
>
> i've made app using wizzard
> i addes tags
> db.define_table('t_tag',
> Field('f_game_id', type='reference t_game',
>   label=T('Game Id')),
> Field('f_name', type='string',
>   label=T('Name')),
> auth.signature,
> format='%(f_game_id)s',
> migrate=settings.migrate)
>
> db.define_table('t_tag_archive',db.t_tag,Field('current_record','reference 
> t_tag',readable=False,writable=False))
>
> in controller i have crud.update
> form = 
> make_taggable_eq(crud.update(db.t_game,record,onaccept=update_tags_eq))
>
> if i want to delete game, there is an error:
>  insert or update on table "t_tag" 
> violates foreign key constraint "t_tag_f_game_id_fkey" DETAIL: Key 
> (f_game_id)=(699) is not present in table "t_game".
>
> update is OK
>
> is this related to postgres?
> what am i doing wrong?
>
> andrej
>
>

-- 





[web2py] auth.wiki( extra=dict() )

2012-11-14 Thread villas
There is this really long thread,  but as far as I can see,  no one seems 
to have answered a main question of the OP.  

https://groups.google.com/d/topic/web2py/r7qMRK2Eir0/discussion

The question is:  can we please have the 'extra' dict for auth.wiki() so 
that this can be passed to Markmin?  I guess it wouldn't do any harm?

Regards,
David


-- 





Re: [web2py] Re: DB insert confusion

2012-11-14 Thread Niphlod


> Yes I understand your point. The reason it is currently like this is 
> because if I use your suggestion (which I obviously had originally)
>
> {"id": 1, "method": "savemessage", "params": { "*message*": 
> "variableholdingmessage", "*uid*" : "variableholdingmail"}}
>
> I get message and uid as the values in the DB. So I switched them.
>
> {"id": 1, "method": "savemessage", "params": { "variableholdingmessage": 
> "mymessage", "variableholdinguid" : "myemail@localhost"}}
>
> The result means that variableholdingmessage is saved as the message and 
> not the expected "mymessage". Exactly the same for uid.
>
> Unfortunately jsonrpc call method has a bug. in web2py 2.2.1, in 
gluon/tools.py, line 4231 should be 

s = methods[method](**params)

instead of

s = methods[method](*params)


sending a patch to Massimo right now!
 

>
> re: PS -- haha yes I know. I did try it with single quotes and it crapped 
> out?? So just kept the doubles. It's not that bad!
>
> re: PS2 -- have you any recommendations to solve this special character 
> potential problem?
>
>  
Normally with jsonrpc you use something that is not curl, e.g. a 
programming language that supports json (python?!)
Escaping on bash without awk, sed, etc is always problematic but if 
you're willing to have as only limitation the " character that is less 
frequent to use within a message, why don't you use one of the methods not 
requiring a json body to be posted ? e.g. @service.xml, @service.csv or 
@service.json

curl -v --get --data-urlencode \"uid=$uid\" --data-urlencode 
\"message=$message\" $url

here curl takes care of urlencoding the message and the uid parameters.


 

-- 





[web2py] Re: auth.signature - how to set is_active back to true?

2012-11-14 Thread Cliff Kachinske
Done. Ticket 1165.

On Wednesday, November 14, 2012 9:41:31 AM UTC-5, Massimo Di Pierro wrote:
>
> This may be a bug. It should work in appadmin. Please submit a ticket.
>
> On Tuesday, 13 November 2012 12:04:54 UTC-6, Cliff Kachinske wrote:
>>
>> Version 2.0.9
>>
>> Using auth.signature, how can I resent is_active back to true?
>>
>> In appadmin I can see the records where is_active is set to False, and 
>> even edit them.  But if I check is_active and submit the record, the value 
>> does not change.
>>
>> Similarly, using ignore_common_filters, I can create an index page that 
>> shows the inactive records, along with an edit function that seems to give 
>> me access to the is_active field.  But when I check the is_active field and 
>> submit the page, the value does not change.
>>
>> In the past I have implemented something like a trash can using the 
>> is_active field.  The only difference is that users were not allowed to 
>> actually delete items in the trash.  I would like to do this again.
>>
>> How can I make this happen?
>>
>

-- 





[web2py] Re: auth.signature - how to set is_active back to true?

2012-11-14 Thread Cliff Kachinske
If it is a bug and is fixed, will I then be able to make it work for end 
users as well?

On Wednesday, November 14, 2012 9:41:31 AM UTC-5, Massimo Di Pierro wrote:
>
> This may be a bug. It should work in appadmin. Please submit a ticket.
>
> On Tuesday, 13 November 2012 12:04:54 UTC-6, Cliff Kachinske wrote:
>>
>> Version 2.0.9
>>
>> Using auth.signature, how can I resent is_active back to true?
>>
>> In appadmin I can see the records where is_active is set to False, and 
>> even edit them.  But if I check is_active and submit the record, the value 
>> does not change.
>>
>> Similarly, using ignore_common_filters, I can create an index page that 
>> shows the inactive records, along with an edit function that seems to give 
>> me access to the is_active field.  But when I check the is_active field and 
>> submit the page, the value does not change.
>>
>> In the past I have implemented something like a trash can using the 
>> is_active field.  The only difference is that users were not allowed to 
>> actually delete items in the trash.  I would like to do this again.
>>
>> How can I make this happen?
>>
>

-- 





[web2py] Re: Updating profile does not update auth.user for computed field

2012-11-14 Thread Mark Li
Here's the link to the ticket: 
http://code.google.com/p/web2py/issues/detail?id=1164&thanks=1164&ts=1352926016

On Wednesday, November 14, 2012 6:21:03 AM UTC-8, Massimo Di Pierro wrote:
>
> Please open a ticket and well' fix this asap. Probably today at the web2py 
> sprint at PyCon Ar.
>
> On Monday, 12 November 2012 22:40:14 UTC-6, Mark Li wrote:
>>
>> I am currently using auth.profile() for a form where users can update 
>> their information. I have an 'upload' field for images, and a computed 
>> field that creates a thumbnail of the previous field.
>>
>> When the user hits 'save profile', auth.user is updated only for the 
>> original 'upload' field, not the computed field. Is there anyway to update 
>> the computed field for auth.user as well (while still using the form 
>> created by auth.profile)?
>>
>

-- 





[web2py] Re: Problem with web2py on Linux

2012-11-14 Thread samuel bonilla
try :
python web2py.py -a admin -i 127.0.0.1 -p 8000

-- 





Re: [web2py] Re: DB insert confusion

2012-11-14 Thread Mike Anson
Speediest response as ever Niphlod!

Yes I understand your point. The reason it is currently like this is
because if I use your suggestion (which I obviously had originally)

{"id": 1, "method": "savemessage", "params": { "*message*":
"variableholdingmessage", "*uid*" : "variableholdingmail"}}

I get message and uid as the values in the DB. So I switched them.

{"id": 1, "method": "savemessage", "params": { "variableholdingmessage":
"mymessage", "variableholdinguid" : "myemail@localhost"}}

The result means that variableholdingmessage is saved as the message and
not the expected "mymessage". Exactly the same for uid.


re: PS -- haha yes I know. I did try it with single quotes and it crapped
out?? So just kept the doubles. It's not that bad!

re: PS2 -- have you any recommendations to solve this special character
potential problem?


On 14 November 2012 15:04, Niphlod  wrote:

> you are using the wrong orderyou have to send something like
>
> {"id": 1, "method": "savemessage", "params": { "*message*":
> "variableholdingmessage", "*uid*" : "variableholdingmail"}}
>
> *message* and *uid* are the named parameters to your function def
> savemessage(*message, uid*)
> and instead you are composing
>
> {"id": 1, "method": "savemessage", "params": { "variableholdingmessage":
> "mymessage", "variableholdinguid" : "myemail@localhost"}}
>
> PS: you are using probably the overcomplicated quoting style ever :P
> try with this
>
> -d '{"id": 1, "method": "savemessage", "params": { "message": "'$message'",
> "uid" : "'$uid'"}}' $url
>
> PS2: relying on a vanilla bash variable for passing around json parameters
> is a bad idea. What if your message includes a ' symbol ? e.g. "Let's
> rock" The json equivalent is "Let\'s rock"...
>
>
>
>  --
>
>
>
>

-- 





[web2py] Re: CodernityDB: pure python, NoSQL, fast DB

2012-11-14 Thread Niphlod
if it supports multiple writes without locking better than Sqlite, I swear 
I'll port at least the scheduler code to work with it.

On Wednesday, November 14, 2012 5:09:48 PM UTC+1, pbreit wrote:
>
> http://labs.codernity.com/codernitydb/
>

-- 





[web2py] Re: DB insert confusion

2012-11-14 Thread Niphlod
you are using the wrong orderyou have to send something like

{"id": 1, "method": "savemessage", "params": { "*message*": 
"variableholdingmessage", "*uid*" : "variableholdingmail"}}

*message* and *uid* are the named parameters to your function def 
savemessage(*message, uid*)
and instead you are composing

{"id": 1, "method": "savemessage", "params": { "variableholdingmessage": 
"mymessage", "variableholdinguid" : "myemail@localhost"}}

PS: you are using probably the overcomplicated quoting style ever :P
try with this

-d '{"id": 1, "method": "savemessage", "params": { "message": "'$message'", 
"uid" : "'$uid'"}}' $url

PS2: relying on a vanilla bash variable for passing around json parameters 
is a bad idea. What if your message includes a ' symbol ? e.g. "Let's 
rock" The json equivalent is "Let\'s rock"...



-- 





[web2py] DB insert confusion

2012-11-14 Thread Mike Anson
Greetings.

I have some strange behavior when saving to my DB.

Here is my DB schemer:

db.define_table('messages',
Field ('uid', 
'string'),
Field 
('message', 
'text'),
Field 
('status', 
'string', default='unsent'),
Field 
('added', 
'datetime', default=request 
.now),
Field 
('modified', 
'datetime', default=request 
.now))


My Controller:

@service.jsonrpc

def savemessage(message, uid):
db.messages.insert(message=message, uid=uid)
db.commit()

message = {"status":"saved"}

return message


Curl script to send message via jsonrpc:

message=$1
uid=$2

url = someURL.com
curl -v -k -X POST -H "Content-Type: application/json" -d "{\"id\": 1, 
\"method\": \"savemessage\", \"params\": { \"${message}\": \"mymessage\", 
\"${uid}\" : \"myemail@localhost\"}}" $url


Command line command:

./send_irc_message.sh "This is my message" s...@email.com


So the first thing to note is that for the params, the value of ${message} 
is being saved rather than mymessage. Similarly the value for ${uid} is 
being saved instead of myemail@localhost

Have I got the script syntax correct?

At a push I could live with this except sporadically, even the value of 
${message} gets saved as the uid in the DB and visa versa. I can't seem to 
consistently replicate this behavior. It just does it from time to time.

When I print out $message and $uid from my curl script, the values are 
correct at this point so it has to be the curl script. Can anyone see 
something I clearly cannot?

Thanks in advance.

-Mike

-- 





[web2py] Re: Very simple issue: redirect on login - auth.settings.login_next

2012-11-14 Thread Anthony

>
> If setting auth.user.settings to a URL stopped the bit of code that 
> generates _next when default/user/register is 'called' then it would seem 
> to fit in with developers expectations. 
>

Keep in mind, currently it is possible to enable referrers (i.e., the _next 
parameter in the URLs) while specifying a default redirect in case there is 
no referrer (i.e., via auth.settings.login_next). If we change the 
behavior, then we lose this capability and are limited to referrers only 
(with no default redirect) or a single fixed default only (with no 
referrers). So, we would be breaking backward compatibility and losing 
functionality. Instead, perhaps we can just improve the documentation. I 
don't think it's that complicated. Redirects from Auth pages are controlled 
via two methods: the _next parameter in the URL, and the 
auth.settings.[action]_next settings, with the former taking precedence. If 
you instead prefer the latter to take precedence, you just have to set the 
referrer_actions argument to auth.navbar() appropriately (or avoid using 
auth.navbar() altogether).

Anthony

-- 





[web2py] Re: flash obtained during not entering a value

2012-11-14 Thread Paolo Caruccio
Important advise: use the book as first help. It is a precious information 
source.

From 
http://web2py.com/books/default/chapter/29/07?search=validators#Validators

Built-in validators have constructors that take an optional argument:

IS_NOT_EMPTY(error_message='cannot be empty')

error_message allows you to override the default error message for any 
validator.

Here is an example of a validator on a database table:db.person.name.requires 
= IS_NOT_EMPTY(error_message='fill this!')

where we have used the translation operator T to allow forinternationalization
. Notice that default error messages are not translated.


>From http://web2py.com/books/default/chapter/29/11?search=form.errors we 
know that:

The color of the errors is given in the CSS code in "layout.html".


Il giorno mercoledì 14 novembre 2012 18:13:43 UTC+1, dantuluri jaganadha 
raju ha scritto:
>
> please reply as soon as possible
>
> On Friday, October 12, 2012 9:37:00 AM UTC+5:30, dantuluri jaganadha raju 
> wrote:
>>
>> Hi,
>> I am getting "enter a value"(with red colored back 
>> ground) when not entering any data to field of table (to which i made 
>> constraint IS_NOT_NULL). How can I change that flash to some "DESIRED 
>> ONE."(including back ground color) for  'ONLY SOME'  fields of table
>>
>>
>>   Thank you in advance...
>>
>

-- 





Re: [web2py] Re: Getting error near "interval_time": syntax error

2012-11-14 Thread Paolo Caruccio
Please try:

query = Expression(db,"interval_time < (strftime('%M','now') - 
strftime('%M', updated_on))")

On the page suggested by Niphlod we read:

Compute the number of seconds between two dates:
  SELECT strftime('%s','now') - strftime('%s','2004-01-01 02:34:56');

So by replacing '%s' with '%M' we obtain the difference in minutes between 
two dates.


Il giorno mercoledì 14 novembre 2012 12:13:03 UTC+1, Amit ha scritto:
>
> 100% correct :) , now facing problem of replacing the query with sqlite 
> compatible query :
>
> MySql query were:
>
> *query = Expression(db,"date_sub(now(),interval interval_time minute) > 
> updated_on")*
>
> where interval_time field is integer field which will be considered to 
> take interval in minutes for e.g. if user wants to save the interval time 
> is 1 hour then he has to enter it in minutes means 60 minutes.
>
> Now problem is when i tried to replace the above query with sqlite 
> compitible query like below and pass to the db to get the required records:
>
> *query = Expression(db,"date('now','-interval_time minutes') > 
> updated_on")*
>
> it returns nothing.
> So can you please help me out write the above query in Sqlite.
>
> Thanks,
> Amit
>
>
>
> On Wed, Nov 14, 2012 at 3:36 PM, Niphlod  >wrote:
>
>>
>> Il giorno mercoledì 14 novembre 2012 09:51:43 UTC+1, Amit ha scritto:
>>
>>> Hi,
>>> I am getting error 
>>> * near "interval_time": syntax error*
>>>
>>
>> syntax error points to something around "interval_time".. my bet is 
>> on date_sub() not supported by sqlite 
>>
>> http://www.sqlite.org/cvstrac/wiki/wiki?p=DateAndTimeFunctions
>>  
>>  
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: flash obtained during not entering a value

2012-11-14 Thread dantuluri jaganadha raju
please reply as soon as possible

On Friday, October 12, 2012 9:37:00 AM UTC+5:30, dantuluri jaganadha raju 
wrote:
>
> Hi,
> I am getting "enter a value"(with red colored back 
> ground) when not entering any data to field of table (to which i made 
> constraint IS_NOT_NULL). How can I change that flash to some "DESIRED 
> ONE."(including back ground color) for  'ONLY SOME'  fields of table
>
>
>   Thank you in advance...
>

-- 





[web2py] Re: Very simple issue: redirect on login - auth.settings.login_next

2012-11-14 Thread peter
You are not the only person to have wasted a lot of time on this issue. 
There iso many issues that the Web2py team are excellent on, but this is 
not one of them.

'auth.navbar(referrer_actions=None)'

Also did not work for me with 2.2.1

however putting 
'auth.next = None' did work.

In the battle of minds between Doug and Anthony, I had similar experience 
to Doug and tend to agree with him.
(https://groups.google.com/forum/?fromgroups=#!topic/web2py/wKd5QN5R5fs)

If setting auth.user.settings to a URL stopped the bit of code that 
generates _next when default/user/register is 'called' then it would seem 
to fit in with developers expectations. I am not sure why these ugly 
workarounds are necessary. The book still has this statment (when talking 
about setting auth.user.---_next)

'These must point to the URL you want to redirect your users to after the 
various possible auth actions (in case there is no referrer): '

This is an example of documentation that can only be understood by the 
person who wrote it, or other people who already know the answer.

I expect everyone new to this expects setting auth.setting.register_next to 
a URL will cause the redirection. They all then find out  the hard way it 
does not work. Trawl through the forums and try various things until coming 
up with a solution. I wonder how much time has been wasted on this (and the 
login_next etc).

Peter

>
>

-- 





Re: [web2py] change database via class?

2012-11-14 Thread tom h
ah, didn't know there was a technical name.  yes, i believe that is what 
i'm trying to do here.

i like to a degree the web2py DAL structure gearing more towards a 
"controller" class, but i would still like to have business objects as 
classes also, that will be acted upon by controller classes.

i just found the link below, and to mdipierro's point, i like and would 
want a Shop controller class that use DAL in a more efficient manner,  but 
i also think having all the logic related to an Order in Shop class might 
make it tough if there are any large underlying changes to Order, whereas a 
business object would make changes to the Order transparent to Shop.
https://groups.google.com/forum/#!msg/web2py/ro1CKfElZQI/4kQfmjrENt4J

so yea, i guess i'm wondering if there are any python/web2py magic that'll 
make database updates a bit easier.  tried to inherit from Storage but 
Table.() didn't like all the extra fields in the dictionary.

thanks,

tom


On Wednesday, November 14, 2012 10:04:54 AM UTC-5, viniciusban wrote:
>
> Are you trying to implement the Business Object pattern, Tom? 
>
>
>
> On Wed, Nov 14, 2012 at 12:54 PM, tom h > 
> wrote: 
> > hi, 
> > 
> > thanks i'll take a look at the hasattr(). 
> > 
> > that's not exactly what i mean.  the difference is having a model class 
> that 
> > represents a real-world application, vs using the Table class to make 
> > database updates.  in your example there, Product(1) is getting a record 
> > set, and to insert, one needs to explicit work with the Table object. 
> > 
> > i'd like to create a class that represents one specific product, and 
> have a 
> > easy way to save an instance of that class into the database. 
> > 
> > i've been reading this thread: 
> > 
> https://groups.google.com/forum/?fromgroups=#!searchin/web2py/web2py$20vs$20World/web2py/KgzKryAEIGw/pTMR_ZuZoJwJ
>  
> > 
> > i think their conclusion at the end is fairly close to what i'm trying 
> to 
> > do.  i was just wondering if there's a better way about it than how i've 
> > done it. 
> > 
> > thanks for your fast response. 
> > 
> > tom 
> > 
> > On Wednesday, November 14, 2012 7:01:34 AM UTC-5, viniciusban wrote: 
> >> 
> >> You may implement this getting your table fields and checking if your 
> >> class has this attribute with hasattr() (it's a Python builtin 
> >> function). It should be done in a upper level class, who you should 
> >> extend. 
> >> 
> >> But, maybe you're missing that DAL does exactly what you mean: this 
> >> mapping between your database physical fields and your properties. 
> >> 
> >> Maybe you could achieve that simply doing this: 
> >> >>> Product = db.define_table('product', ...) # all your define_table. 
> >> 
> >> From now on, you can do: 
> >> >>> p = Product(1) 
> >> >>> Product.price = 100 
> >> >>> Product.name = 'aaa' 
> >> >>> Product.update_or_insert() 
> >> 
> >> -- 
> >> Vinicius Assef 
> >> 
> >> 
> >> On Wed, Nov 14, 2012 at 6:09 AM, tom h  wrote: 
> >> > hi web2py gurus, 
> >> > 
> >> > just out of curiousity, i'd like to create a class (let's say 
> Product) 
> >> > that 
> >> > represents a record in my table "product".  right now, i can't figure 
> >> > out 
> >> > how to have the class attributes (p = Product(); p.price) saved to 
> the 
> >> > database without internally having p.__fields_dict__ containing ONLY 
> >> > table 
> >> > fields, and then map the p.price to p.__fields_dict__['price'], and 
> >> > finally 
> >> > doing something like p.db['product'].insert(p.__fields_dict__). 
> >> > 
> >> > i'm just wondering if there's any better way to do this, sorry i'm 
> >> > pretty 
> >> > new to Python as well and probably am missing something. 
> >> > 
> >> > ideally, i'd like something that's more like: 
> >> > 
> >> > p = Product(id=1) or Product() 
> >> > p.random_var = 'abc' 
> >> > p.name = 'a' 
> >> > p.price = 100.0 
> >> > p.save() # or db['product'].update_or_insert(p) 
> >> > 
> >> > thanks a lot! 
> >> > tom 
> >> > 
> >> > -- 
> >> > 
> >> > 
> >> > 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





[web2py] CodernityDB: pure python, NoSQL, fast DB

2012-11-14 Thread pbreit
http://labs.codernity.com/codernitydb/

-- 





Re: [web2py] OperationalError: database is locked

2012-11-14 Thread Mike Anson
I do indeed have greater than 3.7 so I'll see if that prevents the locking. 
So far so good although it was very sporadic and the scheduler ran over 70 
times before it crapped out before adding the line you suggested.

Thanks again for your responses.

-Mike

On Wednesday, 14 November 2012 00:11:45 UTC-5, Vasile Ermicioi wrote:
>
> first be sure you have sqlite >=3.7:
> 1) open python
> 2)>import sqlite3
> 3)>print sqlite3.sqlite_version
>
> if you don't have sqlite >=3.7 you can't use wal
>
> put the code in models/db.py after database connection
>
> db = DAL('sqlite://storage.sqlite')
> db.executesql('PRAGMA journal_mode=WAL')
>
> but you can remove it after one run
>
> read more here http://www.sqlite.org/draft/wal.html
>
>
>

-- 





Re: [web2py] Trouble with JQuery UI - use 1.8.24 not what ships

2012-11-14 Thread LightDot
Note, jQuery and jQuery UI have separate versions. jQuery UI is not 
included or used in web2py welcome app, there is just a commented link in 
the code, if I recall correctly.

On Wednesday, November 14, 2012 3:44:17 PM UTC+1, Massimo Di Pierro wrote:
>
> I upgraded to jQuery 1.8.2 which appear to be the latest stable.
>
> On Tuesday, 13 November 2012 12:49:56 UTC-6, Richard wrote:
>>
>> jQuery UI 1.9.1 is the last stable... I use it with web2py without 
>> trouble.
>>
>> I had experiment little glitch with 1.8.24
>>
>> Also, I usually download jQuery build and use it instead of using 
>> googleapis...
>>
>> Richard
>>
>> On Tue, Nov 13, 2012 at 1:34 PM, Luca  wrote:
>>
>>> I had trouble using the native autocomplete provided in JQuery UI: the 
>>> autocomplete list would not attach to the  element where the entry 
>>> occurred, but rather, it would attach to the "window" in general.  Closer 
>>> inspection revealed errors in the execution of JQuery UI. 
>>>
>>> I solved the errors by including version 1.8.24 of JQuery UI, not the 
>>> 1.8.18 version that is the default in layout.html. 
>>> I am mentioning this in case it can save other people's time. 
>>>
>>> Actual lines I used:
>>>
>>>http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/themes/base/jquery-ui.css";
>>>  
>>> type="text/css" media="all" />
>>>http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js"; 
>>> type="text/javascript">
>>>
>>> Luca
>>>
>>> -- 
>>>  
>>>  
>>>  
>>>
>>
>>

-- 





Re: [web2py] change database via class?

2012-11-14 Thread Vinicius Assef
Are you trying to implement the Business Object pattern, Tom?



On Wed, Nov 14, 2012 at 12:54 PM, tom h  wrote:
> hi,
>
> thanks i'll take a look at the hasattr().
>
> that's not exactly what i mean.  the difference is having a model class that
> represents a real-world application, vs using the Table class to make
> database updates.  in your example there, Product(1) is getting a record
> set, and to insert, one needs to explicit work with the Table object.
>
> i'd like to create a class that represents one specific product, and have a
> easy way to save an instance of that class into the database.
>
> i've been reading this thread:
> https://groups.google.com/forum/?fromgroups=#!searchin/web2py/web2py$20vs$20World/web2py/KgzKryAEIGw/pTMR_ZuZoJwJ
>
> i think their conclusion at the end is fairly close to what i'm trying to
> do.  i was just wondering if there's a better way about it than how i've
> done it.
>
> thanks for your fast response.
>
> tom
>
> On Wednesday, November 14, 2012 7:01:34 AM UTC-5, viniciusban wrote:
>>
>> You may implement this getting your table fields and checking if your
>> class has this attribute with hasattr() (it's a Python builtin
>> function). It should be done in a upper level class, who you should
>> extend.
>>
>> But, maybe you're missing that DAL does exactly what you mean: this
>> mapping between your database physical fields and your properties.
>>
>> Maybe you could achieve that simply doing this:
>> >>> Product = db.define_table('product', ...) # all your define_table.
>>
>> From now on, you can do:
>> >>> p = Product(1)
>> >>> Product.price = 100
>> >>> Product.name = 'aaa'
>> >>> Product.update_or_insert()
>>
>> --
>> Vinicius Assef
>>
>>
>> On Wed, Nov 14, 2012 at 6:09 AM, tom h  wrote:
>> > hi web2py gurus,
>> >
>> > just out of curiousity, i'd like to create a class (let's say Product)
>> > that
>> > represents a record in my table "product".  right now, i can't figure
>> > out
>> > how to have the class attributes (p = Product(); p.price) saved to the
>> > database without internally having p.__fields_dict__ containing ONLY
>> > table
>> > fields, and then map the p.price to p.__fields_dict__['price'], and
>> > finally
>> > doing something like p.db['product'].insert(p.__fields_dict__).
>> >
>> > i'm just wondering if there's any better way to do this, sorry i'm
>> > pretty
>> > new to Python as well and probably am missing something.
>> >
>> > ideally, i'd like something that's more like:
>> >
>> > p = Product(id=1) or Product()
>> > p.random_var = 'abc'
>> > p.name = 'a'
>> > p.price = 100.0
>> > p.save() # or db['product'].update_or_insert(p)
>> >
>> > thanks a lot!
>> > tom
>> >
>> > --
>> >
>> >
>> >
>
> --
>
>
>

-- 





Re: [web2py] change database via class?

2012-11-14 Thread tom h
hi,

thanks i'll take a look at the hasattr().

that's not exactly what i mean.  the difference is having a model class 
that represents a real-world application, vs using the Table class to make 
database updates.  in your example there, Product(1) is getting a record 
set, and to insert, one needs to explicit work with the Table object.

i'd like to create a class that represents one specific product, and have a 
easy way to save an instance of that class into the database.

i've been reading this thread:
https://groups.google.com/forum/?fromgroups=#!searchin/web2py/web2py$20vs$20World/web2py/KgzKryAEIGw/pTMR_ZuZoJwJ

i think their conclusion at the end is fairly close to what i'm trying to 
do.  i was just wondering if there's a better way about it than how i've 
done it.

thanks for your fast response.

tom

On Wednesday, November 14, 2012 7:01:34 AM UTC-5, viniciusban wrote:
>
> You may implement this getting your table fields and checking if your 
> class has this attribute with hasattr() (it's a Python builtin 
> function). It should be done in a upper level class, who you should 
> extend. 
>
> But, maybe you're missing that DAL does exactly what you mean: this 
> mapping between your database physical fields and your properties. 
>
> Maybe you could achieve that simply doing this: 
> >>> Product = db.define_table('product', ...) # all your define_table. 
>
> From now on, you can do: 
> >>> p = Product(1) 
> >>> Product.price = 100 
> >>> Product.name = 'aaa' 
> >>> Product.update_or_insert() 
>
> -- 
> Vinicius Assef 
>
>
> On Wed, Nov 14, 2012 at 6:09 AM, tom h > 
> wrote: 
> > hi web2py gurus, 
> > 
> > just out of curiousity, i'd like to create a class (let's say Product) 
> that 
> > represents a record in my table "product".  right now, i can't figure 
> out 
> > how to have the class attributes (p = Product(); p.price) saved to the 
> > database without internally having p.__fields_dict__ containing ONLY 
> table 
> > fields, and then map the p.price to p.__fields_dict__['price'], and 
> finally 
> > doing something like p.db['product'].insert(p.__fields_dict__). 
> > 
> > i'm just wondering if there's any better way to do this, sorry i'm 
> pretty 
> > new to Python as well and probably am missing something. 
> > 
> > ideally, i'd like something that's more like: 
> > 
> > p = Product(id=1) or Product() 
> > p.random_var = 'abc' 
> > p.name = 'a' 
> > p.price = 100.0 
> > p.save() # or db['product'].update_or_insert(p) 
> > 
> > thanks a lot! 
> > tom 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





[web2py] Re: Git Push ignores .gitignore

2012-11-14 Thread Massimo Di Pierro
This is still listed as an experimental feature. We use some some help 
fixing it. 

On Tuesday, 13 November 2012 16:24:17 UTC-6, dhmorgan wrote:
>
> I don't know if this is a bug or not:
>
> I added an application to my site using the admin console's 'upload from 
> git repository' function. The repository I added was one I had previously 
> created and pushed to Github. Its ".gitignore" file prevents the usual 
> files and directories from being uploaded (*.pyc, sessions/*, cron/*, etc).
>
> After making changes to the application, I pushed it back to the Github 
> repository from within admin, but it added all of the items that should be 
> ignored. This also happens when using git directly from the command line in 
> the web2py-installed application. It does not happen, however, when I push 
> from my original local repository to Github, even though the .gitignore 
> files and permissions are exactly the same.
>
> I should add that I experienced the problem earlier and started to post 
> this comment, but in trying to replicate it (upload from repository; a 
> quick edit; push to repository), it initially worked. I don't know what 
> might have happened in the meantime -- I haven't done anything git-related, 
> just editing controllers and views.
>
> I'm using 2.2.1
>
>

-- 





Re: [web2py] Trouble with JQuery UI - use 1.8.24 not what ships

2012-11-14 Thread Massimo Di Pierro
I upgraded to jQuery 1.8.2 which appear to be the latest stable.

On Tuesday, 13 November 2012 12:49:56 UTC-6, Richard wrote:
>
> jQuery UI 1.9.1 is the last stable... I use it with web2py without trouble.
>
> I had experiment little glitch with 1.8.24
>
> Also, I usually download jQuery build and use it instead of using 
> googleapis...
>
> Richard
>
> On Tue, Nov 13, 2012 at 1:34 PM, Luca  >wrote:
>
>> I had trouble using the native autocomplete provided in JQuery UI: the 
>> autocomplete list would not attach to the  element where the entry 
>> occurred, but rather, it would attach to the "window" in general.  Closer 
>> inspection revealed errors in the execution of JQuery UI. 
>>
>> I solved the errors by including version 1.8.24 of JQuery UI, not the 
>> 1.8.18 version that is the default in layout.html. 
>> I am mentioning this in case it can save other people's time. 
>>
>> Actual lines I used:
>>
>>http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/themes/base/jquery-ui.css";
>>  
>> type="text/css" media="all" />
>>http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js"; 
>> type="text/javascript">
>>
>> Luca
>>
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: auth.signature - how to set is_active back to true?

2012-11-14 Thread Massimo Di Pierro
This may be a bug. It should work in appadmin. Please submit a ticket.

On Tuesday, 13 November 2012 12:04:54 UTC-6, Cliff Kachinske wrote:
>
> Version 2.0.9
>
> Using auth.signature, how can I resent is_active back to true?
>
> In appadmin I can see the records where is_active is set to False, and 
> even edit them.  But if I check is_active and submit the record, the value 
> does not change.
>
> Similarly, using ignore_common_filters, I can create an index page that 
> shows the inactive records, along with an edit function that seems to give 
> me access to the is_active field.  But when I check the is_active field and 
> submit the page, the value does not change.
>
> In the past I have implemented something like a trash can using the 
> is_active field.  The only difference is that users were not allowed to 
> actually delete items in the trash.  I would like to do this again.
>
> How can I make this happen?
>

-- 





[web2py] Re: Empty "db stats" and "db tables" in response.toolbar() despite database connection - MySQL

2012-11-14 Thread Massimo Di Pierro
Any chance you can try trunk? I remember we made some changes about it 
recently because of a bug.

On Tuesday, 13 November 2012 11:01:51 UTC-6, Maciej Kwiecień wrote:
>
> Dear All, 
>
> I'm using 2.2.1 version on Apache 2.2.19 with ssl, on Windows 7 (64 bit). 
> The database engine is MySQL. 
>
> No matter how my models look like I never get anything in "db stats" and 
> "db tables" info in response.toolbar().
> When I explicitly output db._timings in the view, at least 3 queries are 
> shown.
>
> What can be the reason?
>
> Thank you!
> Maciek
>

-- 





[web2py] Re: REF: Programmatically assign args to LOAD

2012-11-14 Thread Massimo Di Pierro
Not using LOAD but you can check the code LOAD generates and easily tweak 
that.

On Tuesday, 13 November 2012 06:14:15 UTC-6, software.ted wrote:
>
> Hi, 
>
> I am trying to find out if its possible using javascript assigning 
> args to the LOAD when button is clicked as follow: 
>
> View: 
>
> my button 
>
>  
> jQuery('#55').onclick(function(){ 
>   web_component(...) 
>   update args.. 
>}; 
>  
>  
> {{=LOAD('mycontroller','myaction',args=55, ajax=True}}} 
>  
>
> I have several buttons with an ID which I want passed to the args. 
>
> Kind regards, 
>
> Teddy L. 
>

-- 





[web2py] Re: Cannot import module 'lpod'

2012-11-14 Thread Massimo Di Pierro
Moreover. Where is lpod? How was it installed?

On Wednesday, 14 November 2012 08:26:09 UTC-6, Massimo Di Pierro wrote:
>
> Does it work if you simply do:  import lpod.document  ?
>
>
> On Tuesday, 13 November 2012 04:37:43 UTC-6, omicron wrote:
>>
>> With web2py 1.99.7 this import was Ok :
>> import lpod.document as oodoc
>>
>> But with version 2.2.1, I have this error :
>>   File "/home/myhome/Applications/web2py/gluon/custom_import.py", line 
>> 77, in custom_importer
>> raise ImportError, 'Cannot import module %s' % str(e)
>>   ImportError: Cannot import module 'lpod'
>>
>> But if I replace with this:
>>   import lpod
>> It's ok !!!
>>
>> And, of course, in a python shell it's ok.
>>
>> Thanks
>>
>>

-- 





[web2py] Re: Cannot import module 'lpod'

2012-11-14 Thread Massimo Di Pierro
Does it work if you simply do:  import lpod.document  ?


On Tuesday, 13 November 2012 04:37:43 UTC-6, omicron wrote:
>
> With web2py 1.99.7 this import was Ok :
> import lpod.document as oodoc
>
> But with version 2.2.1, I have this error :
>   File "/home/myhome/Applications/web2py/gluon/custom_import.py", line 77, 
> in custom_importer
> raise ImportError, 'Cannot import module %s' % str(e)
>   ImportError: Cannot import module 'lpod'
>
> But if I replace with this:
>   import lpod
> It's ok !!!
>
> And, of course, in a python shell it's ok.
>
> Thanks
>
>

-- 





[web2py] Re: How to open a ticket on the web2py itself?

2012-11-14 Thread Massimo Di Pierro

http://code.google.com/p/web2py/issues/list

I agree this should be more prominent in the web site.

On Tuesday, 13 November 2012 03:42:28 UTC-6, Maciej Kwiecień wrote:
>
> Regards,
>
> After spending significant amount of time on futile searching on the 
> Internet, Google Groups and web2py book itself I'm asking the question I 
> was asking myself from the very beginning:
>
> Where to add and browse bugs / issues / tickets about the web2py itself? 
> This place has to exist, but unfortunately nothing is mentioned in the book 
> nor the website. Or maybe I'm searching incorrectly?
>
> Thank you for your help!
> Maciek
>

-- 





[web2py] Re: Updating profile does not update auth.user for computed field

2012-11-14 Thread Massimo Di Pierro
Please open a ticket and well' fix this asap. Probably today at the web2py 
sprint at PyCon Ar.

On Monday, 12 November 2012 22:40:14 UTC-6, Mark Li wrote:
>
> I am currently using auth.profile() for a form where users can update 
> their information. I have an 'upload' field for images, and a computed 
> field that creates a thumbnail of the previous field.
>
> When the user hits 'save profile', auth.user is updated only for the 
> original 'upload' field, not the computed field. Is there anyway to update 
> the computed field for auth.user as well (while still using the form 
> created by auth.profile)?
>

-- 





[web2py] Re: New error after installing 2.2.1 version

2012-11-14 Thread Massimo Di Pierro
The error is that here:

(self=, 
message='User %(id)s Logged-in', symbols=("",))

should be

(self=, 
message='User %(id)s Logged-in', symbols="")

Yet I do not know why this happens to you. It does not happen to me. Can 
you post the complete traceback?

On Monday, 12 November 2012 19:08:09 UTC-6, Julien Courteau wrote:
>
> Hello All,
> After converting to 2.2.1 I've got the following error message:
> " format requires a mapping"
>
> when I try to log on for accessing an action that requires 
> authentification / authaurization such as:
> @auth.requires_membership('admin')
> def  f(): ...
>
> Here is an extract of the traceback:
>
>
> *File /home/julien/web2py/gluon/languages.py 
> inparams_substitution at line 
> 855* 
> Function argument list
>
> (self=, 
> message='User %(id)s Logged-in', symbols=(" 'julien', 'first_name': 'Julie...f9da1adefd98', 'registration_key': '', 
> 'id': 12\x1f>",))
> Code listing 
>
> 850.
> 851.
> 852.
> 853.
> 854.
> 855.
>
> 856.
> 857.
> 858.
> 859.
>
> if part == s:
> part = regex_plural_dict.sub(sub_dict, s)
> if part == s:
> return m.group(0)
> return part
> message = message % symbols
>
> message = regex_plural.sub(sub_plural, message)
> return message
>
> def translate(self, message, symbols):
>
>Variables   symbols(" 'julien', 'first_name': 'Julie...f9da1adefd98', 'registration_key': '', 
> 'id': 12\x1f>",)message'User %(id)s Logged-in'
>
> Anybody have a clue?
>
> Thanks.
>

-- 





Re: [web2py] Re: Some Scheduler questions

2012-11-14 Thread Niphlod
and the log with the debug active says ?

-- 





[web2py] Re: SQLFORM.smartgrid. This is a bug?

2012-11-14 Thread Jose
Here's the answer:

https://groups.google.com/forum/#!msg/web2py/bpNJ8bhDs7Q/2U3IRB18MkMJ

José

-- 





[web2py] Re: step-by step instructions installing web2py on a CentOS server with cPanel installed

2012-11-14 Thread LightDot
You're really using a CentOS 4.x server? That's quite old... Any chance you 
could move to a newer version of CentOS to start with? Preferably CentOS 
6.x.

Regards,
Ales

On Wednesday, November 14, 2012 10:18:36 AM UTC+1, Daniele wrote:
>
> Bump! I'd also like to see a guide on how to do this.
>
> On Friday, January 21, 2011 9:18:12 PM UTC, stargate wrote:
>>
>> I as wondering if there is step-by step instructions installing web2py 
>> on a CentOS version 4.x server with cPanel installed.
>
>

-- 





Re: [web2py] Re: web2py as Windows service

2012-11-14 Thread David Sorrentino
NSSM is just what I was looking for. Simple and effective.
I also agree for the use of third-party software in cases like this.

Thank you one more time for your help and availability.
Saluti,
David


On 14 November 2012 14:09, Niphlod  wrote:

>
>
> Il giorno mercoledì 14 novembre 2012 11:52:36 UTC+1, David Sorrentino ha
> scritto:
>
>> Ok, I managed to make it work.
>> I set the *ip* variable to '127.0.0.1'.
>>
>> So, the ActivePython environment made the trick.
>> Thank you very much for your help Tim. ;)
>>
>> Did anyone else try to run web2py as a Windows service using the .exe
>> install? I'd rather to use the .exe install because in that way I don't
>> need to install Python before installing my app.
>>
>>
> use something external, web2py binary and services doesn't really get
> along. I use personally the http://nssm.cc/ package and I'm really happy
> with that.
> I "voted" for removing services support within web2py, the code (as all
> code around windows services with python programs) is a copy-paste of a
> copy-paste of a copy-paste of Mark Hammond's original recipe (and that was
> for XP).
> After all, programs like nssm can be more productive and are a piece of
> sotware that basically deals with all the unconsistencies of the Win API.
>
>  --
>
>
>
>

-- 





Re: [web2py] Problem with fresh install of web2py on Linux

2012-11-14 Thread LightDot
It seems to me that Robert's suggestion might be correct. Anyway, the 
problem is in your Python environment - you're saying that you use Red Hat 
64-bit but no released version of Red Hat comes with Python 2.7.x so I'm 
assuming you've installed this version of Python yourself. This leads me to 
conclusion that a few standard python modules might be missing.

Regards,
Ales


On Wednesday, November 14, 2012 12:11:06 PM UTC+1, Roberto Perdomo wrote:
>
>
> El 14/11/2012 07:44, "gabriele dantona" > 
> escribió:
> >
> > Hello,
>
> Hi,
>
> > I've installed web2py on Linux Redhat 64bit with Python 2.7.3.
> >
> > After starting the server, the first request fails with this stack 
> trace. Anyone can help please?
> > Thanks
> >
> > friol@test:~/web2py> python web2py.py --ip 192.168.168.131
> > web2py Web Framework
> > Created by Massimo Di Pierro, Copyright 2007-2012
> > Version 2.2.1 (2012-10-21 16:57:04) stable
> > Database drivers available: MySQL(pymysql), PostgreSQL(pg8000), 
> IMAP(imaplib)
>
> What database are you using? May be using Sqlite, and this not appear on 
> this list, install it first.
>
> Show us your model.
>
> > WARNING:web2py:GUI not available because Tk library is not installed
> > choose a password:
> > please visit:
> > http://192.168.168.131:8000
> > use "kill -SIGTERM 4341" to shutdown the web2py server
> > DEBUG: connect attempt 0, connection error:
> > Traceback (most recent call last):
> >   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> > self._adapter = ADAPTERS[self._dbname](**kwargs)
> >   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> > if do_connect: self.find_driver(adapter_args)
> >   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> > raise RuntimeError, "no driver available %s" % self.drivers
> > TypeError: not all arguments converted during string formatting
> > DEBUG: connect attempt 1, connection error:
> > Traceback (most recent call last):
> >   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> > self._adapter = ADAPTERS[self._dbname](**kwargs)
> >   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> > if do_connect: self.find_driver(adapter_args)
> >   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> > raise RuntimeError, "no driver available %s" % self.drivers
> > TypeError: not all arguments converted during string formatting
> > DEBUG: connect attempt 2, connection error:
> > Traceback (most recent call last):
> >   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> > self._adapter = ADAPTERS[self._dbname](**kwargs)
> >   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> > if do_connect: self.find_driver(adapter_args)
> >   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> > raise RuntimeError, "no driver available %s" % self.drivers
> > TypeError: not all arguments converted during string formatting
> > DEBUG: connect attempt 3, connection error:
> > Traceback (most recent call last):
> >   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> > self._adapter = ADAPTERS[self._dbname](**kwargs)
> >   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> > if do_connect: self.find_driver(adapter_args)
> >   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> > raise RuntimeError, "no driver available %s" % self.drivers
> > TypeError: not all arguments converted during string formatting
> > DEBUG: connect attempt 4, connection error:
> > Traceback (most recent call last):
> >   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> > self._adapter = ADAPTERS[self._dbname](**kwargs)
> >   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> > if do_connect: self.find_driver(adapter_args)
> >   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> > raise RuntimeError, "no driver available %s" % self.drivers
> > TypeError: not all arguments converted during string formatting
> >
> > -- 
> >  
> >  
> >  
>  

-- 





[web2py] Re: Problem with web2py on Linux

2012-11-14 Thread LightDot
You already opened a thread about this, I suggest continuing there:

https://groups.google.com/d/topic/web2py/Ca_BxwYOYz0/discussion

Regards,
Ales

On Tuesday, November 13, 2012 6:44:07 PM UTC+1, gabriele dantona wrote:
>
>
> Hello, I've installed the source code of web2py on Linux Redhat, but when 
> I do the first call (via web browser) I have this call stack trace:
>
> test@test01:~/web2py> python web2py.py --ip xxx.xxx.xxx.xxx
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2012
> Version 2.2.1 (2012-10-21 16:57:04) stable
> Database drivers available: MySQL(pymysql), PostgreSQL(pg8000), 
> IMAP(imaplib)
> WARNING:web2py:GUI not available because Tk library is not installed
> choose a password:
> please visit:
> http://xxx.xxx.xxx.xxx:8000 
> use "kill -SIGTERM 4341" to shutdown the web2py server
> DEBUG: connect attempt 0, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 1, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 2, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 3, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 4, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
>
> Anyone can help?
>
> Python version is 2.7.3.
>
> Thanks
> Gabriele
>

-- 





[web2py] Re: Some Scheduler questions

2012-11-14 Thread Niphlod
ok, what time does your machine's clock do ?

These tasks will start on your local time 2012-11-14 15:07 (-MM-DD 
HH:MM)

-- 





[web2py] Re: Some Scheduler questions

2012-11-14 Thread Johann Spies
Hallo Niphlod,

Thanks for your answers which cleared up some of the muddy areas in my mind.

Post all the fields, this is far too little to tell what's wrong. 

I have recreated those records.

Here they are:

scheduler_task.id scheduler_task.application_name 
scheduler_task.task_name scheduler_task.group_name scheduler_task.status 
scheduler_task.function_name scheduler_task.uuid scheduler_task.args 
scheduler_task.vars scheduler_task.enabled scheduler_task.start_time 
scheduler_task.next_run_time scheduler_task.stop_time scheduler_task.repeats 
scheduler_task.retry_failed scheduler_task.period scheduler_task.timeout 
scheduler_task.sync_output scheduler_task.times_run 
scheduler_task.times_failed scheduler_task.last_run_time 
scheduler_task.assigned_worker_name  4 akb/appadmin Number of articles per 
publication main QUEUED nr_arts_per_journal 
3ae49c6c-729c-44bb-92d9-35b4900c5695 [] {} True 2012-11-14 15:07:59 2012-11-14 
15:07:59  0 0 3600 60 0 0 0  
 5 akb/appadmin Publishers main QUEUED publishers 
12cdd123-d883-4a48-877f-997242b443f7 [] {} True 2012-11-14 15:08:59 2012-11-14 
15:08:59  0 0 3600 60 0 0 0  
   

-- 





Re: [web2py] Re: web2py as Windows service

2012-11-14 Thread Niphlod


Il giorno mercoledì 14 novembre 2012 11:52:36 UTC+1, David Sorrentino ha 
scritto:
>
> Ok, I managed to make it work.
> I set the *ip* variable to '127.0.0.1'.
>
> So, the ActivePython environment made the trick.
> Thank you very much for your help Tim. ;)
>
> Did anyone else try to run web2py as a Windows service using the .exe 
> install? I'd rather to use the .exe install because in that way I don't 
> need to install Python before installing my app.
>
>  
use something external, web2py binary and services doesn't really get 
along. I use personally the http://nssm.cc/ package and I'm really happy 
with that. 
I "voted" for removing services support within web2py, the code (as all 
code around windows services with python programs) is a copy-paste of a 
copy-paste of a copy-paste of Mark Hammond's original recipe (and that was 
for XP). 
After all, programs like nssm can be more productive and are a piece of 
sotware that basically deals with all the unconsistencies of the Win API.

-- 





[web2py] Re: Some Scheduler questions

2012-11-14 Thread Niphlod


> I have entered two functions in /models/scheduler.py and have added 
> them using:
>
> from gluon.scheduler import Scheduler
> myscheduler = Scheduler(db,dict(nr_arts_per_journal=art_pp, publishers =pbs
> ))
>
> This did not add anything to the table db.scheduler_task.  Is that normal?
>
 
Yep. That means only that you're willing to queue a task named 
"nr_arts_per_journal" and that task should "launch" the art_pp function 
(meaning that you have a def art_pp() somewhere in your app) 
 

> 1.  The default entry in the field application_name is '/appadmin'.  
> Why is /appadmin added?  I suspect I should enter the app name there.  
>

By default tasks are entered in an "applicationname/controller" form. This 
allows to execute eventual conditional models in the right way (i.e. when 
you queue the task from test.py controller, conditional models in 
models/test/ folder will be executed). You don't have to worry about this 
field normally because it's filled by default even when you queue tasks not 
using appadmin
 

> 2.  What 'repeats' mean is not clear to me.  
> 2.1 Does that mean 'repeat x number of times in the period' for each 
> period? 
> 2.2 What does -0 (unlimited) mean in relation to period?  Does that mean: 
> try as many as you can within the period? Or: repeat until ended otherwise 
> once per period?
>
> I though the image on the book was pretty clear. *repeats *means 
"execute this task n times". Repetitive tasks (i.e. whose *repeats *value 
is not 1) will repeat execution every *period *seconds.
 

> 3. In the video, the command 'python web2py.py -K '  showd some info 
> about the runs.  I have started the worker and nothing is showing but:
> 'starting single-scheduler for "akb"...'
>
> How do I get the worker to be more verbose?
>
 
Using web2py.py -K akb -D 0 (-D 0 is "set logging level to debug")
 

>
> 4. I have the following entries in db.scheduler_task:
>
> scheduler_task.application_name scheduler_task.task_name 
> scheduler_task.function_name scheduler_task.repeats 
> scheduler_task.retry_failed scheduler_task.period scheduler_task.timeout  
> akb Number of articles per publication nr_arts_per_journal 3 -1 180 120  
> akb Publishers publishers 1 0 7200 120
>  
> The absent fields were either NULL or the default values.  Both functions 
> were queued and enabled.
>
> Although I have started the worker (python web2py.py -K akb)  nothing is 
> happening.
>
 
Post all the fields, this is far too little to tell what's wrong. 

-- 





Re: [web2py] OperationalError: database is locked

2012-11-14 Thread www.diazluis.com
greetings.
I have the same problem.
but sometimes I throw a cache miss.
and I do not use cache cleared ... I have not configured ..

It had implemented db.executesql ('PRAGMA journal_mode = WAL')


error:

default.py OperationalError: database is locked + details
10_base_config.py OperationalError: database is locked + details
planilla.py ValueError: invalid literal for int() with base 
10: 'cache' + details




El miércoles, 14 de noviembre de 2012 00:41:45 UTC-4:30, Vasile Ermicioi 
escribió:
>
> first be sure you have sqlite >=3.7:
> 1) open python
> 2)>import sqlite3
> 3)>print sqlite3.sqlite_version
>
> if you don't have sqlite >=3.7 you can't use wal
>
> put the code in models/db.py after database connection
>
> db = DAL('sqlite://storage.sqlite')
> db.executesql('PRAGMA journal_mode=WAL')
>
> but you can remove it after one run
>
> read more here http://www.sqlite.org/draft/wal.html
>
>
>

-- 





Re: [web2py] Some Scheduler questions

2012-11-14 Thread Johann Spies
On 14 November 2012 13:58, villas  wrote:

> Hi Johann,
>
> IMO the best way forward is to study the app on github (
> https://github.com/niphlod/**w2p_scheduler_tests
> ).
> After looking at that you should be able to achieve what you want.
>
>
Thanks for the hint. I have done that and still have no success.  The
problem is that that app provides examples, but no real explanations.

I do not understand the so called tests it is supposed to show.

The entries in db.schedular_task are flatly ignored by the worker.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





Re: [web2py] request args

2012-11-14 Thread Vinicius Assef
Are you passing the argument "1" in your URL?


On Tue, Nov 13, 2012 at 9:28 PM, Paul Rykiel  wrote:
> Hi just learning WEB2py and I have a question:
>
> why do i get an error on this code
> *** This code errors out, but when I replace "tag_no" with 1 for record id
> 1, it works, also the variable "tag_no" has a 1 as a value when i type in an
> argument 1 on the end of the URL
>
> def tag():
> tag_no = request.args(0)
> Title = "For Sale"
> Rows = db(db.bike.id==tag_no).select()
> for row in Rows:
>  serial = row.serial
>  make = row.make
>  model = row.model
>  size = row.size
>  color = row.color
>  style = row.style
>  date_of_receipt = row.date_of_receipt
>  repairs = row.repairs_done
>  price = row.price
> return locals()
>
> --
>
>
>

-- 





Re: [web2py] Problem with web2py on Linux

2012-11-14 Thread Vinicius Assef
Try just:
$ python web2py.py

And direct your URL to http://localhost:8000




On Tue, Nov 13, 2012 at 3:44 PM, gabriele dantona  wrote:
>
> Hello, I've installed the source code of web2py on Linux Redhat, but when I
> do the first call (via web browser) I have this call stack trace:
>
> test@test01:~/web2py> python web2py.py --ip xxx.xxx.xxx.xxx
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2012
> Version 2.2.1 (2012-10-21 16:57:04) stable
> Database drivers available: MySQL(pymysql), PostgreSQL(pg8000),
> IMAP(imaplib)
> WARNING:web2py:GUI not available because Tk library is not installed
> choose a password:
> please visit:
> http://xxx.xxx.xxx.xxx:8000
> use "kill -SIGTERM 4341" to shutdown the web2py server
> DEBUG: connect attempt 0, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 1, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 2, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 3, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 4, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
>
> Anyone can help?
>
> Python version is 2.7.3.
>
> Thanks
> Gabriele
>
> --
>
>
>

-- 





Re: [web2py] change database via class?

2012-11-14 Thread Vinicius Assef
You may implement this getting your table fields and checking if your
class has this attribute with hasattr() (it's a Python builtin
function). It should be done in a upper level class, who you should
extend.

But, maybe you're missing that DAL does exactly what you mean: this
mapping between your database physical fields and your properties.

Maybe you could achieve that simply doing this:
>>> Product = db.define_table('product', ...) # all your define_table.

>From now on, you can do:
>>> p = Product(1)
>>> Product.price = 100
>>> Product.name = 'aaa'
>>> Product.update_or_insert()

--
Vinicius Assef


On Wed, Nov 14, 2012 at 6:09 AM, tom h  wrote:
> hi web2py gurus,
>
> just out of curiousity, i'd like to create a class (let's say Product) that
> represents a record in my table "product".  right now, i can't figure out
> how to have the class attributes (p = Product(); p.price) saved to the
> database without internally having p.__fields_dict__ containing ONLY table
> fields, and then map the p.price to p.__fields_dict__['price'], and finally
> doing something like p.db['product'].insert(p.__fields_dict__).
>
> i'm just wondering if there's any better way to do this, sorry i'm pretty
> new to Python as well and probably am missing something.
>
> ideally, i'd like something that's more like:
>
> p = Product(id=1) or Product()
> p.random_var = 'abc'
> p.name = 'a'
> p.price = 100.0
> p.save() # or db['product'].update_or_insert(p)
>
> thanks a lot!
> tom
>
> --
>
>
>

-- 





Re: [web2py] Some Scheduler questions

2012-11-14 Thread villas
Hi Johann,

IMO the best way forward is to study the app on github (
https://github.com/niphlod/w2p_scheduler_tests).
After looking at that you should be able to achieve what you want.

Regards,  D


On Wednesday, November 14, 2012 11:53:23 AM UTC, Johann Spies wrote:
>
> On 14 November 2012 12:55, Johann Spies 
> > wrote:
>
>> 3. In the video, the command 'python web2py.py -K '  showd some info 
>> about the runs.  I have started the worker and nothing is showing but:
>> 'starting single-scheduler for "akb"...'
>>
>> How do I get the worker to be more verbose?
>>
>>
> OK I have read more about the startup options:
>
> python web2py.py -v -D 20 -K akb
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2012
> Version 2.2.1 (2012-11-09 14:11:30) stable
> Database drivers available: SQLite(sqlite2), SQLite(sqlite3), 
> MySQL(pymysql), PostgreSQL(psycopg2), PostgreSQL(pg8000), IMAP(imaplib)
> starting single-scheduler for "akb"...
> INFO:web2py.scheduler:nothing to do
> INFO:web2py.scheduler:nothing to do
>
> Why does the scheduler not find my scheduled_tasks?
>
> Regards
> Johann 
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>
>

-- 





Re: [web2py] Some Scheduler questions

2012-11-14 Thread Johann Spies
On 14 November 2012 12:55, Johann Spies  wrote:

> 3. In the video, the command 'python web2py.py -K '  showd some info
> about the runs.  I have started the worker and nothing is showing but:
> 'starting single-scheduler for "akb"...'
>
> How do I get the worker to be more verbose?
>
>
OK I have read more about the startup options:

python web2py.py -v -D 20 -K akb
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2012
Version 2.2.1 (2012-11-09 14:11:30) stable
Database drivers available: SQLite(sqlite2), SQLite(sqlite3),
MySQL(pymysql), PostgreSQL(psycopg2), PostgreSQL(pg8000), IMAP(imaplib)
starting single-scheduler for "akb"...
INFO:web2py.scheduler:nothing to do
INFO:web2py.scheduler:nothing to do

Why does the scheduler not find my scheduled_tasks?

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





Re: [web2py] How to get a filter subset?

2012-11-14 Thread Johann Spies
On 13 November 2012 19:04, John Ho  wrote:

> For a school admin database, different roles for logged in users:  admin,
> teachers and staff.  I can use using auth_group and auth_membership to
> define these roles.
>
> I have the following table:
>
> db.define_table( "class", Field("teacher_id", db.auth_user), ...)
>
> want a form to create a new class, very nice that web2py will done most of
> the work of creating a form with drop-down list of auth_users for the
> "teacher_id" field.  However, I don't want the whole list of auth_users, I
> would like the list to be filtered to only show users with "teacher" role.
>
> I think using the _and=IS_IN_DB() to get the subset, not quite sure how to
> write it.
>
>
One option is to build a set with a separate query and use IS_IN_SET()

Something like

teachers = [x.teacher_id for x in db(class.teacher_id >
0).select(db.class.teacher_id)

and then IS_IN_SET(teachers)

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





Re: [web2py] Re: Getting error near "interval_time": syntax error

2012-11-14 Thread Amit
100% correct :) , now facing problem of replacing the query with sqlite
compatible query :

MySql query were:

*query = Expression(db,"date_sub(now(),interval interval_time minute) >
updated_on")*

where interval_time field is integer field which will be considered to take
interval in minutes for e.g. if user wants to save the interval time is 1
hour then he has to enter it in minutes means 60 minutes.

Now problem is when i tried to replace the above query with sqlite
compitible query like below and pass to the db to get the required records:

*query = Expression(db,"date('now','-interval_time minutes') > updated_on")*

it returns nothing.
So can you please help me out write the above query in Sqlite.

Thanks,
Amit



On Wed, Nov 14, 2012 at 3:36 PM, Niphlod  wrote:

>
> Il giorno mercoledì 14 novembre 2012 09:51:43 UTC+1, Amit ha scritto:
>
>> Hi,
>> I am getting error
>> * near "interval_time": syntax error*
>>
>
> syntax error points to something around "interval_time".. my bet is on
> date_sub() not supported by sqlite
>
> http://www.sqlite.org/cvstrac/wiki/wiki?p=DateAndTimeFunctions
>
>
> --
>
>
>
>

-- 





Re: [web2py] Problem with fresh install of web2py on Linux

2012-11-14 Thread Roberto Perdomo
El 14/11/2012 07:44, "gabriele dantona"  escribió:
>
> Hello,

Hi,

> I've installed web2py on Linux Redhat 64bit with Python 2.7.3.
>
> After starting the server, the first request fails with this stack trace.
Anyone can help please?
> Thanks
>
> friol@test:~/web2py> python web2py.py --ip 192.168.168.131
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2012
> Version 2.2.1 (2012-10-21 16:57:04) stable
> Database drivers available: MySQL(pymysql), PostgreSQL(pg8000),
IMAP(imaplib)

What database are you using? May be using Sqlite, and this not appear on
this list, install it first.

Show us your model.

> WARNING:web2py:GUI not available because Tk library is not installed
> choose a password:
> please visit:
> http://192.168.168.131:8000
> use "kill -SIGTERM 4341" to shutdown the web2py server
> DEBUG: connect attempt 0, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 1, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 2, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 3, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
> DEBUG: connect attempt 4, connection error:
> Traceback (most recent call last):
>   File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
> self._adapter = ADAPTERS[self._dbname](**kwargs)
>   File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
> if do_connect: self.find_driver(adapter_args)
>   File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
> raise RuntimeError, "no driver available %s" % self.drivers
> TypeError: not all arguments converted during string formatting
>
> --
>
>
>

-- 





Re: [web2py] request args

2012-11-14 Thread David Sorrentino
Hello Paul,

request.args[0] returns a string, and for *Rows =
db(db.bike.id==tag_no).select()
*you need an integer.
Try this:

tag_no = int(request.args(0))
>

And let me know.

Cheers,
David


On 14 November 2012 00:28, Paul Rykiel  wrote:

> Hi just learning WEB2py and I have a question:
>
> why do i get an error on this code
>  This code errors out, but when I replace "tag_no" with 1 for record
> id 1, it works, also the variable "tag_no" has a 1 as a value when i type
> in an argument 1 on the end of the URL *
>
> def tag():
> tag_no = request.args(0)
> Title = "For Sale"
>   *  Rows = db(db.bike.id==tag_no).select()   *
> for row in Rows:
>  serial = row.serial
>  make = row.make
>  model = row.model
>  size = row.size
>  color = row.color
>  style = row.style
>  date_of_receipt = row.date_of_receipt
>  repairs = row.repairs_done
>  price = row.price
> return locals()
>
> --
>
>
>
>

-- 





[web2py] Some Scheduler questions

2012-11-14 Thread Johann Spies
I am for the first time trying to use the scheduler and so far it was 
unsuccessful :(

I have watched the video on vimeo on the scheduler and I suspect that is a 
bit old.

I have read what was written in the book as well as the docstrings in 
gluon/scheduler.py.

I have entered two functions in /models/scheduler.py and have added 
them using:

from gluon.scheduler import Scheduler
myscheduler = Scheduler(db,dict(nr_arts_per_journal=art_pp, publishers = pbs
))

This did not add anything to the table db.scheduler_task.  Is that normal?

So I used the appadmin interface to add them the functions.

Some options are not clear to me:

1.  The default entry in the field application_name is '/appadmin'.  
Why is /appadmin added?  I suspect I should enter the app name there.  

2.  What 'repeats' mean is not clear to me.  
2.1 Does that mean 'repeat x number of times in the period' for each 
period? 
2.2 What does -0 (unlimited) mean in relation to period?  Does that mean: 
try as many as you can within the period? Or: repeat until ended otherwise 
once per period?

3. In the video, the command 'python web2py.py -K '  showd some info 
about the runs.  I have started the worker and nothing is showing but:
'starting single-scheduler for "akb"...'

How do I get the worker to be more verbose?

4. I have the following entries in db.scheduler_task:

 scheduler_task.application_name scheduler_task.task_name 
scheduler_task.function_name scheduler_task.repeats 
scheduler_task.retry_failed scheduler_task.period scheduler_task.timeout  
akb Number of articles per publication nr_arts_per_journal 3 -1 180 120  akb 
Publishers publishers 1 0 7200 120
 
The absent fields were either NULL or the default values.  Both functions 
were queued and enabled.

Although I have started the worker (python web2py.py -K akb)  nothing is 
happening.

How do I get the scheduler to handle those tasks?  

Are my options wrong?

Regards
Johann




-- 





Re: [web2py] Re: web2py as Windows service

2012-11-14 Thread David Sorrentino
Thanks to Niphlod, too. I hadn't seen your post! ;)

Cheers,
David


On 14 November 2012 11:52, David Sorrentino  wrote:

> Ok, I managed to make it work.
> I set the *ip* variable to '127.0.0.1'.
>
> So, the ActivePython environment made the trick.
> Thank you very much for your help Tim. ;)
>
> Did anyone else try to run web2py as a Windows service using the .exe
> install? I'd rather to use the .exe install because in that way I don't
> need to install Python before installing my app.
>
> Cheers,
> David
>
>
>
> On 14 November 2012 11:07, David Sorrentino wrote:
>
>> I just tried with ActivePython 2.7 and it works. I mean, at least the
>> task manager says that the service is running. :)
>> However I do not manage to make web2py work.
>> I am pretty sure that the problem is in my* option.py* file.
>> Now it looks like that:
>>
>> import socket
>>> import os
>>>
>>> ip = socket.gethostname()
>>> port = 8000
>>> interfaces = [('0.0.0.0', 80)]
>>>
>>> #,('0.0.0.0',443,'ssl_private_key.pem','ssl_certificate.pem')]
>>> password = ''  # ##  means use the previous password
>>>
>>> pid_filename = 'httpserver.pid'
>>> log_filename = 'httpserver.log'
>>> profiler_filename = None
>>> ssl_certificate = None  # 'ssl_certificate.pem'  # ## path to
>>> certificate file
>>> ssl_private_key = None  # 'ssl_private_key.pem'  # ## path to private
>>> key file
>>>
>>> #numthreads = 50 # ## deprecated; remove
>>> minthreads = None
>>> maxthreads = None
>>> server_name = socket.gethostname()
>>> request_queue_size = 5
>>> timeout = 30
>>> shutdown_timeout = 5
>>> folder = os.getcwd()
>>> extcron = None
>>> nocron = None
>>>
>>
>> It should work with the URL 127.0.0.1:8000, but it does not. And I do
>> not understand what *interfaces *is. :(
>> Any thoughts?
>>
>> Best,
>> David
>>
>>
>>
>> On 14 November 2012 10:25, Tim Richardson  wrote:
>>
>>> Hi David,
>>> for me the service installation has worked every time I've used it ...
>>> but that's with the ActivePython 2.7 distribution on the windows boxes, and
>>> therefore with a source installation of web2py.
>>>
>>> My practical advice is go for this set up and see if that fixes the
>>> problem. You get a considerably different Python distribution this way.
>>>
>>> regards
>>>
>>> Tim
>>>
>>>
>>>
>>> On Wednesday, 14 November 2012 18:30:38 UTC+11, David Sorrentino wrote:
>>>
 Hello Derek and Tim,

 First of all thanks for your reply. :)

 @Derek: I do not see any log in the logs folder, but logging is not
 enabled. This morning I will enable it and tell you the results.

 @Tim: I am testing my app on Windows 7. I did not install any Python
 distribution on Windows, since I have the need of using the .exe install.
 However the application has been compiled and packed on Linux
 (archlinux), with web2py version 2.2.1 and Python 2.7.3 .

 Can I help more?

 I wish you a wonderful day.
 David


  On 14 November 2012 03:27, Tim Richardson wrote:

> what kind of Windows is it? How did you install Python, and which
> distribution is it?
> Is your Web2py a source code install, or the .exe install?
>
>  --
>
>
>
>

  --
>>>
>>>
>>>
>>>
>>
>>
>

-- 





Re: [web2py] Re: web2py as Windows service

2012-11-14 Thread David Sorrentino
Ok, I managed to make it work.
I set the *ip* variable to '127.0.0.1'.

So, the ActivePython environment made the trick.
Thank you very much for your help Tim. ;)

Did anyone else try to run web2py as a Windows service using the .exe
install? I'd rather to use the .exe install because in that way I don't
need to install Python before installing my app.

Cheers,
David


On 14 November 2012 11:07, David Sorrentino  wrote:

> I just tried with ActivePython 2.7 and it works. I mean, at least the task
> manager says that the service is running. :)
> However I do not manage to make web2py work.
> I am pretty sure that the problem is in my* option.py* file.
> Now it looks like that:
>
> import socket
>> import os
>>
>> ip = socket.gethostname()
>> port = 8000
>> interfaces = [('0.0.0.0', 80)]
>>
>> #,('0.0.0.0',443,'ssl_private_key.pem','ssl_certificate.pem')]
>> password = ''  # ##  means use the previous password
>>
>> pid_filename = 'httpserver.pid'
>> log_filename = 'httpserver.log'
>> profiler_filename = None
>> ssl_certificate = None  # 'ssl_certificate.pem'  # ## path to certificate
>> file
>> ssl_private_key = None  # 'ssl_private_key.pem'  # ## path to private key
>> file
>>
>> #numthreads = 50 # ## deprecated; remove
>> minthreads = None
>> maxthreads = None
>> server_name = socket.gethostname()
>> request_queue_size = 5
>> timeout = 30
>> shutdown_timeout = 5
>> folder = os.getcwd()
>> extcron = None
>> nocron = None
>>
>
> It should work with the URL 127.0.0.1:8000, but it does not. And I do not
> understand what *interfaces *is. :(
> Any thoughts?
>
> Best,
> David
>
>
>
> On 14 November 2012 10:25, Tim Richardson  wrote:
>
>> Hi David,
>> for me the service installation has worked every time I've used it ...
>> but that's with the ActivePython 2.7 distribution on the windows boxes, and
>> therefore with a source installation of web2py.
>>
>> My practical advice is go for this set up and see if that fixes the
>> problem. You get a considerably different Python distribution this way.
>>
>> regards
>>
>> Tim
>>
>>
>>
>> On Wednesday, 14 November 2012 18:30:38 UTC+11, David Sorrentino wrote:
>>
>>> Hello Derek and Tim,
>>>
>>> First of all thanks for your reply. :)
>>>
>>> @Derek: I do not see any log in the logs folder, but logging is not
>>> enabled. This morning I will enable it and tell you the results.
>>>
>>> @Tim: I am testing my app on Windows 7. I did not install any Python
>>> distribution on Windows, since I have the need of using the .exe install.
>>> However the application has been compiled and packed on Linux
>>> (archlinux), with web2py version 2.2.1 and Python 2.7.3 .
>>>
>>> Can I help more?
>>>
>>> I wish you a wonderful day.
>>> David
>>>
>>>
>>>  On 14 November 2012 03:27, Tim Richardson wrote:
>>>
 what kind of Windows is it? How did you install Python, and which
 distribution is it?
 Is your Web2py a source code install, or the .exe install?

  --




>>>
>>>  --
>>
>>
>>
>>
>
>

-- 





[web2py] Please help me, add button not work

2012-11-14 Thread Ton Dong
Hi all,

I am a newbie in web design. I followed the instructions in the video 
"Build an online store with web2py" at http://vimeo.com/20768689
I don't know why I can not add any items to cart. Please help me to show 
where I was wrong. Thank you a lot.

~ Ton Dong
The code:

- Model: hmw.py
# coding: utf8
db.define_table(
'product',
  Field('nameproduct', 'string',notnull=True,unique=True, length=30),
  Field('price', 'double'),
  Field('desciption', 'text'),
  Field('image','upload'),
  Field('sortable','integer'),
  auth.signature,
  format = '%(nameproduct)s',
  singular = 'product',
  plural = 'products',
  )
db.define_table(
 'sale',
  Field('invoice'),
  Field('creditcard'),
  Field('buyer',db.auth_user),
  Field('product',db.product),
  Field('quantity','integer'),
  Field('price', 'double'),
  Field('shipped', 'boolean', default=False),
  auth.signature,
  )

- Conntroller:
def index():
session.cart = session.cart 
products = db(db.product).select(orderby=db.product.sortable)
return locals()
 
def user():
return dict(form=auth())

def download():
return response.download(request,db)
def call():
session.forget()
return service()
@auth.requires_login()
def cart():
return dict(cart=session.cart)

@auth.requires_login()
def pay():
import uuid
invoice = str(uuid.uuid4())
total = sum(db.product(id).price*qty for id, qty in 
session.cart.items())
form = SQLFORM.factory(Field('creditcard',default='000'),
   Field('expiration', default='12/2015'),
   Field('cvv', default='111'),
   
Field('total','double',default=total,writable=False))
if form.accepts(request,session):
  if process(form.vars.creditcard, form.vars.expiration, total, 
form.vars.cvv,0.0,'invoice'):  
for key, value in sesssion.cart.items():
db.sale.insert(invoice=invoice,
buyer=auth.user.id,
product=key,
quantity = value,
price = db.product(key).price,
creditcard = form.vars.creditcard)
session.cart.clear()
session.flash = 'Thanks for your order'   
redirect(URL('index'))
return dict(cart=session.cart, form=form)

def cart_callback():
id = int(request.vars.id)
if request.vars.action == 'add':
session.cart[id] = int(session.cart.get(id,0))+1
if request.vars.action == 'sub':
session.cart[id] = max(0,session.cart.get(id,0)-1)
return str(session.cart[id])

- index.html

{{extend 'layout.html'}}
{{for p in products:}}

 {{=p.nameproduct}} - ${{=p.price}} 

http://127.0.0.1:8000/examples/global/vars/URL>('download', args=p.image)}}" />

{{=session 
.cart.get(p.id,0)}} 
in cart
http://127.0.0.1:8000/examples/global/vars/URL>('cart_callback', 
vars=dict(id=p.id,action='add'))}}',[],'item{{=p.id}}')'>add 
  

{{pass}}



 

-- 





[web2py] Empty "db stats" and "db tables" in response.toolbar() despite database connection - MySQL

2012-11-14 Thread Maciej Kwiecień
Dear All, 

I'm using 2.2.1 version on Apache 2.2.19 with ssl, on Windows 7 (64 bit). 
The database engine is MySQL. 

No matter how my models look like I never get anything in "db stats" and 
"db tables" info in response.toolbar().
When I explicitly output db._timings in the view, at least 3 queries are 
shown.

What can be the reason?

Thank you!
Maciek

-- 





[web2py] How to get a filter subset?

2012-11-14 Thread John Ho
For a school admin database, different roles for logged in users:  admin, 
teachers and staff.  I can use using auth_group and auth_membership to 
define these roles.

I have the following table:

db.define_table( "class", Field("teacher_id", db.auth_user), ...)

want a form to create a new class, very nice that web2py will done most of 
the work of creating a form with drop-down list of auth_users for the 
"teacher_id" field.  However, I don't want the whole list of auth_users, I 
would like the list to be filtered to only show users with "teacher" role.

I think using the _and=IS_IN_DB() to get the subset, not quite sure how to 
write it.

Another option is to create a DB View, cannot find out how web2py works 
with DB views.

-- 





[web2py] Re: AJAX form submission with image upload

2012-11-14 Thread Krisha Teja


On Monday, 26 December 2011 22:12:27 UTC+5:30, Yarin wrote:
>
> @Massimo, this worked for me- thanks a lot. 
>
> I'd suggest making mention of jquery.form.js in the regular book as 
> well. 
>
> Yarin 
>
> On Dec 25, 1:31 am, Massimo Di Pierro  
> wrote: 
> > The only way around this is using thishttp://jquery.malsup.com/form/ 
>









it worked fine how to insert the returned file into db i got ['[object 
File]', FieldStorage('image', 'a.py','dsaa') 
 how to store it in db
 

> > 
> > There is a web2py slice about this and an extended recipe in this 
> > book:
> http://www.packtpub.com/web2py-application-development-recipes-to-mas... 
> > 
> > we decided not to include jquery.form.js in web2py because it is a 
> > workaround to the specs (lack of multipart forms in ajax) and 
> > therefore it has to be handled in a special way serverside. 
> > 
> > massimo 
> > 
> > On Dec 24, 8:00 pm, Yarin  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Just found this in the docs, which perhaps partially answers my 
> > > question: 
> > 
> > > "*Please note:* Because Ajax post does not support multipart forms, 
> > > i.e. file uploads, upload fields will not work with the LOAD 
> > > component. You could be fooled into thinking it would work because 
> > > upload fields will function normally if POST is done from the 
> > > individual component's .load view. Instead, uploads are done 
> > > with ajax- compatible 3rd-party widgets and web2py manual upload 
> > > store commands."http://web2py.com/books/default/chapter/29/12? 
> > > search=upload 
>
> > 
> > >  Does this mean I have to do uploads manually? I'm looking at http:// 
> > > web2py.com/book/default/chapter/06#Manual-uploads but I'm not clear 
> on 
> > > where/how I would perform this. 
> > 
> > > My table definition: db.define_table('image', Field('title', 
> > > required=True), Field('file', 'upload')) 
> > 
> > > On Dec 24, 8:09 pm, Yarin  wrote: 
> > 
> > > > Merry Christmas 
> > 
> > > > I need to do an AJAX form submission for a basic image table. I'm 
> > > > following the strategy described here:
> http://web2py.com/books/default/chapter/29/11#Ajax-form-submission 
> > 
> > > > whereby I create an HTML form by hand, and have a SQLForm handle the 
> > > > submission. The record gets inserted fine, except that the image I 
> > > > choose is not being uploaded, but a .txt file shows up in the 
> uploads 
> > > > folder instead. 
> > 
> > > > Is it possible to use web2py's upload functionality with AJAX 
> > > > submissions? What are my options here? 
> > 
> > > > (NOTE: I need to use native jQuery ajax, not web2py ajax helpers, 
> due 
> > > > to extenuating circumstances) 
> > 
> > > > The form: 
> > 
> > > >  
> > > >  > > > value=""> 
> > > >  
> > > >  
> > > >  
> > 
> > > >  
> > 
> > > > $(function() { 
> > 
> > > > $('#image-form').submit(function() { 
> > 
> > > > $.update('{{=URL(c='images', 
> f='process')}}', { 
> > > > title: $('#image_title').val(), 
> > > > file: $('#image_file').val(), 
> > > > }); 
> > > > return false; 
> > > > });}); 
> > 
> > > > 

-- 





[web2py] Problem with web2py on Linux

2012-11-14 Thread gabriele dantona

Hello, I've installed the source code of web2py on Linux Redhat, but when I 
do the first call (via web browser) I have this call stack trace:

test@test01:~/web2py> python web2py.py --ip xxx.xxx.xxx.xxx
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2012
Version 2.2.1 (2012-10-21 16:57:04) stable
Database drivers available: MySQL(pymysql), PostgreSQL(pg8000), 
IMAP(imaplib)
WARNING:web2py:GUI not available because Tk library is not installed
choose a password:
please visit:
http://xxx.xxx.xxx.xxx:8000 
use "kill -SIGTERM 4341" to shutdown the web2py server
DEBUG: connect attempt 0, connection error:
Traceback (most recent call last):
  File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
  File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
if do_connect: self.find_driver(adapter_args)
  File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
raise RuntimeError, "no driver available %s" % self.drivers
TypeError: not all arguments converted during string formatting
DEBUG: connect attempt 1, connection error:
Traceback (most recent call last):
  File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
  File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
if do_connect: self.find_driver(adapter_args)
  File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
raise RuntimeError, "no driver available %s" % self.drivers
TypeError: not all arguments converted during string formatting
DEBUG: connect attempt 2, connection error:
Traceback (most recent call last):
  File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
  File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
if do_connect: self.find_driver(adapter_args)
  File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
raise RuntimeError, "no driver available %s" % self.drivers
TypeError: not all arguments converted during string formatting
DEBUG: connect attempt 3, connection error:
Traceback (most recent call last):
  File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
  File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
if do_connect: self.find_driver(adapter_args)
  File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
raise RuntimeError, "no driver available %s" % self.drivers
TypeError: not all arguments converted during string formatting
DEBUG: connect attempt 4, connection error:
Traceback (most recent call last):
  File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
  File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
if do_connect: self.find_driver(adapter_args)
  File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
raise RuntimeError, "no driver available %s" % self.drivers
TypeError: not all arguments converted during string formatting

Anyone can help?

Python version is 2.7.3.

Thanks
Gabriele

-- 





[web2py] Please help me, add button not work

2012-11-14 Thread Ton Dong


Hi all,

I am a newbie in web design. I followed the instructions in the video "Build an 
online store with web2py" at http://vimeo.com/20768689
I don't know why I can not add any items to cart, It always 0 items. Please 
help me to show where I was wrong. Thank you a lot.

~ Ton Dong
- Models: hmw.py
# coding: utf8
db.define_table(
'product',
  Field('nameproduct', 'string',notnull=True,unique=True, length=30),
  Field('price', 'double'),
  Field('desciption', 'text'),
  Field('image','upload'),
  Field('sortable','integer'),
  auth.signature,
  format = '%(nameproduct)s',
  singular = 'product',
  plural = 'products',
  )
db.define_table(
 'sale',
  Field('invoice'),
  Field('creditcard'),
  Field('buyer',db.auth_user),
  Field('product',db.product),
  Field('quantity','integer'),
  Field('price', 'double'),
  Field('shipped', 'boolean', default=False),
  auth.signature,
  )

- Controller/default.py
def index():
session.cart = session.cart 
products = db(db.product).select(orderby=db.product.sortable)
return locals()
 
def user():
return dict(form=auth())

def download():
return response.download(request,db)
def call():
session.forget()
return service()
@auth.requires_login()
def cart():
return dict(cart=session.cart)

@auth.requires_login()
def pay():
import uuid
invoice = str(uuid.uuid4())
total = sum(db.product(id).price*qty for id, qty in session.cart.items())
form = SQLFORM.factory(Field('creditcard',default='000'),
   Field('expiration', default='12/2015'),
   Field('cvv', default='111'),
   Field('total','double',default=total,writable=False))
if form.accepts(request,session):
  if process(form.vars.creditcard, form.vars.expiration, total, 
form.vars.cvv,0.0,'invoice'):  
for key, value in sesssion.cart.items():
db.sale.insert(invoice=invoice,
buyer=auth.user.id,
product=key,
quantity = value,
price = db.product(key).price,
creditcard = form.vars.creditcard)
session.cart.clear()
session.flash = 'Thanks for your order'   
redirect(URL('index'))
return dict(cart=session.cart, form=form)

def cart_callback():
id = int(request.vars.id)
if request.vars.action == 'add':
session.cart[id] = int(session.cart.get(id,0))+1
if request.vars.action == 'sub':
session.cart[id] = max(0,session.cart.get(id,0)-1)
return str(session.cart[id])

- Views/index.html

{{extend 'layout.html'}}
{{for p in products:}}

 {{=p.nameproduct}} - ${{=p.price}} 

http://127.0.0.1:8000/examples/global/vars/URL>('download', args=p.image)}}" />

{{=session 
.cart.get(p.id,0)}} 
in cart
http://127.0.0.1:8000/examples/global/vars/URL>('cart_callback', 
vars=dict(id=p.id,action='add'))}}',[],'item{{=p.id}}')'>add 
  

{{pass}}

-- 





[web2py] How to open a ticket on the web2py itself?

2012-11-14 Thread Maciej Kwiecień
Regards,

After spending significant amount of time on futile searching on the 
Internet, Google Groups and web2py book itself I'm asking the question I 
was asking myself from the very beginning:

Where to add and browse bugs / issues / tickets about the web2py itself? 
This place has to exist, but unfortunately nothing is mentioned in the book 
nor the website. Or maybe I'm searching incorrectly?

Thank you for your help!
Maciek

-- 





[web2py] Re: step-by step instructions installing web2py on a CentOS server with cPanel installed

2012-11-14 Thread Daniele
Bump! I'd also like to see a guide on how to do this.

On Friday, January 21, 2011 9:18:12 PM UTC, stargate wrote:
>
> I as wondering if there is step-by step instructions installing web2py 
> on a CentOS version 4.x server with cPanel installed.

-- 





[web2py] Re: Retype password: None

2012-11-14 Thread Daniele
Hmm I can't figure out how to get the entropy check on a custom form. I'm 
using a vanilla Twitter Bootstrap without all the web2py stuff because it 
was breaking my layout.

Is there a way to get password entropy check on custom forms with plain 
Twitter Bootstrap css files??


On Monday, November 12, 2012 4:52:53 PM UTC, Daniele wrote:
>
> Once I have the class, how can I get the jQuery entropy check for password 
> strength to change the background color? Again, this is on a custom form so 
> I'm having quite some trouble with this...
>
> On Monday, November 12, 2012 3:51:48 PM UTC, Massimo Di Pierro wrote:
>>
>> form.element(name='email').add_class('test')
>>
>> On Sunday, 11 November 2012 21:03:04 UTC-6, Daniele wrote:
>>>
>>> I am writing a custom registration form. I noticed that in the 
>>> controller, if I put
>>>
>>> def signup():
>>> return dict(form=auth.register())
>>>
>>> I get a Retype password field. However, if I put
>>>
>>> def signup():
>>> form = SQLFORM(auth.settings.table_user,
>>> labels = {'email':'Email address'},
>>> submit_button = 'Sign up',
>>> separator = '', _class='form-horizontal')
>>> return dict(form=form)
>>>
>>> I get None for the Retype password field. How can I fix this?
>>>
>>> Also, how can I specify the class of the fields and buttons??
>>>
>>> Thanks!
>>>
>>

-- 





[web2py] request args

2012-11-14 Thread Paul Rykiel
Hi just learning WEB2py and I have a question:
 
why do i get an error on this code
 This code errors out, but when I replace "tag_no" with 1 for record id 
1, it works, also the variable "tag_no" has a 1 as a value when i type in 
an argument 1 on the end of the URL *
 
def tag():
tag_no = request.args(0) 
Title = "For Sale"
  *  Rows = db(db.bike.id==tag_no).select()   *
for row in Rows:
 serial = row.serial
 make = row.make
 model = row.model
 size = row.size
 color = row.color
 style = row.style
 date_of_receipt = row.date_of_receipt
 repairs = row.repairs_done
 price = row.price
return locals()

-- 





[web2py] Problem with fresh install of web2py on Linux

2012-11-14 Thread gabriele dantona
Hello,
I've installed web2py on Linux Redhat 64bit with Python 2.7.3.

After starting the server, the first request fails with this stack trace. 
Anyone can help please?
Thanks

friol@test:~/web2py> python web2py.py --ip 192.168.168.131
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2012
Version 2.2.1 (2012-10-21 16:57:04) stable
Database drivers available: MySQL(pymysql), PostgreSQL(pg8000), 
IMAP(imaplib)
WARNING:web2py:GUI not available because Tk library is not installed
choose a password:
please visit:
http://192.168.168.131:8000
use "kill -SIGTERM 4341" to shutdown the web2py server
DEBUG: connect attempt 0, connection error:
Traceback (most recent call last):
  File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
  File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
if do_connect: self.find_driver(adapter_args)
  File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
raise RuntimeError, "no driver available %s" % self.drivers
TypeError: not all arguments converted during string formatting
DEBUG: connect attempt 1, connection error:
Traceback (most recent call last):
  File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
  File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
if do_connect: self.find_driver(adapter_args)
  File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
raise RuntimeError, "no driver available %s" % self.drivers
TypeError: not all arguments converted during string formatting
DEBUG: connect attempt 2, connection error:
Traceback (most recent call last):
  File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
  File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
if do_connect: self.find_driver(adapter_args)
  File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
raise RuntimeError, "no driver available %s" % self.drivers
TypeError: not all arguments converted during string formatting
DEBUG: connect attempt 3, connection error:
Traceback (most recent call last):
  File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
  File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
if do_connect: self.find_driver(adapter_args)
  File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
raise RuntimeError, "no driver available %s" % self.drivers
TypeError: not all arguments converted during string formatting
DEBUG: connect attempt 4, connection error:
Traceback (most recent call last):
  File "/home/aomoper/web2py/gluon/dal.py", line 6755, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
  File "/home/aomoper/web2py/gluon/dal.py", line 2079, in __init__
if do_connect: self.find_driver(adapter_args)
  File "/home/aomoper/web2py/gluon/dal.py", line 695, in find_driver
raise RuntimeError, "no driver available %s" % self.drivers
TypeError: not all arguments converted during string formatting

-- 





Fw: [web2py] SQLFORM.smartgrid. This is a bug?

2012-11-14 Thread Marco Mansilla


Inicio del mensaje redirigido:

Fecha: Tue, 13 Nov 2012 15:27:38 -0300
Desde: Marco Mansilla 
Para: web2py@googlegroups.com
Asunto: Re: [web2py] SQLFORM.smartgrid. This is a bug?


still you need to give to orderby the name of the field that you want
to order, even when the table has only one field... but the error seems
odd...

def something():
 grilla = SQLFORM.smartgrid(table_1, orderby=table_1.name)

also, since you you don't use represent you could add format at the end
of your table definition...

#Model:
table_1 = db.define_table('table1',
Field('name'),
format='%(name)s')
> 
> 
> El martes, 13 de noviembre de 2012 02:10:03 UTC-3, marco mansilla
> escribió:
> >
> > aren't you missing the db. before table? 
> >
> 
>  
> No, the way I define the table is not necessary
> 
> table_1 = db.define_table('table1',
> Field('name'),
> )
> 
> *table_1 *is equals to* db.table1*
> 
> Jose
> 

-- 





Re: [web2py] Re: web2py as Windows service

2012-11-14 Thread Niphlod
nope interfaces is a list of tuples of ip,port,key,cert where the 
webserver replies . like the -i option on cmdline it helps to let the 
webserver reply on different ports. I think "interfaces" trumps "ip" and 
"port" parameters



Il giorno mercoledì 14 novembre 2012 11:07:50 UTC+1, David Sorrentino ha 
scritto:
>
> I just tried with ActivePython 2.7 and it works. I mean, at least the task 
> manager says that the service is running. :)
> However I do not manage to make web2py work.
> I am pretty sure that the problem is in my* option.py* file.
> Now it looks like that:
>
> import socket
>> import os
>>
>> ip = socket.gethostname()
>> port = 8000
>> interfaces = [('0.0.0.0', 80)]
>>
>> #,('0.0.0.0',443,'ssl_private_key.pem','ssl_certificate.pem')]
>> password = ''  # ##  means use the previous password
>> pid_filename = 'httpserver.pid'
>> log_filename = 'httpserver.log'
>> profiler_filename = None
>> ssl_certificate = None  # 'ssl_certificate.pem'  # ## path to certificate 
>> file
>> ssl_private_key = None  # 'ssl_private_key.pem'  # ## path to private key 
>> file
>> #numthreads = 50 # ## deprecated; remove
>> minthreads = None
>> maxthreads = None
>> server_name = socket.gethostname()
>> request_queue_size = 5
>> timeout = 30
>> shutdown_timeout = 5
>> folder = os.getcwd()
>> extcron = None
>> nocron = None
>>
>
> It should work with the URL 127.0.0.1:8000, but it does not. And I do not 
> understand what *interfaces *is. :(
> Any thoughts? 
>
> Best,
> David
>
>
> On 14 November 2012 10:25, Tim Richardson 
> > wrote:
>
>> Hi David,
>> for me the service installation has worked every time I've used it ... 
>> but that's with the ActivePython 2.7 distribution on the windows boxes, and 
>> therefore with a source installation of web2py.
>>
>> My practical advice is go for this set up and see if that fixes the 
>> problem. You get a considerably different Python distribution this way. 
>>
>> regards
>>
>> Tim
>>
>>
>>
>> On Wednesday, 14 November 2012 18:30:38 UTC+11, David Sorrentino wrote:
>>
>>> Hello Derek and Tim,
>>>
>>> First of all thanks for your reply. :)
>>>
>>> @Derek: I do not see any log in the logs folder, but logging is not 
>>> enabled. This morning I will enable it and tell you the results.
>>>
>>> @Tim: I am testing my app on Windows 7. I did not install any Python 
>>> distribution on Windows, since I have the need of using the .exe install.
>>> However the application has been compiled and packed on Linux 
>>> (archlinux), with web2py version 2.2.1 and Python 2.7.3 .
>>>
>>> Can I help more?
>>>
>>> I wish you a wonderful day.
>>> David
>>>
>>>
>>>  On 14 November 2012 03:27, Tim Richardson wrote:
>>>
 what kind of Windows is it? How did you install Python, and which 
 distribution is it? 
 Is your Web2py a source code install, or the .exe install?

  -- 
  
  
  

>>>
>>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] postgres problem with crud.update

2012-11-14 Thread Johann Spies
Hallo Andreij,
On 14 November 2012 11:50, andrej burja  wrote:

> i've made app using wizzard
> i addes tags
> db.define_table('t_tag',
> Field('f_game_id', type='reference t_game',
>   label=T('Game Id')),
> Field('f_name', type='string',
>   label=T('Name')),
> auth.signature,
> format='%(f_game_id)s',
> migrate=settings.migrate)
>
> db.define_table('t_tag_archive',db.t_tag,Field('current_record','reference
> t_tag',readable=False,writable=False))
>
> in controller i have crud.update
> form =
> make_taggable_eq(crud.update(db.t_game,record,onaccept=update_tags_eq))
>
> if i want to delete game, there is an error:
>  insert or update on table "t_tag"
> violates foreign key constraint "t_tag_f_game_id_fkey" DETAIL: Key
> (f_game_id)=(699) is not present in table "t_game".
>
>
You are trying to add a tag in t_tag that is not present in t_game.
Postgresql is complaining about an absend foreign key because of that.

First add the tag to t_game before trying to use it in t_tag.

Regards
Johann

-- 





Re: [web2py] Re: web2py as Windows service

2012-11-14 Thread David Sorrentino
I just tried with ActivePython 2.7 and it works. I mean, at least the task
manager says that the service is running. :)
However I do not manage to make web2py work.
I am pretty sure that the problem is in my* option.py* file.
Now it looks like that:

import socket
> import os
>
> ip = socket.gethostname()
> port = 8000
> interfaces = [('0.0.0.0', 80)]
>
> #,('0.0.0.0',443,'ssl_private_key.pem','ssl_certificate.pem')]
> password = ''  # ##  means use the previous password
> pid_filename = 'httpserver.pid'
> log_filename = 'httpserver.log'
> profiler_filename = None
> ssl_certificate = None  # 'ssl_certificate.pem'  # ## path to certificate
> file
> ssl_private_key = None  # 'ssl_private_key.pem'  # ## path to private key
> file
> #numthreads = 50 # ## deprecated; remove
> minthreads = None
> maxthreads = None
> server_name = socket.gethostname()
> request_queue_size = 5
> timeout = 30
> shutdown_timeout = 5
> folder = os.getcwd()
> extcron = None
> nocron = None
>

It should work with the URL 127.0.0.1:8000, but it does not. And I do not
understand what *interfaces *is. :(
Any thoughts?

Best,
David


On 14 November 2012 10:25, Tim Richardson  wrote:

> Hi David,
> for me the service installation has worked every time I've used it ... but
> that's with the ActivePython 2.7 distribution on the windows boxes, and
> therefore with a source installation of web2py.
>
> My practical advice is go for this set up and see if that fixes the
> problem. You get a considerably different Python distribution this way.
>
> regards
>
> Tim
>
>
>
> On Wednesday, 14 November 2012 18:30:38 UTC+11, David Sorrentino wrote:
>
>> Hello Derek and Tim,
>>
>> First of all thanks for your reply. :)
>>
>> @Derek: I do not see any log in the logs folder, but logging is not
>> enabled. This morning I will enable it and tell you the results.
>>
>> @Tim: I am testing my app on Windows 7. I did not install any Python
>> distribution on Windows, since I have the need of using the .exe install.
>> However the application has been compiled and packed on Linux
>> (archlinux), with web2py version 2.2.1 and Python 2.7.3 .
>>
>> Can I help more?
>>
>> I wish you a wonderful day.
>> David
>>
>>
>> On 14 November 2012 03:27, Tim Richardson  wrote:
>>
>>> what kind of Windows is it? How did you install Python, and which
>>> distribution is it?
>>> Is your Web2py a source code install, or the .exe install?
>>>
>>>  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





[web2py] Re: Getting error near "interval_time": syntax error

2012-11-14 Thread Niphlod

Il giorno mercoledì 14 novembre 2012 09:51:43 UTC+1, Amit ha scritto:
>
> Hi,
> I am getting error 
> * near "interval_time": syntax error*
>

syntax error points to something around "interval_time".. my bet is on 
date_sub() not supported by sqlite 

http://www.sqlite.org/cvstrac/wiki/wiki?p=DateAndTimeFunctions
 

-- 





[web2py] postgres problem with crud.update

2012-11-14 Thread andrej burja
i've made app using wizzard
i addes tags
db.define_table('t_tag',
Field('f_game_id', type='reference t_game',
  label=T('Game Id')),
Field('f_name', type='string',
  label=T('Name')),
auth.signature,
format='%(f_game_id)s',
migrate=settings.migrate)

db.define_table('t_tag_archive',db.t_tag,Field('current_record','reference 
t_tag',readable=False,writable=False))

in controller i have crud.update
form = 
make_taggable_eq(crud.update(db.t_game,record,onaccept=update_tags_eq))

if i want to delete game, there is an error:
 insert or update on table "t_tag" 
violates foreign key constraint "t_tag_f_game_id_fkey" DETAIL: Key 
(f_game_id)=(699) is not present in table "t_game".

update is OK

is this related to postgres?
what am i doing wrong?

andrej

-- 





[web2py] Re: Placing the database of a web2py app on the cloud

2012-11-14 Thread Tim Richardson
I'm curious about why you wouldn't not just deploy the app on the EC2 
instance?

-- 





Re: [web2py] Re: web2py as Windows service

2012-11-14 Thread Tim Richardson
Hi David,
for me the service installation has worked every time I've used it ... but 
that's with the ActivePython 2.7 distribution on the windows boxes, and 
therefore with a source installation of web2py.

My practical advice is go for this set up and see if that fixes the 
problem. You get a considerably different Python distribution this way. 

regards

Tim


On Wednesday, 14 November 2012 18:30:38 UTC+11, David Sorrentino wrote:
>
> Hello Derek and Tim,
>
> First of all thanks for your reply. :)
>
> @Derek: I do not see any log in the logs folder, but logging is not 
> enabled. This morning I will enable it and tell you the results.
>
> @Tim: I am testing my app on Windows 7. I did not install any Python 
> distribution on Windows, since I have the need of using the .exe install.
> However the application has been compiled and packed on Linux (archlinux), 
> with web2py version 2.2.1 and Python 2.7.3 .
>
> Can I help more?
>
> I wish you a wonderful day.
> David
>
>
> On 14 November 2012 03:27, Tim Richardson 
> > wrote:
>
>> what kind of Windows is it? How did you install Python, and which 
>> distribution is it? 
>> Is your Web2py a source code install, or the .exe install?
>>
>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Getting error near "interval_time": syntax error

2012-11-14 Thread Amit
Hi,
I am getting error 
* near "interval_time": syntax error*


Please see the code and traceback below:

*In db.py:*

db.define_table(
'status',
Field('serial_no',requires=IS_NOT_EMPTY()),
Field('name',requires=IS_NOT_EMPTY()), 
   
Field('updated_on','datetime',default=request.now),
Field('interval_time','integer',default=0))
   
def save_status():
result = {}
result['serial_no'] = '123456'
result['name'] = 'MyDevice'
result['updated_on'] = request.now
result['interval_time'] = 1 
db.status.insert(**result)
db.commit()

*In default.py:*

from gluon.dal import Expression

def status():
tbl = db.status
max_created_on = tbl.updated_on.max()
query = Expression(db,"date_sub(now(),interval interval_time minute) > 
updated_on")

rows=db(query).select(tbl.serial_no,tbl.name,\
  tbl.interval_time,max_created_on,\
  groupby=tbl.serial_no|tbl.name)

# additional logic has to be added here when we get rows object 
successfully from db

grid = SQLFORM.grid(db.status)
return locals()
 
 
def save_device_status():
save_status()   



*TRACEBACK:*


Ticket ID 

127.0.0.1.2012-11-14.14-09-15.d938f195-3cd2-4ea2-9044-40a2e8d4226f
 near "interval_time": syntax error 
Version  web2py™ (2, 1, 1, datetime.datetime(2012, 10, 15, 12, 44, 40), 
'stable')  Python Python 2.7.2: C:\Python27\python.exe  Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.

Traceback (most recent call last):
  File "D:\web2py2.1.1\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
  File 
"D:/web2py2.1.1/web2py/applications/TestApplication/controllers/default.py" 
,
 line 91, in 
  File "D:\web2py2.1.1\web2py\gluon\globals.py", line 187, in 
self._caller = lambda f: f()
  File 
"D:/web2py2.1.1/web2py/applications/TestApplication/controllers/default.py" 
,
 line 84, in status
groupby=tbl.serial_no|tbl.name)
  File "D:\web2py2.1.1\web2py\gluon\dal.py", line 8787, in select
return adapter.select(self.query,fields,attributes)
  File "D:\web2py2.1.1\web2py\gluon\dal.py", line 2127, in select
return super(SQLiteAdapter, self).select(query, fields, attributes)
  File "D:\web2py2.1.1\web2py\gluon\dal.py", line 1615, in select
return self._select_aux(sql,fields,attributes)
  File "D:\web2py2.1.1\web2py\gluon\dal.py", line 1580, in _select_aux
self.execute(sql)
  File "D:\web2py2.1.1\web2py\gluon\dal.py", line 1693, in execute
return self.log_execute(*a, **b)
  File "D:\web2py2.1.1\web2py\gluon\dal.py", line 1687, in log_execute
ret = self.cursor.execute(*a, **b)
OperationalError: near "interval_time": syntax error

 Error snapshot [image: help]  

(near "interval_time": syntax error) 

inspect attributes 
 Frames 
   
   -  
   
   *File D:\web2py2.1.1\web2py\gluon\restricted.py in restricted at line 209
   * code arguments variables 
-  
   
   *File 
   D:\web2py2.1.1\web2py\applications\TestApplication\controllers\default.py 
   in  at line 91* code arguments variables 
-  
   
   *File D:\web2py2.1.1\web2py\gluon\globals.py in  at line 187* 
   code arguments variables 
-  
   
   *File 
   D:\web2py2.1.1\web2py\applications\TestApplication\controllers\default.py 
   in status at line 84* code arguments variables 
Code listing 
   
   79.
   80.
   81.
   82.
   83.
   84.
   
   85.
   86.
   87.
   88.
   
   max_created_on = tbl.updated_on.max()
   query = Expression(db,"date_sub(now(),interval interval_time minute) > 
updated_on")
   
   rows=db(query).select(tbl.serial_no,tbl.name,\
 tbl.interval_time,max_created_on,\
 groupby=tbl.serial_no|tbl.name)
   
   grid = SQLFORM.grid(db.status)
   return locals()
   
-  
   
   *File D:\web2py2.1.1\web2py\gluon\dal.py in select at line 8787* code 
   arguments variables 
-  
   
   *File D:\web2py2.1.1\web2py\gluon\dal.py in select at line 2127* code 
   arguments variables 
-  
   
   *File D:\web2py2.1.1\web2py\gluon\dal.py in select at line 1615* code 
   arguments variables 
-  
   
   *File D:\web2py2.1.1\web2py\gluon\dal.py in _select_aux at line 1580* 
   code arguments variables 
-  
   
   *File D:\web2py2.1.1\web2py\gluon\dal.py in execute at line 1693* code 
   arguments variables 
-  
   
   *File D:\web2py2.1.1\web2py\gluon\dal.py in log_execute at line 1687* 
   code arguments variables 
Function argument list 
   
   (self=, *a=('SELECT status.serial_no, 
   status.name, status.in...dated_on) GROUP BY status.serial_no, 
   status.name;',), **b={})
Code listing 
   
   1682.
   1683.
   168

[web2py] change database via class?

2012-11-14 Thread tom h
hi web2py gurus,

just out of curiousity, i'd like to create a class (let's say Product) that 
represents a record in my table "product".  right now, i can't figure out 
how to have the class attributes (p = Product(); p.price) saved to the 
database without internally having p.__fields_dict__ containing ONLY table 
fields, and then map the p.price to p.__fields_dict__['price'], and finally 
doing something like p.db['product'].insert(p.__fields_dict__).

i'm just wondering if there's any better way to do this, sorry i'm pretty 
new to Python as well and probably am missing something.

ideally, i'd like something that's more like:

p = Product(id=1) or Product()
p.random_var = 'abc'
p.name = 'a'
p.price = 100.0
p.save() # or db['product'].update_or_insert(p) 

thanks a lot!
tom

--