[web2py] MongoDB adapter

2015-05-01 Thread José Ricardo Borba
Hi 4 All,

I'm new to mongoDB and still having some problems with a TIME field. When I
set a TIME field in the table, fill the input field of a sqlform (only time
is allowed) and send the data to table, all the record is inserted without
any warning. But when I try to show in the sqlform, I receive a message:

pre
code
  Traceback (most recent call last):
  File /home/xxx.../applications/ras/controllers/appadmin.py, line 269,
in select
*fields, limitby=(start, stop))
  File /home/xxx.../gluon/packages/dal/pydal/objects.py, line 2026, in
select
return adapter.select(self.query,fields,attributes)
  File /home/xxx.../gluon/packages/dal/pydal/adapters/mongo.py, line 353,
in select
result = processor(rows, fields, newnames, False)
  File /home/xxx.../gluon/packages/dal/pydal/adapters/base.py, line 1596,
in parse
value = self.parse_value(value,ft,blob_decode)
  File /home/xxx.../gluon/packages/dal/pydal/adapters/base.py, line 1450,
in parse_value
return self.parsemap[key](value,field_type)
  File /home/xxx.../gluon/packages/dal/pydal/adapters/base.py, line 1472,
in parse_time
time_items = map(int,str(value)[:8].strip().split(':')[:3])
ValueError: invalid literal for int() with base 10: '2000-01-'
/code
/pre

Trying to understand what happened, I'm googled for some info, and found
the Mongo adapter code (yes, I didn't tried in my own computer).

Reading the code (in pydal/adapters/mongo.py), I see a (possible) clue: The
lines 148 to 163 is, in some way, weird for my reading. Maybe I
misunderstood some point, but this

pre
code
t = datetime.time(0,0,0)
/code
/pre

is a formatter for a field type DATE, and this

pre
code
t = datetime.date(2000,1,1)
/code
/pre

is a formatter for a field type TIME ?

Best regards, and keep going the invaluable work with this framework.

-- 
José Ricardo Borba

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Optimize js, css seems to compute minify over and over

2015-05-01 Thread Joe Barnhart
I haven't used response.optimize_js and css very much, but I just enabled 
them on my test site.  As I expected, it took a long time to load my page 
the first time (around 15 seconds) as web2py concatenated and minimized the 
files into the temp directory.  But strangely enough, the site only works 
quickly for a few minutes before taking 15 seconds again to re-minify the 
same static files.

I checked the temp directory and I can see the files being written whenever 
the load time takes 15 seconds.  The hashed name does not change, but the 
file is overwritten and the file date is changed.  This seems like an 
error.  Is there any other setting I need to make to tell web2py to not 
re-minimize and re-concat the files again and again?

I'm on web2py 2.10.4 released and running Python 2.7.6.  The files are 
served thru Apache2 on Debian, if it matters.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: socket.io to connect to tornado websocket

2015-05-01 Thread Derek
I believe you have to put the port in a variable...

var socket = new io.Socket('ws://localhost/realtime/mygroup1',{
 port: 12200
});


On Friday, May 1, 2015 at 9:16:01 AM UTC-7, Ramos wrote:

 I really missed a line 
 here it is

 socket.emit('subscribe', 'mygroup1');

 according to this meteor package documentation

 https://atmospherejs.com/joncursi/socket-io-client

 but it does not work!! dont know why...


 Iḿ trying to have a meteorjs app connecting to my web2py tornado websockets 
 app

 any ideas?


 2015-04-30 21:18 GMT+01:00 Derek sp1...@gmail.com javascript::

 those aren't the same url. don't you need /mygroup1 ?


 On Tuesday, April 28, 2015 at 3:34:05 AM UTC-7, Ramos wrote:

 hello i have an app with tornado websockets in the back
 my webpage has this code
 web2py_websocket('ws://serverip:12200/realtime/mygroup1')

 it just works !!

 now i need to connect to my tornado websocket from a nodejs server using 
 socket.io

 this line of code does not connect
 var socket = io('ws://serveip:12200/realtime/');


 any help would be appreciated

 António


  -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to web2py+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: socket.io to connect to tornado websocket

2015-05-01 Thread António Ramos
I really missed a line
here it is

socket.emit('subscribe', 'mygroup1');

according to this meteor package documentation

https://atmospherejs.com/joncursi/socket-io-client

but it does not work!! dont know why...


Iḿ trying to have a meteorjs app connecting to my web2py tornado websockets app

any ideas?


2015-04-30 21:18 GMT+01:00 Derek sp1d...@gmail.com:

 those aren't the same url. don't you need /mygroup1 ?


 On Tuesday, April 28, 2015 at 3:34:05 AM UTC-7, Ramos wrote:

 hello i have an app with tornado websockets in the back
 my webpage has this code
 web2py_websocket('ws://serverip:12200/realtime/mygroup1')

 it just works !!

 now i need to connect to my tornado websocket from a nodejs server using
 socket.io

 this line of code does not connect
 var socket = io('ws://serveip:12200/realtime/');


 any help would be appreciated

 António


  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] form misalignment with bootstrap3_inline

2015-05-01 Thread Bob St John
Using web2py version 2.10.4 with response.formstyle=bootstrap3_inline

Problem:
When using SQLFORM or SQLFORM.grid(view) the form fields whose value is 
None or when writable=False do not line up horizontally with the label.

Solution (or hack):
In gluon.sqlhtml.py I added the following elif (about line 918)

elif isinstance(controls, UL):
for e in controls.elements(input):
e.add_class('form-control')

# bob's fix
elif controls is None or isinstance(controls, basestring):
_controls = P(controls, _class=form-control-static %s % col_class)
# end bob's fix

if isinstance(label, LABEL):
label['_class'] = 'control-label %s' % label_col_class


This is probably more of a hack than a solution... somewhere else in 
SQLFORM when controls == None or controls == string it should be included 
inside a SPAN()...

But this works for me right now.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] delete session value that store query as_list()

2015-05-01 Thread 黄祥
hi,

i store rows query in the session, and want to remove it, is it need two 
step for that?
e.g.
def purchase_return_form():
form = SQLFORM(db.purchase_return_header)
if form.validate():
session.purchase_return_header = dict(form.vars)
rows = db(db.purchase_order_detail.purchase_order_no == 
session.purchase_return_header['purchase_order_no']).select()
*session.purchase_return_detail = rows.as_list() # store session as 
list()*
return dict(form = form)

def empty_return_0(session_return_header, session_return_detail, 
redirect_cart):
session_return_header.clear()
# step one delete all except i = 1
for i, row in enumerate(session_return_detail):
del session_return_detail[i]
# step two delete i = 1
for i in xrange(0, len(session_return_detail) ):
del session_return_detail[i]
redirect(URL(redirect_cart) )

the problem is if i just use one all value that store in session detail is 
not deleted all, always remain i=1, so that i must take two steps for that.
is it the correct way to handle it in web2py?

thanks and best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] websocket_send() on db insert

2015-05-01 Thread 'sasogeek' via web2py-users
is there a way to execute some script anytime there's a db insert (either 
from a form or by manual insert query, or any db query for that matter)? 
and by script, i'd want to use websocket_send to send some messages anytime 
something goes in or out of the db with regards to some specific tables.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: websocket_send() on db insert

2015-05-01 Thread 黄祥
perhaps you can check this discussion :
https://groups.google.com/forum/#!topic/web2py/sp4fpYz36HI

instead insert it into auth_event table, you can do mail.send()

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.