Re: [web2py] Logging http audit

2013-10-14 Thread Arnon Marcus
I don't see a bug here - things work, just no as ideal as it coulb be.
I ended up using monkey-patching so I don't even need the thread-local globals 
- I use them in a dependancy-injection kind of way.
So I am successfully bypassing the lack of support in 1.8.95.
The issues massimo is raising seems to apply to any version, and are 
architectual in nature - how does one reliably-accesses the user-name of the 
current session, regardless of how sessions are being stored and what 
authentication mechanism is used. I don't know. And it seems no one else has an 
answer either. Perhapse there isnt a good answer for that as of yet.

-- 
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/groups/opt_out.


Re: [web2py] Logging http audit

2013-10-14 Thread Arnon Marcus
The other issue is with the body of requests/responses - how does one reliably 
accesses the content of the body, regardless of wether it happens to be 
implemented as an io-stream or a file-wrapper in any given http-session 
(request->response pair) - and regardless of that being a regular http-request 
or an xhr (ajax) one.

-- 
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/groups/opt_out.


Re: [web2py] Logging http audit

2013-10-14 Thread Arnon Marcus
In both cases that can be implemented as a form of "rendering". The body can be 
tought of as being 'rendered-into', say, body.text (which would hold a simple 
string object) or something, that happens at the end of the current 
request-processing cycle. Similarly, user-name/info could be rendered by the 
auth mechanism into some buffer, and the session-mechanism would store that 
buffer in, say, session.user.

This way I could do 'request.body.text' and 'response.body.text' regardless of 
the underlying http-machinery, and 'session.user.first_name' and 
'session.user.last_name' regardless of the session-storing mechanism and 
authorisation-implementation.

-- 
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/groups/opt_out.


[web2py] Re: Issue with switching to mysql from sqlite in Pythonanywhere (table not created)

2013-10-14 Thread Ykä Marjanen
Thanks Niphlod,

I've been happily using SQLite for testing and smaller projects, so 
switching to MySQL was a new thing (I'd like to use PostgreSQL in the 
future). I was expecting it to work by just switching the initialization 
line, as it was working fine with SQLite. But I learned new stuff, again.

Ykä

On Sunday, October 13, 2013 9:42:50 PM UTC+3, Niphlod wrote:
>
> mysql has a very known problem of not handling unique keys longer than 255 
> chars. 
> As specified in the book and as a best practice, ALWAYS specify a length 
> for 'string' fields. In the case of mysql, if those fields are unique, the 
> maximum length is 255.
>
> On the other issue (creating the referencing table before the referenced 
> one): seems impossible to let users digest this fact (seems pretty obvious 
> to me), but you CAN'T (in ANY serious backend) specify a relationship 
> towards something that doesn't exist.
> SQLite has no referential integrity turned on by default, so it skips the 
> issue entirely. Remember, SQLite is a wonderful db but is tiny and has its 
> own limitations.
>
>
> On Sunday, October 13, 2013 6:36:16 PM UTC+2, Ykä Marjanen wrote:
>>
>> I got everything working, when I moved the table order so that all tables 
>> that are referenced later are at the beginning.
>>
>> Additionally I had to declare the "unique" value after creating the 
>> table, so:
>>
>> Not working:
>> db.define_table('tablename',Field('name',unique=True)
>>
>> Working:
>> db.define_table('tablename',Field('name')
>> db.tablename.name.unique = True
>>
>> Is this correct behavior?
>>
>> Ykä
>>
>> On Sunday, October 13, 2013 4:54:30 PM UTC+3, Niphlod wrote:
>>>
>>> there is no path2 field in the models you posted. are you sure that this 
>>> is the correct traceback ?
>>> BTW, try to issue the create statement to the db to see what is the 
>>> error, eventually trimming out the column that are references to external 
>>> tables.
>>>
>>> On Sunday, October 13, 2013 3:00:57 PM UTC+2, Ykä Marjanen wrote:

 And the resulting ticket:

 Error ticket for "innopinion_01" Ticket ID 

 91.155.41.52.2013-10-13.12-54-52.7a8f0165-58f8-4ca8-960a-7fdcdc40d788
  (1005, "Can't create table 
 'ykamarjanen$dbname.campaign' (errno: 150)") Version  web2py™ Version 
 2.6.4-stable+timestamp.2013.09.22.01.43.37  Traceback 

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

 Traceback (most recent call last):
   File "/home/ykamarjanen/web2py/gluon/restricted.py", line 217, in 
 restricted
 exec ccode in environment
   File "/home/ykamarjanen/web2py/applications/innopinion_01/models/db.py" 
 ,
  line 114, in 
 Field('path2','text', filter_in=(lambda x: pickle.dumps(x)), 
 filter_out=(lambda s: s and pickle.loads(s)),default=None, readable=False, 
 writable=False))
   File "/home/ykamarjanen/web2py/gluon/dal.py", line 7895, in define_table
 table = self.lazy_define_table(tablename,*fields,**args)
   File "/home/ykamarjanen/web2py/gluon/dal.py", line 7932, in 
 lazy_define_table
 polymodel=polymodel)
   File "/home/ykamarjanen/web2py/gluon/dal.py", line 1002, in create_table
 self.create_sequence_and_triggers(query,table)
   File "/home/ykamarjanen/web2py/gluon/dal.py", line 1816, in 
 create_sequence_and_triggers
 self.execute(query)
   File "/home/ykamarjanen/web2py/gluon/dal.py", line 1833, in execute
 return self.log_execute(*a, **b)
   File "/home/ykamarjanen/web2py/gluon/dal.py", line 1827, in log_execute
 ret = self.cursor.execute(command, *a[1:], **b)
   File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 
 201, in execute
 self.errorhandler(self, exc, value)
   File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", 
 line 36, in defaulterrorhandler
 raise errorclass, errorvalue
 OperationalError: (1005, "Can't create table 'ykamarjanen$dbname.campaign' 
 (errno: 150)")



 On Sunday, October 13, 2013 3:59:08 PM UTC+3, Ykä Marjanen wrote:
>
> Niphlod,
>
> this is the log. The test table, that I created, passes fine, but the 
> "campaign" table doesn't say "success". Is it about the FOREIGN KEY?
>
> < sql.log
> timestamp: 2013-10-13T12:23:25.789598
> CREATE TABLE tests(
> id INTEGER PRIMARY KEY AUTOINCREMENT,
> auth_table INTEGER REFERENCES auth_user (id) ON DELETE CASCADE,
> path2 TEXT
> );
> success!
> timestamp: 2013-10-13T12:29:03.020292
> CREATE TABLE campaign(
> id INT AUTO_INCREMENT NOT NULL,
> uuid VARCHAR(64),
> name VARCHAR(512),
> pagename VARCHAR(512),

Re: [web2py] Logging http audit

2013-10-14 Thread Arnon Marcus
I ended-up embedding my code into web2py instead of injecting it - it's 
simpler this way (for me) - it looks like this:

*In logging.conf:*

[loggers]
keys=root,rocket,markdown,web2py,rewrite,app,welcome,*logstash*

[handlers]
keys=consoleHandler,rotatingFileHandler,*logstash*

...

*[logger_logstash]
level=DEBUG
handlers=logstash
qualname=logstash
propagate=0
*
...

*[handler_logstash]
class=handlers.TimedRotatingFileHandler
level=DEBUG
args=("", "midnight")*


*In gluon.main.py:*

# set up logging for subsequent imports
import logging
import logging.config
logpath = abspath("logging.conf")
if os.path.exists(logpath):
logging.config.fileConfig(abspath("logging.conf"))
else:
logging.basicConfig()
logger = logging.getLogger("web2py")

import gluon.contrib.logstash as logstash
import logstash_formatter
logstash_logger = logging.getLogger('logstash')
logstash_logger.handlers[0].setFormatter(logstash_formatter.
LogstashFormatter())

from restricted import RestrictedError
from http import HTTP, redirect
from globals import Request, Response, Session
from compileapp import build_environment, run_models_in, \
run_controller_in, run_view_in
from fileutils import copystream
from contenttype import contenttype
from sql import BaseAdapter
from settings import global_settings
from validators import CRYPT
from cache import Cache
from html import URL as Url
from storage import List
import newcron
import rewrite

...

def serve_controller(request, response, session):
...

# also, make sure the flash is passed through
# ##
# process models, controller and view (if required)
# ##

run_models_in(environment)
response._view_environment = copy.copy(environment)
page = run_controller_in(request.controller, request.function,environment
)
if isinstance(page, dict):
response._vars = page
for key in page:
response._view_environment[key] = page[key]
run_view_in(response._view_environment)
page = response.body.getvalue()

logstash.log(request, response, session, logstash_logger)

raise HTTP(response.status, page, **response.headers)

*In gluon.contrib.logstash.py:*

import simplejson

def getBody(obj):
body = None
try:
body = obj.getvalue()
except:
try:
body = obj.read()
except:
pass

return body

def log(request, response, session, logger):
user = ''
sessionDict = dict(session)
if sessionDict.has_key('auth') and sessionDict['auth']:
authDict = dict(sessionDict['auth'])
if authDict.has_key('user') and authDict['user']:
userDict = dict(authDict['user'])
if userDict.has_key('first_name') and userDict.has_key(
'last_name'):
user = userDict['first_name'] + ' ' + userDict['last_name']

message = {
'@user': user,
'@controller': request.controller,
'@function': request.function,
'@args': request.args,
'@vars': dict(request.vars),
'@requestBody': getBody(request.body),
'@responseBody': getBody(response.body)
}

logMessage = simplejson.dumps(message)
logger.debug(logMessage)



Any suggestions?

-- 
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/groups/opt_out.


[web2py] Re: Update sqlform.grid query from external click

2013-10-14 Thread Gael Princivalle
Hi Niphlod.

Now I use request.vars instead of request.args and it works, I don't have 
anymore the flash "Not authorized" message.
Here is the hp.load file:
{{=grid}}
{{=A('Test',callback=URL('hp.load', vars=dict(cat='a')))}}

When I load only the hp.load file it works, but when I load it inside the 
html file no, hp.load file reload without a query update (I have all rows).

Do you know why ?

.html file:
{{=grid}}
{{=A('Test',callback=URL('hp.load', vars=dict(cat='a')))}}

Controller hp.py:
def hp():
db.models.pdf_path.readable = False
if request.vars['cat']:
cat_to_show=str(request.vars['cat'])
query = db.models.category==str(cat_to_show)
response.flash = 'Category to show is ' + cat_to_show
else:
query = db.models
response.flash = 'Request.vars[cat] is empty, show all rows'
fields = 
(db.models.code,db.models.category,db.models.description_it,db.models.pdf_path)
headers = {'models.code':   T('Product model'),
   'models.category': T('Category'),
   'models.description_it': T('Description'),
   'models.pdf_path': 'pdf_path' }
links = [dict(header=T('Catalogue'), body=lambda row: A('Download', 
_href=row.pdf_path, _target='_blank'))]
maxtextlengths={'models.code': 6, 'models.description_it': 120}
grid = SQLFORM.grid(query, headers=headers, fields=fields, csv=False, 
maxtextlengths=maxtextlengths, orderby=db.models.code, 
links=links,links_in_grid=True)
return dict(grid=grid)

Il giorno domenica 13 ottobre 2013 20:33:22 UTC+2, Niphlod ha scritto:
>
> grid uses signed links by default (otherwise, you could access all data 
> just changing the url). Make sure that all links fiddling with grid "own" 
> links (such as lining directyl to the edit action of some record) are 
> signed. 
> Also, grid uses request.args to detect what you're trying to do, so if you 
> want to use something like /app/default/index/whatever as a "base url", you 
> should pass also args=request.args[:1] to tell the grid that it should only 
> consider what comes after the "whatever".
>
>
> On Sunday, October 13, 2013 8:24:15 PM UTC+2, Gael Princivalle wrote:
>>
>> Tim, Niphlod thank you for your answers. @Niphlod "Luke" means that's I'm 
>> a skywalker ? I would like to ! 
>> Components are pretty useful, I've tried the documentation tutorial, 
>> that's ok.
>> I'm still having some problems on this topic.
>> 1/My left side bar is under the grid
>> 2/I don't reach to give some args to the grid. As args I've just got to 
>> give a category number. I've made a test link with "1". If I load only the 
>> .load file clicking on the link it show al rows. With the .load file inside 
>> the .html file, it returns me this message "not authorized".
>>
>> Here is my hp.load file in a dedicated component folder called hp:
>> {{left_sidebar_enabled=True,}}
>> {{=grid}}
>>  
>> {{=A('Test',callback=URL('hp.load', args='1'))}}
>> {{block left_sidebar}}
>> 
>>
>> My dedicated controller hp.py:
>> def hp():
>> #I don't want to show this field. I'm gone take care of it under with 
>> the lambda function
>> db.models.pdf_path.readable = False 
>> if request.args(0): #If there's an arg, it means that I have to make 
>> a query with this category number
>> query = db.models.category==request.args(0)
>> else: #Else, I have to show all rows
>> query = db.models
>> fields = 
>> (db.models.code,db.models.category,db.models.description_it,db.models.pdf_path)
>> #I set my headers
>> headers = {'models.code':   T('Product model'),
>>'models.category': T('Category'),
>>'models.description_it': T('Description'),
>>'models.pdf_path': 'pdf_path' }
>> #Here I take care about pdf_path for having a link on it.
>> links = [dict(header=T('Catalogue'), body=lambda row: A('Download', 
>> _href=row.pdf_path, _target='_blank'))]
>> maxtextlengths={'models.code': 6, 'models.description_it': 120}
>> #Here is my construction grid
>> grid = SQLFORM.grid(query, headers=headers, fields=fields, csv=False, 
>> maxtextlengths=maxtextlengths, orderby=db.models.code, 
>> links=links,links_in_grid=True)
>> return dict(grid=grid)
>>
>> My h_products.html view:
>> {{extend 'layout.html'}}
>> {{=LOAD('hp','hp.load',ajax=True)}}
>>
>> How can I resolve these problems ?
>>
>> Il giorno giovedì 10 ottobre 2013 20:45:45 UTC+2, Tim Richardson ha 
>> scritto:
>>>
>>> A web2py component will make the grid controlled by ajax, which means 
>>> you can reload it from your page with javascript when some event happens, 
>>> and that reloading is done the ajax way, without reloading the entire page. 
>>> And there's more. Read about components in the book.
>>
>>

-- 
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 

Re: [web2py] T() lack at welcome application?

2013-10-14 Thread mcamel
Wow!, finally the four problems reported have four different 
reasons/behaviour!!!

1.- Share: yet explained

2.- user/impersonate: i wasn't able to solve it

3.- user/groups: the string "Group uniquely assigned to user %(id)s" seems 
to be "harcoded" when you create the application. I wasn't able to change 
this behavior anymore, but if you create a new app, it takes the actual 
state of the language file. Really strange.

4.- user/not_authorized: the problem is at tools.py; where it says "return 
('ACCESS DENIED')" (line 3199), it should say "return 
(self.messages.access_denied)". You have to reset web2py after change it. 
After that, every change at the entry 'Insufficient privileges' of the 
language file, is immediately taken.


In my opinion this would need, at least, a patch to tools.py and a 
clarification in the manual.


Best regards.


El domingo, 13 de octubre de 2013 21:23:47 UTC+2, mcamel escribió:
>
> Hello,
>
> I've explained badly. The problem is in the core of the project (Auth) not 
> in the welcome application, except share.js that has different 
> consideration because is in static folder.
>
> share.js has written the word 'Share' in it, but if you change it (e.g. 
> for 'Comparte'), then the "composition" of its elements breaks, so it would 
> needed at least hard CSS work.
>
> The actions exposed by Auth are not in the applications, but in 'gluon' 
> folder. E.g. i've found "group_description='Group uniquely assigned to user 
> %(id)s'," at tools.py, but it still appears in english if you force spanish 
> and write this at languages/es.py:
>
> 'Group uniquely assigned to user %(id)s': 'Grupo asignado únicamene al 
> usuario %(id)s',
>
> I'm quite sure this is a bug, but i've made a similar mistake recently and 
> would feel more confortable if other could verify this before opening a 
> ticket.
>
> Thank you.
>
>
> El viernes, 11 de octubre de 2013 19:07:14 UTC+2, Richard escribió:
>>
>> Just change your welcome and make the test!! It is easy you have done the 
>> hard work so far...
>>
>> Don't forget to update language files after change the app and then add 
>> your translation to the file and update the files.
>>
>> If you feel confident you fix that, you can pull request here : 
>> https://github.com/web2py/web2py/tree/master/applications/welcome
>>
>> :)
>>
>> Richard
>>
>>
>> On Fri, Oct 11, 2013 at 1:00 PM, mcamel  wrote:
>>
>>> Hello,
>>>
>>> There are a couple of things not being translated at the Welcome 
>>> application, even after added to the language file. I think the reason is 
>>> lack of T() at the code.
>>>
>>> Observed at:
>>> - Share: div at bottom-right to social networks
>>> - User Id: at user/impersonate
>>> - Group uniquely assigned to user %(id)s: at user/groups
>>> - ACCESS DENIED: at user/not_authorized
>>>
>>> Could anyone confirm this is the reason?.
>>>
>>> Thanks.
>>>
>>> -- 
>>> 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.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>

-- 
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/groups/opt_out.


Re: [web2py] T() lack at welcome application?

2013-10-14 Thread mcamel
Hello,

Just want to puntualize that problem 3, happens when you register a new 
user with Auth, not when you create a new application.

Best regards.


El lunes, 14 de octubre de 2013 12:09:28 UTC+2, mcamel escribió:
>
> Wow!, finally the four problems reported have four different 
> reasons/behaviour!!!
>
> 1.- Share: yet explained
>
> 2.- user/impersonate: i wasn't able to solve it
>
> 3.- user/groups: the string "Group uniquely assigned to user %(id)s" seems 
> to be "harcoded" when you create the application. I wasn't able to change 
> this behavior anymore, but if you create a new app, it takes the actual 
> state of the language file. Really strange.
>
> 4.- user/not_authorized: the problem is at tools.py; where it says "return 
> ('ACCESS DENIED')" (line 3199), it should say "return 
> (self.messages.access_denied)". You have to reset web2py after change it. 
> After that, every change at the entry 'Insufficient privileges' of the 
> language file, is immediately taken.
>
>
> In my opinion this would need, at least, a patch to tools.py and a 
> clarification in the manual.
>
>
> Best regards.
>
>
> El domingo, 13 de octubre de 2013 21:23:47 UTC+2, mcamel escribió:
>>
>> Hello,
>>
>> I've explained badly. The problem is in the core of the project (Auth) 
>> not in the welcome application, except share.js that has different 
>> consideration because is in static folder.
>>
>> share.js has written the word 'Share' in it, but if you change it (e.g. 
>> for 'Comparte'), then the "composition" of its elements breaks, so it would 
>> needed at least hard CSS work.
>>
>> The actions exposed by Auth are not in the applications, but in 'gluon' 
>> folder. E.g. i've found "group_description='Group uniquely assigned to user 
>> %(id)s'," at tools.py, but it still appears in english if you force spanish 
>> and write this at languages/es.py:
>>
>> 'Group uniquely assigned to user %(id)s': 'Grupo asignado únicamene 
>> al usuario %(id)s',
>>
>> I'm quite sure this is a bug, but i've made a similar mistake recently 
>> and would feel more confortable if other could verify this before opening a 
>> ticket.
>>
>> Thank you.
>>
>>
>> El viernes, 11 de octubre de 2013 19:07:14 UTC+2, Richard escribió:
>>>
>>> Just change your welcome and make the test!! It is easy you have done 
>>> the hard work so far...
>>>
>>> Don't forget to update language files after change the app and then add 
>>> your translation to the file and update the files.
>>>
>>> If you feel confident you fix that, you can pull request here : 
>>> https://github.com/web2py/web2py/tree/master/applications/welcome
>>>
>>> :)
>>>
>>> Richard
>>>
>>>
>>> On Fri, Oct 11, 2013 at 1:00 PM, mcamel  wrote:
>>>
 Hello,

 There are a couple of things not being translated at the Welcome 
 application, even after added to the language file. I think the reason is 
 lack of T() at the code.

 Observed at:
 - Share: div at bottom-right to social networks
 - User Id: at user/impersonate
 - Group uniquely assigned to user %(id)s: at user/groups
 - ACCESS DENIED: at user/not_authorized

 Could anyone confirm this is the reason?.

 Thanks.

 -- 
 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.
 For more options, visit https://groups.google.com/groups/opt_out.

>>>
>>>

-- 
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/groups/opt_out.


Re: [web2py] Re: Load with ajax doesn't work since upgrade > 1.6

2013-10-14 Thread Niphlod
of course it doesn't. but it won't work even with pre-2.6.0 releases 
. you aren't including the template which holds the js to load the 
component! :D 

Il giorno lunedì 14 ottobre 2013 08:13:36 UTC+2, Michael Helbling ha 
scritto:
>
>
> Dear Niphlod
>
> Attached is a minimal App. In w2p 2.7.2 i just created a new simple 
> application and inserted the test code, I posted last time. The load of 
> "test3" doesn't work and in the div is just "loading..."
>
> I tried it on 2 different pcs (at home and work) in firefox and chrome, so 
> the client shouldn't be the problem. Can you reproduce the problem with the 
> attached app? the whole code is original, except the 3 test functions in 
> the default controller and the view default/test.html
>
>
>
> Am Freitag, 11. Oktober 2013 22:15:22 UTC+2 schrieb José L.:
>>
>>
>> El 11/10/2013 21:52, "Niphlod"  escribió:
>> >
>> > talking about minimal app, heh anyway, better than nothing.
>>
>> I know, but I am answering from my phone, without a PC available ;)
>>
>> > taken movuca, setupped, doesn't work (as advertised in web2py's 
>> changelog).
>> > Take web2py.js from welcome and overwrite web2py.js in 
>> /static/bootstrap/js/web2py.js
>> > Next issue, movuca ships jquery 1.7.1 (november 2011). 
>> > web2py.js requires something jquery having $.parseHTML ... update 
>> jquery too and you'll only receive a problem about bootstrap-transition.js, 
>> that is trying to do something with the (now unsupported) $.browser.
>> > Update bootstrap-transition.js and movuca works like a charm.
>> >
>>
>> I will check it again, maybe I made some mistake copying those files, but 
>> I knew this has to be done.
>>
>> Thanks
>>
>> > tl;dr : movuca just needs a few upgrades to work.
>> >
>> >
>> > On Friday, October 11, 2013 9:19:01 PM UTC+2, José L. wrote:
>> >>
>> >> Movuca app from Bruno, available at Github has this behaviour.
>> >>
>> >> El 11/10/2013 21:05, "Niphlod"  escribió:
>> >>>
>> >>> can you pack a minimal app to reproduce the behaviour please ? I 
>> can't reproduce the issue you're seeing
>> >>>
>> >>> On Friday, October 11, 2013 8:55:19 AM UTC+2, Michael Helbling wrote:
>> 
>> 
>>  yes, jquery.js and web2py.js are configured in web2py_ajax.html and 
>> jquery.js is preceding web2py.js:
>>  {{
>>  response.files.insert(0,URL('static','js/jquery.js'))
>>  response.files.insert(1,URL('static','css/calendar.css'))
>>  response.files.insert(2,URL('static','js/calendar.js'))
>>  response.files.insert(3,URL('static','js/web2py.js'))
>>  response.files.insert(4,URL('static','js/jquery.blockUI.js'))
>>  response.include_meta()
>>  response.include_files()
>>  }}
>> 
>> 
>>  The workaround from José works. After replacing the compileapp.py 
>> through the old one, every load is working again. I'll take a closer look 
>> at the file in the afternoon. 
>> 
>> 
>>  Am Donnerstag, 10. Oktober 2013 21:15:40 UTC+2 schrieb Niphlod:
>> >
>> > is jquery.js preceding web2py.js in your layout.html ?
>> >
>> > On Thursday, October 10, 2013 8:27:04 AM UTC+2, Michael Helbling 
>> wrote:
>> >>
>> >>
>> >> Yes, i already copied the web2py.js, appadmin controller and views 
>> from the latest welcome app to all my apps. 
>> >> Without copying the web2py.js, no load worked. But even with the 
>> latest web2py.js, not all loads are working. that's my problem and i don't 
>> know why some load doesn't work. In version 2.5.1 with the old web2py.js 
>> all loads worked and in version 2.7.1 with the new web2py.js ~30% of the 
>> loads in our app don't work anymore. 
>> >>
>> >> as described, i don't know what to try anymore. May you can give 
>> me a hint what i could try additionally? 
>> >>
>> >>
>> >> Am Mittwoch, 9. Oktober 2013 18:53:02 UTC+2 schrieb Massimo Di 
>> Pierro:
>> >>>
>> >>> You need to copy web2py.js from the latest welcome app into your 
>> old app.
>> >>>
>> >>  
>> >> On Wednesday, 9 October 2013 04:57:20 UTC-5, Michael Helbling 
>> wrote:
>> >>>
>> >>> First of all to avoid this question: Yes I copied the appadmin 
>> and javascript file from the welcome app to my own app ;-) 
>> >>>
>> >>
>> >>  
>> >>>
>> >>> -- 
>> >>> 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.
>> >>>
>> >>> For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> > -- 
>> > Resources:
>> > - http://web2py.com
>> > - http://web2py.com/book (Documentation)
>> > - http://github.com/web2py/web2py (Source code)
>> > 

[web2py] Re: Update sqlform.grid query from external click

2013-10-14 Thread Niphlod
I think you don't have a clear "bigger picture" of all the pieces involved.
In order to update a component, you need to have it loaded somewhere you 
know inside the page.
This mean that there will be a certain div with id "iwillreload" inside 
your page that will point to the page that generates the grid.
In order to replace that component with a click on a link "outside" that 
"iwillreload" component, you NEED to tell to the link where you want that 
link to be loaded.

so, first of all, in your "main" page, you need to include a 

LOAD(c='default', f='thegrid.load', ajax=True, target='iwillreload')

This will create a div with id iwillreload inside your page, with 
default/thegrid.load called via ajax to fill this page "fragment".

To replace that component clicking on a link, with that link being the 
source of the wanted "new fragment", you need to do

A('click this', callback=URL('default', 'thegrid.load', 
vars=dict(something=else), user_signature=True), target="iwillreload")

i.e. you need to tell to A where would you want that url loaded.

Il giorno lunedì 14 ottobre 2013 12:02:28 UTC+2, Gael Princivalle ha 
scritto:
>
> Hi Niphlod.
>
> Now I use request.vars instead of request.args and it works, I don't have 
> anymore the flash "Not authorized" message.
> Here is the hp.load file:
> {{=grid}}
> {{=A('Test',callback=URL('hp.load', vars=dict(cat='a')))}}
>
> When I load only the hp.load file it works, but when I load it inside the 
> html file no, hp.load file reload without a query update (I have all rows).
>
> Do you know why ?
>
> .html file:
> {{=grid}}
> {{=A('Test',callback=URL('hp.load', vars=dict(cat='a')))}}
>
> Controller hp.py:
> def hp():
> db.models.pdf_path.readable = False
> if request.vars['cat']:
> cat_to_show=str(request.vars['cat'])
> query = db.models.category==str(cat_to_show)
> response.flash = 'Category to show is ' + cat_to_show
> else:
> query = db.models
> response.flash = 'Request.vars[cat] is empty, show all rows'
> fields = 
> (db.models.code,db.models.category,db.models.description_it,db.models.pdf_path)
> headers = {'models.code':   T('Product model'),
>'models.category': T('Category'),
>'models.description_it': T('Description'),
>'models.pdf_path': 'pdf_path' }
> links = [dict(header=T('Catalogue'), body=lambda row: A('Download', 
> _href=row.pdf_path, _target='_blank'))]
> maxtextlengths={'models.code': 6, 'models.description_it': 120}
> grid = SQLFORM.grid(query, headers=headers, fields=fields, csv=False, 
> maxtextlengths=maxtextlengths, orderby=db.models.code, 
> links=links,links_in_grid=True)
> return dict(grid=grid)
>
> Il giorno domenica 13 ottobre 2013 20:33:22 UTC+2, Niphlod ha scritto:
>>
>> grid uses signed links by default (otherwise, you could access all data 
>> just changing the url). Make sure that all links fiddling with grid "own" 
>> links (such as lining directyl to the edit action of some record) are 
>> signed. 
>> Also, grid uses request.args to detect what you're trying to do, so if 
>> you want to use something like /app/default/index/whatever as a "base url", 
>> you should pass also args=request.args[:1] to tell the grid that it should 
>> only consider what comes after the "whatever".
>>
>>
>> On Sunday, October 13, 2013 8:24:15 PM UTC+2, Gael Princivalle wrote:
>>>
>>> Tim, Niphlod thank you for your answers. @Niphlod "Luke" means that's 
>>> I'm a skywalker ? I would like to ! 
>>> Components are pretty useful, I've tried the documentation tutorial, 
>>> that's ok.
>>> I'm still having some problems on this topic.
>>> 1/My left side bar is under the grid
>>> 2/I don't reach to give some args to the grid. As args I've just got to 
>>> give a category number. I've made a test link with "1". If I load only the 
>>> .load file clicking on the link it show al rows. With the .load file inside 
>>> the .html file, it returns me this message "not authorized".
>>>
>>> Here is my hp.load file in a dedicated component folder called hp:
>>> {{left_sidebar_enabled=True,}}
>>> {{=grid}}
>>>  
>>> {{=A('Test',callback=URL('hp.load', args='1'))}}
>>> {{block left_sidebar}}
>>> 
>>>
>>> My dedicated controller hp.py:
>>> def hp():
>>> #I don't want to show this field. I'm gone take care of it under 
>>> with the lambda function
>>> db.models.pdf_path.readable = False 
>>> if request.args(0): #If there's an arg, it means that I have to make 
>>> a query with this category number
>>> query = db.models.category==request.args(0)
>>> else: #Else, I have to show all rows
>>> query = db.models
>>> fields = 
>>> (db.models.code,db.models.category,db.models.description_it,db.models.pdf_path)
>>> #I set my headers
>>> headers = {'models.code':   T('Product model'),
>>>'models.category': T('Category'),
>>>'models.description_it': T('Description'),
>>>'models.

[web2py] Re: thread._local' object has no ANY attribute

2013-10-14 Thread Matheus Cardoso
I was wondering about that, Massimo. The odd is that sometime before, I was 
running the same code in the same way. And I assumed that the HTTP request 
lives while selenium calls a controller with the Web2py running. I will try 
the command that you stated and to see the discussion that you said. 

Thanks a lot, Massimo. 

On Thursday, October 10, 2013 11:25:39 AM UTC-3, Matheus Cardoso wrote:
>
> Hi guys,
>
> Sorry if the following question was already answered,  but I could not 
> find nothing like this in this list, stack or in others lists. Here is the 
> thing: I wrote some tests that already was working. I got back to the code, 
> after some time, and then: 'thread._local' object has no attribute (in this 
> case, the classic 'db'). Here is my code:
>
> In models/0.py
>
> db = 
> DAL(db_postgres_url,pool_size=1,check_reserved=['all'],fake_migrate_all=False)
>
> from gluon import current
> current.db = db
>
> In module/my_module.py
>
> from gluon import *
> def some_function():
>   #some db stuff calling current.db
>
> However, the 'thread._local' object has no attribute db keeps raising. I 
> tried other approach like 
>   
> In models/0.py
>
> db = 
> DAL(db_postgres_url,pool_size=1,check_reserved=['all'],fake_migrate_all=False)
>
> from gluon import current
> from storage import Storage
> current.toc = Storage()
> current.toc.db = db
>
> But then, the same error, but with "toc", raises again. Is there any 
> changes in Web2py that changed this behavior? 
>
>
>
>
>

-- 
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/groups/opt_out.


[web2py] Re: Update sqlform.grid query from external click

2013-10-14 Thread Gael Princivalle
Thanks a lot now I've got it, have a nice day.

Il giorno lunedì 14 ottobre 2013 14:07:32 UTC+2, Niphlod ha scritto:
>
> I think you don't have a clear "bigger picture" of all the pieces involved.
> In order to update a component, you need to have it loaded somewhere you 
> know inside the page.
> This mean that there will be a certain div with id "iwillreload" inside 
> your page that will point to the page that generates the grid.
> In order to replace that component with a click on a link "outside" that 
> "iwillreload" component, you NEED to tell to the link where you want that 
> link to be loaded.
>
> so, first of all, in your "main" page, you need to include a 
>
> LOAD(c='default', f='thegrid.load', ajax=True, target='iwillreload')
>
> This will create a div with id iwillreload inside your page, with 
> default/thegrid.load called via ajax to fill this page "fragment".
>
> To replace that component clicking on a link, with that link being the 
> source of the wanted "new fragment", you need to do
>
> A('click this', callback=URL('default', 'thegrid.load', 
> vars=dict(something=else), user_signature=True), target="iwillreload")
>
> i.e. you need to tell to A where would you want that url loaded.
>
> Il giorno lunedì 14 ottobre 2013 12:02:28 UTC+2, Gael Princivalle ha 
> scritto:
>>
>> Hi Niphlod.
>>
>> Now I use request.vars instead of request.args and it works, I don't have 
>> anymore the flash "Not authorized" message.
>> Here is the hp.load file:
>> {{=grid}}
>> {{=A('Test',callback=URL('hp.load', vars=dict(cat='a')))}}
>>
>> When I load only the hp.load file it works, but when I load it inside the 
>> html file no, hp.load file reload without a query update (I have all rows).
>>
>> Do you know why ?
>>
>> .html file:
>> {{=grid}}
>> {{=A('Test',callback=URL('hp.load', vars=dict(cat='a')))}}
>>
>> Controller hp.py:
>> def hp():
>> db.models.pdf_path.readable = False
>> if request.vars['cat']:
>> cat_to_show=str(request.vars['cat'])
>> query = db.models.category==str(cat_to_show)
>> response.flash = 'Category to show is ' + cat_to_show
>> else:
>> query = db.models
>> response.flash = 'Request.vars[cat] is empty, show all rows'
>> fields = 
>> (db.models.code,db.models.category,db.models.description_it,db.models.pdf_path)
>> headers = {'models.code':   T('Product model'),
>>'models.category': T('Category'),
>>'models.description_it': T('Description'),
>>'models.pdf_path': 'pdf_path' }
>> links = [dict(header=T('Catalogue'), body=lambda row: A('Download', 
>> _href=row.pdf_path, _target='_blank'))]
>> maxtextlengths={'models.code': 6, 'models.description_it': 120}
>> grid = SQLFORM.grid(query, headers=headers, fields=fields, csv=False, 
>> maxtextlengths=maxtextlengths, orderby=db.models.code, 
>> links=links,links_in_grid=True)
>> return dict(grid=grid)
>>
>> Il giorno domenica 13 ottobre 2013 20:33:22 UTC+2, Niphlod ha scritto:
>>>
>>> grid uses signed links by default (otherwise, you could access all data 
>>> just changing the url). Make sure that all links fiddling with grid "own" 
>>> links (such as lining directyl to the edit action of some record) are 
>>> signed. 
>>> Also, grid uses request.args to detect what you're trying to do, so if 
>>> you want to use something like /app/default/index/whatever as a "base url", 
>>> you should pass also args=request.args[:1] to tell the grid that it should 
>>> only consider what comes after the "whatever".
>>>
>>>
>>> On Sunday, October 13, 2013 8:24:15 PM UTC+2, Gael Princivalle wrote:

 Tim, Niphlod thank you for your answers. @Niphlod "Luke" means that's 
 I'm a skywalker ? I would like to ! 
 Components are pretty useful, I've tried the documentation tutorial, 
 that's ok.
 I'm still having some problems on this topic.
 1/My left side bar is under the grid
 2/I don't reach to give some args to the grid. As args I've just got to 
 give a category number. I've made a test link with "1". If I load only the 
 .load file clicking on the link it show al rows. With the .load file 
 inside 
 the .html file, it returns me this message "not authorized".

 Here is my hp.load file in a dedicated component folder called hp:
 {{left_sidebar_enabled=True,}}
 {{=grid}}
  
 {{=A('Test',callback=URL('hp.load', args='1'))}}
 {{block left_sidebar}}
 

 My dedicated controller hp.py:
 def hp():
 #I don't want to show this field. I'm gone take care of it under 
 with the lambda function
 db.models.pdf_path.readable = False 
 if request.args(0): #If there's an arg, it means that I have to 
 make a query with this category number
 query = db.models.category==request.args(0)
 else: #Else, I have to show all rows
 query = db.models
 fields = 
 (db.models.code,db.models.category,

Re: [web2py] Re: Load with ajax doesn't work since upgrade > 1.6

2013-10-14 Thread Niphlod
You aren't using any view if you return raw HTML tags (as in return 
DIV('...'))

Il giorno lunedì 14 ottobre 2013 14:38:02 UTC+2, Michael Helbling ha 
scritto:
>
>
>
> hmm, in the view test.html is the layout included, in the layout the 
> web2py_ajax.html and there are the js included.? :S
> do you mean the web2py_ajax.html? 
>
> i tried to copy the app to w2p 2.5.1 too, but it seems there were some 
> changes, that needs more changes to migrate an app to a lower version :/ 
> sorry, i didn't test this direction before..
>
>
> if i create a new simple app in w2p 2.5.1, insert the code for the test 
> functions and views. It works. I attached the app from 2.5.1 
> (web2py.app.test251)
>
> then i packed the app and installed it in w2p 2.7.2. After this, i copied 
> the web2py.js, jquery.js and appadmin controller/view as in the changelog 
> described. But the load still doesn't work. I attached this app too 
> (web2py.app.test272.w2p) 
> are there more files that needs an update? *i'm not sure which template 
> you mean
>
>
>
>
> Am Montag, 14. Oktober 2013 13:55:05 UTC+2 schrieb Niphlod:
>>
>> of course it doesn't. but it won't work even with pre-2.6.0 releases 
>> . you aren't including the template which holds the js to load the 
>> component! :D 
>>
>> Il giorno lunedì 14 ottobre 2013 08:13:36 UTC+2, Michael Helbling ha 
>> scritto:
>>>
>>>
>>> Dear Niphlod
>>>
>>> Attached is a minimal App. In w2p 2.7.2 i just created a new simple 
>>> application and inserted the test code, I posted last time. The load of 
>>> "test3" doesn't work and in the div is just "loading..."
>>>
>>> I tried it on 2 different pcs (at home and work) in firefox and chrome, 
>>> so the client shouldn't be the problem. Can you reproduce the problem with 
>>> the attached app? the whole code is original, except the 3 test functions 
>>> in the default controller and the view default/test.html
>>>
>>>
>>>
>>> Am Freitag, 11. Oktober 2013 22:15:22 UTC+2 schrieb José L.:


 El 11/10/2013 21:52, "Niphlod"  escribió:
 >
 > talking about minimal app, heh anyway, better than nothing.

 I know, but I am answering from my phone, without a PC available ;)

 > taken movuca, setupped, doesn't work (as advertised in web2py's 
 changelog).
 > Take web2py.js from welcome and overwrite web2py.js in 
 /static/bootstrap/js/web2py.js
 > Next issue, movuca ships jquery 1.7.1 (november 2011). 
 > web2py.js requires something jquery having $.parseHTML ... update 
 jquery too and you'll only receive a problem about 
 bootstrap-transition.js, 
 that is trying to do something with the (now unsupported) $.browser.
 > Update bootstrap-transition.js and movuca works like a charm.
 >

 I will check it again, maybe I made some mistake copying those files, 
 but I knew this has to be done.

 Thanks

 > tl;dr : movuca just needs a few upgrades to work.
 >
 >
 > On Friday, October 11, 2013 9:19:01 PM UTC+2, José L. wrote:
 >>
 >> Movuca app from Bruno, available at Github has this behaviour.
 >>
 >> El 11/10/2013 21:05, "Niphlod"  escribió:
 >>>
 >>> can you pack a minimal app to reproduce the behaviour please ? I 
 can't reproduce the issue you're seeing
 >>>
 >>> On Friday, October 11, 2013 8:55:19 AM UTC+2, Michael Helbling 
 wrote:
 
 
  yes, jquery.js and web2py.js are configured in web2py_ajax.html 
 and jquery.js is preceding web2py.js:
  {{
  response.files.insert(0,URL('static','js/jquery.js'))
  response.files.insert(1,URL('static','css/calendar.css'))
  response.files.insert(2,URL('static','js/calendar.js'))
  response.files.insert(3,URL('static','js/web2py.js'))
  response.files.insert(4,URL('static','js/jquery.blockUI.js'))
  response.include_meta()
  response.include_files()
  }}
 
 
  The workaround from José works. After replacing the compileapp.py 
 through the old one, every load is working again. I'll take a closer look 
 at the file in the afternoon. 
 
 
  Am Donnerstag, 10. Oktober 2013 21:15:40 UTC+2 schrieb Niphlod:
 >
 > is jquery.js preceding web2py.js in your layout.html ?
 >
 > On Thursday, October 10, 2013 8:27:04 AM UTC+2, Michael Helbling 
 wrote:
 >>
 >>
 >> Yes, i already copied the web2py.js, appadmin controller and 
 views from the latest welcome app to all my apps. 
 >> Without copying the web2py.js, no load worked. But even with the 
 latest web2py.js, not all loads are working. that's my problem and i don't 
 know why some load doesn't work. In version 2.5.1 with the old web2py.js 
 all loads worked and in version 2.7.1 with the new web2py.js ~30% of the 
 loads in our app don't work anymore. 
 >>
 >> as de

[web2py] Embed PDF

2013-10-14 Thread Ari Lion BR Sp
Hi to all, 

I do generate PDFs at my my application, and do store it at a folder at my 
aapication, and I want to embed it as a preview at my View page.
I was using  tag in order to do so:

http://www.mysite.com/local_where_i_saved_my_pdf/pdf_name.pdf
" width="100%" height="375">

But I need it to be flexible, and I do not succeed to map *src *to point to 
the absolute URL (I guess also due to routing etc). 

I have also tried the below without success.

os.path.join(request.http_host, request.folder,'local_where_i_saved_my_pdf', 
'pdf_name 
.pdf')


What should be the correct, and which alternatives do I have?

Thanks and regards!

-- 
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/groups/opt_out.


Re: [web2py] Re: Load with ajax doesn't work since upgrade > 1.6

2013-10-14 Thread Michael Helbling

Yes, but there was no need to load the js two times on the same page < 2.6. 
Even if there was an ajax call between the initially page load and the 
LOAD. 
if you import the web2py.app.test251.w2p into w2p 2.5.1, you will see, this 
behavior worked before the upgrade. And there are a lot of these Loads in 7 
different applications. 

Do you mean something like this?
def test2():
ret = DIV(XML("test2 "))
ret.append(XML(""))
ret.append(XML(""))
ret.append(LOAD(f='test3', ajax=True))
return ret

*This works :/ but this will cause a lot of work to find and expand every 
ajax call which has a LOAD in it. 

If you have an idea, how to solve this properly in an other way, please let 
me know. 
Else, thanks a lot for your support and patience! It's good to know the 
reason, even if I can not solve it immediately :D



Am Montag, 14. Oktober 2013 14:54:36 UTC+2 schrieb Niphlod:
>
> You aren't using any view if you return raw HTML tags (as in return 
> DIV('...'))
>
> Il giorno lunedì 14 ottobre 2013 14:38:02 UTC+2, Michael Helbling ha 
> scritto:
>>
>>
>>
>> hmm, in the view test.html is the layout included, in the layout the 
>> web2py_ajax.html and there are the js included.? :S
>> do you mean the web2py_ajax.html? 
>>
>> i tried to copy the app to w2p 2.5.1 too, but it seems there were some 
>> changes, that needs more changes to migrate an app to a lower version :/ 
>> sorry, i didn't test this direction before..
>>
>>
>> if i create a new simple app in w2p 2.5.1, insert the code for the test 
>> functions and views. It works. I attached the app from 2.5.1 
>> (web2py.app.test251)
>>
>> then i packed the app and installed it in w2p 2.7.2. After this, i copied 
>> the web2py.js, jquery.js and appadmin controller/view as in the changelog 
>> described. But the load still doesn't work. I attached this app too 
>> (web2py.app.test272.w2p) 
>> are there more files that needs an update? *i'm not sure which template 
>> you mean
>>
>>
>>
>>
>> Am Montag, 14. Oktober 2013 13:55:05 UTC+2 schrieb Niphlod:
>>>
>>> of course it doesn't. but it won't work even with pre-2.6.0 releases 
>>> . you aren't including the template which holds the js to load the 
>>> component! :D 
>>>
>>> Il giorno lunedì 14 ottobre 2013 08:13:36 UTC+2, Michael Helbling ha 
>>> scritto:


 Dear Niphlod

 Attached is a minimal App. In w2p 2.7.2 i just created a new simple 
 application and inserted the test code, I posted last time. The load of 
 "test3" doesn't work and in the div is just "loading..."

 I tried it on 2 different pcs (at home and work) in firefox and chrome, 
 so the client shouldn't be the problem. Can you reproduce the problem with 
 the attached app? the whole code is original, except the 3 test functions 
 in the default controller and the view default/test.html



 Am Freitag, 11. Oktober 2013 22:15:22 UTC+2 schrieb José L.:
>
>
> El 11/10/2013 21:52, "Niphlod"  escribió:
> >
> > talking about minimal app, heh anyway, better than nothing.
>
> I know, but I am answering from my phone, without a PC available ;)
>
> > taken movuca, setupped, doesn't work (as advertised in web2py's 
> changelog).
> > Take web2py.js from welcome and overwrite web2py.js in 
> /static/bootstrap/js/web2py.js
> > Next issue, movuca ships jquery 1.7.1 (november 2011). 
> > web2py.js requires something jquery having $.parseHTML ... update 
> jquery too and you'll only receive a problem about 
> bootstrap-transition.js, 
> that is trying to do something with the (now unsupported) $.browser.
> > Update bootstrap-transition.js and movuca works like a charm.
> >
>
> I will check it again, maybe I made some mistake copying those files, 
> but I knew this has to be done.
>
> Thanks
>
> > tl;dr : movuca just needs a few upgrades to work.
> >
> >
> > On Friday, October 11, 2013 9:19:01 PM UTC+2, José L. wrote:
> >>
> >> Movuca app from Bruno, available at Github has this behaviour.
> >>
> >> El 11/10/2013 21:05, "Niphlod"  escribió:
> >>>
> >>> can you pack a minimal app to reproduce the behaviour please ? I 
> can't reproduce the issue you're seeing
> >>>
> >>> On Friday, October 11, 2013 8:55:19 AM UTC+2, Michael Helbling 
> wrote:
> 
> 
>  yes, jquery.js and web2py.js are configured in web2py_ajax.html 
> and jquery.js is preceding web2py.js:
>  {{
>  response.files.insert(0,URL('static','js/jquery.js'))
>  response.files.insert(1,URL('static','css/calendar.css'))
>  response.files.insert(2,URL('static','js/calendar.js'))
>  response.files.insert(3,URL('static','js/web2py.js'))
>  response.files.insert(4,URL('static','js/jquery.blockUI.js'))
>  response.include_meta()
>  response.include_files()
>  }}
> 

[web2py] Re: web2py!!!

2013-10-14 Thread Willoughby
You might also look at LighSwitch - it's pretty slick if you're forced to 
use a Microsoft product.  Includes mobile to boot.
Anything is better than PHP...

http://msdn.microsoft.com/en-us/vstudio/gg604823

http://blogs.msdn.com/b/bethmassi/archive/2011/12/01/beginning-lightswitch-getting-started.aspx

-- 
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/groups/opt_out.


Re: [web2py] Re: Load with ajax doesn't work since upgrade > 1.6

2013-10-14 Thread Niphlod
wait a sec. before (< 2.6.0) the js to "trigger" the load was inlined, but 
web2py.js HAD to be available nonetheless to make that happen. What's 
changed is that now web2py.js takes also care of the "trigger".

def test2()
ret = DIV(XML("test2 "))
ret.append(LOAD(f='test3', ajax=True))
return ret

def test3():
return DIV('test 3')


Opening test2 as it is and hoping that it loads test3 doesn't work in  > 
2.6.0 AND doesn't work in < 2.6.0 , because neither test2 nor test3 load 
web2py.js.

Il giorno lunedì 14 ottobre 2013 15:43:21 UTC+2, Michael Helbling ha 
scritto:
>
>
> Yes, but there was no need to load the js two times on the same page < 
> 2.6. Even if there was an ajax call between the initially page load and the 
> LOAD. 
> if you import the web2py.app.test251.w2p into w2p 2.5.1, you will see, 
> this behavior worked before the upgrade. And there are a lot of these Loads 
> in 7 different applications. 
>
> Do you mean something like this?
> def test2():
> ret = DIV(XML("test2 "))
> ret.append(XML(" type='text/javascript'>"))
> ret.append(XML(" type='text/javascript'>"))
> ret.append(LOAD(f='test3', ajax=True))
> return ret
>
> *This works :/ but this will cause a lot of work to find and expand every 
> ajax call which has a LOAD in it. 
>
> If you have an idea, how to solve this properly in an other way, please 
> let me know. 
> Else, thanks a lot for your support and patience! It's good to know the 
> reason, even if I can not solve it immediately :D
>
>
>
> Am Montag, 14. Oktober 2013 14:54:36 UTC+2 schrieb Niphlod:
>>
>> You aren't using any view if you return raw HTML tags (as in return 
>> DIV('...'))
>>
>> Il giorno lunedì 14 ottobre 2013 14:38:02 UTC+2, Michael Helbling ha 
>> scritto:
>>>
>>>
>>>
>>> hmm, in the view test.html is the layout included, in the layout the 
>>> web2py_ajax.html and there are the js included.? :S
>>> do you mean the web2py_ajax.html? 
>>>
>>> i tried to copy the app to w2p 2.5.1 too, but it seems there were some 
>>> changes, that needs more changes to migrate an app to a lower version :/ 
>>> sorry, i didn't test this direction before..
>>>
>>>
>>> if i create a new simple app in w2p 2.5.1, insert the code for the test 
>>> functions and views. It works. I attached the app from 2.5.1 
>>> (web2py.app.test251)
>>>
>>> then i packed the app and installed it in w2p 2.7.2. After this, i 
>>> copied the web2py.js, jquery.js and appadmin controller/view as in the 
>>> changelog described. But the load still doesn't work. I attached this app 
>>> too (web2py.app.test272.w2p) 
>>> are there more files that needs an update? *i'm not sure which template 
>>> you mean
>>>
>>>
>>>
>>>
>>> Am Montag, 14. Oktober 2013 13:55:05 UTC+2 schrieb Niphlod:

 of course it doesn't. but it won't work even with pre-2.6.0 
 releases . you aren't including the template which holds the js to 
 load 
 the component! :D 

 Il giorno lunedì 14 ottobre 2013 08:13:36 UTC+2, Michael Helbling ha 
 scritto:
>
>
> Dear Niphlod
>
> Attached is a minimal App. In w2p 2.7.2 i just created a new simple 
> application and inserted the test code, I posted last time. The load of 
> "test3" doesn't work and in the div is just "loading..."
>
> I tried it on 2 different pcs (at home and work) in firefox and 
> chrome, so the client shouldn't be the problem. Can you reproduce the 
> problem with the attached app? the whole code is original, except the 3 
> test functions in the default controller and the view default/test.html
>
>
>
> Am Freitag, 11. Oktober 2013 22:15:22 UTC+2 schrieb José L.:
>>
>>
>> El 11/10/2013 21:52, "Niphlod"  escribió:
>> >
>> > talking about minimal app, heh anyway, better than nothing.
>>
>> I know, but I am answering from my phone, without a PC available ;)
>>
>> > taken movuca, setupped, doesn't work (as advertised in web2py's 
>> changelog).
>> > Take web2py.js from welcome and overwrite web2py.js in 
>> /static/bootstrap/js/web2py.js
>> > Next issue, movuca ships jquery 1.7.1 (november 2011). 
>> > web2py.js requires something jquery having $.parseHTML ... update 
>> jquery too and you'll only receive a problem about 
>> bootstrap-transition.js, 
>> that is trying to do something with the (now unsupported) $.browser.
>> > Update bootstrap-transition.js and movuca works like a charm.
>> >
>>
>> I will check it again, maybe I made some mistake copying those files, 
>> but I knew this has to be done.
>>
>> Thanks
>>
>> > tl;dr : movuca just needs a few upgrades to work.
>> >
>> >
>> > On Friday, October 11, 2013 9:19:01 PM UTC+2, José L. wrote:
>> >>
>> >> Movuca app from Bruno, available at Github has this behaviour.
>> >>
>> >> El 11/10/2013 21:05, "Niphlod"  escribió:
>> >>>
>> >>> can you pack a 

[web2py] web2py 2.7.4 is OUT

2013-10-14 Thread Massimo Di Pierro
there is no new changelog. It is mostly bug fixes.

-- 
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/groups/opt_out.


[web2py] Re: Error on main site -- powered by -- returns a ticket...

2013-10-14 Thread Massimo Di Pierro
fixed.

On Monday, 14 October 2013 01:11:05 UTC-5, jjs0sbw wrote:
>
> Internal errorTicket issued: 
> poweredby/208.38.200.112.2013-10-14.06-09-31.0e47e788-d8f0-45ad-9030-43d394841bdd
>
> -- 
> Joe Simpson
>
> Sent From My DROID!! 
>

-- 
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/groups/opt_out.


[web2py] Re: web2py 2.7.4 is OUT

2013-10-14 Thread Massimo Di Pierro
Mind that you may have to re-compile bytecode applications to work with 
2.7.4. Is this an issue? we could make it backward compatible but is 
anybody here distribution bytecode compile apps without distributing web2py 
with it?

On Monday, 14 October 2013 10:35:17 UTC-5, Massimo Di Pierro wrote:
>
> there is no new changelog. It is mostly bug fixes.
>

-- 
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/groups/opt_out.


[web2py] Re: web2py 2.7.4 is OUT

2013-10-14 Thread 黄祥
wonthefull no compiled error again.
tested on windows 7 and pythonanywhere.

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/groups/opt_out.


[web2py] Download file from string not triggering

2013-10-14 Thread Kariloy Markief
Hello,

I'm writing an app that at some point has a text string dynamically 
generated in a view via javascript.
What I would like to do is download that text as a file.
For that purpose my attempted approach has been...:

- on the same js function that generates the string I call:

ajax('download_test?content='+content, [], '');


and on the controller I have:


def download_test():

content = request.vars.content

response.headers['Content-Type'] = 'text/csv'
attachment = 'attachment;filename=data.csv'
response.headers['Content-Disposition'] = attachment

raise HTTP(200,str(content),
   **{'Content-Type':'text/csv',
  'Content-Disposition':attachment + ';'})


I've tried several variations around this approach, and the only thing that 
I can confirm is that the desired content is effectively passed from the 
the view to the controller (and back to the view if I define a container as 
the 3rd parameter of the ajax() function, but that's not what I want).

So the problem here seems to be be triggering the download. 

I've tried this on firefox (running my app), and also on chromium (via 
minimal app just to reproduce this issue). 

I'm running web2py version 2.4.7

Also the most similar reported issue I've found in this list was:
https://groups.google.com/forum/#!topic/web2py/GH2HVCGPMKo

Because no answer was found then and I was unsure about this group's policy 
of reviving old threads, I published mine as a new question. Hope this is 
ok.









-- 
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/groups/opt_out.


[web2py] Re: web2py!!!

2013-10-14 Thread Derek
I've tried those tutorials, as I was very interested in using Lightswitch. 
I could never figure out how to get that 'lightswitch' template to install 
into the new project wizard. This may be a time to step up to corporate IT 
and ask for approval. Show them the philosophy behind everything.

On Monday, October 14, 2013 7:28:13 AM UTC-7, Willoughby wrote:
>
> You might also look at LighSwitch - it's pretty slick if you're forced to 
> use a Microsoft product.  Includes mobile to boot.
> Anything is better than PHP...
>
> http://msdn.microsoft.com/en-us/vstudio/gg604823
>
>
> http://blogs.msdn.com/b/bethmassi/archive/2011/12/01/beginning-lightswitch-getting-started.aspx
>
>

-- 
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/groups/opt_out.


[web2py] Re: onselect ajax...

2013-10-14 Thread Derek
Yea, working with folders is pretty much nonexistant in web2py. you just 
have to 'rename' something to move it to a different folder. kinda weird 
but it works.

On Saturday, October 12, 2013 2:28:23 AM UTC-7, Avi A wrote:
>
> Shame to say but  Bingo!
> It nicely works now :).
> Thank you very much.
>
>
> On Saturday, October 12, 2013 3:36:59 AM UTC+3, Derek wrote:
>>
>> perhaps you didn't save the echo.html in the proper folder?
>>
>> On Friday, October 11, 2013 5:34:56 PM UTC-7, Derek wrote:
>>>
>>> Pretty strange. My example as shown in the web2pyslices site works just 
>>> fine.
>>>
>>> On Friday, October 11, 2013 1:30:46 PM UTC-7, Avi A wrote:

 No, I don't have it and I changed it to get echo.load and that solve 
 that issue, but it still renders the table instead of rendering the dict 
 in 
 the for loop, which should render the dropdown.
 This is a video of what it does:
 http://goo.gl/DWHqrp
 Thanks.
 On Friday, October 11, 2013 1:11:34 AM UTC+3, Derek wrote:
>
> You probably have a line in the echo.html file {{extend 
> 'layout.html'}}. Remove that.
>
> On Thursday, October 10, 2013 11:22:58 AM UTC-7, Avi A wrote:
>>
>>
>> def echo():
>> value = request.post_vars.f_item_category
>> filtered_sub = db(db.t_sub_categories.f_category_id == 
>> value).select(db.t_sub_categories.ALL,orderby=db.t_sub_categories.f_sub_category_name,
>>  
>> cache=(cache.ram,10),cacheable=True)
>> return  dict(filtered_sub = filtered_sub)
>>
>>
>> echo.html
>>
>> > name='f_item_subcategory'>
>>  
>>  {{for f in filtered_sub:}}
>>  test
>>  {{pass}}
>> 
>>
>>
>> It injects into the target div a whole page (layout.html) and inside, 
>> it renders "ECHO" then  the filtered_sub results as a table, + 
>> design, reqwest, response, session, db tables and db stats buttons under 
>> it.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Thursday, October 10, 2013 9:03:10 PM UTC+3, Avi A wrote:
>>>
>>> Exactly Starting now...
>>>
>>> On Thursday, October 10, 2013 8:02:40 PM UTC+3, Derek wrote:

 Any luck?

 On Tuesday, October 8, 2013 6:29:03 AM UTC-7, Avi A wrote:
>
> Still stuck with that...
> Thanks.
>
> On Saturday, October 5, 2013 5:29:37 PM UTC+3, Avi A wrote:
>>
>> def echo():
>> value = request.post_vars.f_item_category
>> filtered_sub = db(db.t_sub_categories.f_category_id == 
>> value).select(db.t_sub_categories.ALL,orderby=db.t_sub_categories.f_sub_category_name,
>>  
>> cache=(cache.ram,10),cacheable=True)
>> filtered_sub = dict(filtered_sub = filtered_sub)
>> select_header = "> class='generic-widget' name='f_item_subcategory'> \
>>  "
>> select_footer = ''
>> def select_body():
>> for f in filtered_sub:
>> #return "" + 
>> f.f_item_subcategory + ""
>> return 'test'
>> return select_footer + select_body() + select_footer
>>
>> This will render 'test' just once(where expected more).
>> I think the problem is that the filtered_sub = dict() from some 
>> reason.
>> If I replace the return 'test' with:
>> return "" + f.f_item_subcategory + 
>> ""
>> It flashes an error.
>> Thanks. 
>>
>>
>>
>>
>>
>>
>> On Saturday, October 5, 2013 10:32:43 AM UTC+3, Avi A wrote:
>>>
>>> Thanks. Yes, I will look carefully, but it looks like the html 
>>> is in the controller.
>>>
>>> On Saturday, October 5, 2013 2:31:10 AM UTC+3, Derek wrote:

 This question gets asked frequently here, there should be a FAQ 
 somewhere and this should be in it...

 Is this what you want?

 http://www.web2pyslices.com/slice/show/1467/cascading-drop-down-lists-with-ajax

 On Friday, October 4, 2013 2:04:41 PM UTC-7, Avi A wrote:
>
> I was exactly pasting it actually :).
>
> def echo():
> value = request.post_vars.f_item_category
> filtered_sub=db(db.t_sub_categories.f_category_id == 
> value).select(db.t_sub_categories.ALL,orderby=db.t_sub_categories.f_sub_category_name,
>  
> cache=(cache.ram,10),cacheable=True)
>
>return dict(filtered_sub=filtered_sub)
>
>
>
>   class="generic-widget" name="f_item_subcategory">
> 
> {{for 

Re: [web2py] Re: Google Chrome and the editor

2013-10-14 Thread Dave S
On Sunday, October 13, 2013 4:49:14 AM UTC-7, mweissen wrote:
>
> ok - that works!
>
>
> 2013/10/13 LightOfMooN >
>
>> Try to Ctrl+F5
>>
>>
:-)
 
 

-- 
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/groups/opt_out.


Re: [web2py] Logging http audit

2013-10-14 Thread Ricardo Pedroso
On Mon, Oct 14, 2013 at 10:01 AM, Arnon Marcus  wrote:

> I ended-up embedding my code into web2py instead of injecting it - it's
> simpler this way (for me) - it looks like this:
>
> *In gluon.contrib.logstash.py:*
>
>
> def log(request, response, session, logger):
>
> user = ''
> sessionDict = dict(session)
> if sessionDict.has_key('auth') and sessionDict['auth']:
> authDict = dict(sessionDict['auth'])
> if authDict.has_key('user') and authDict['user']:
> userDict = dict(authDict['user'])
> if userDict.has_key('first_name') and userDict.has_key(
> 'last_name'):
> user = userDict['first_name'] + ' ' + userDict['last_name'
> ]
>
>
I would write the above with something (not tested) like:

def log(request, response, session, logger):
user = ''
if session and session.auth and session.auth.user:
   auth_user = session.auth.user
   first_name = auth_user.firstname or ''
   last_name = auth_user.lastname or ''
   user = firstname + ' ' + lastname

or

def log(request, response, session, logger):
try:
auth_user = session.auth.user
first_name = auth_user.firstname or ''
last_name = auth_user.lastname or ''
user = first_name + ' ' + last_name
except AttributeError:
user = ''

-- 
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/groups/opt_out.


[web2py] Re: GAE: Running test. issue with exec_environment()

2013-10-14 Thread Quint
Guys,

What are the steps i need to take to be able to run tests while using GAE?

Do you want me to to create an issue?



On Sunday, October 13, 2013 3:14:46 PM UTC+2, Quint wrote:
>
> That indeed had something to do with it.
> After i changed it to this:
>
> db = DAL('google:datastore')
> session.connect(request, response, db=db)
>
> I got this error:
>
> Traceback (most recent call last):
>   File "X:\GAE\***\tests\test_fragments.py", line 25, in setUp
> exec_environment('applications/init/models/db.py')
>   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\shell.py",
>  line 93, in exec_environment
> execfile(pyfile, env)
>   File "applications/init/models/db.py", line 30, in 
> session.connect(request, response, db=db)
>   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\globals.py
> ", line 730, in connect
> response.session_id_name = 'session_id_%s' % masterapp.lower()
> AttributeError: 'NoneType' object has no attribute 'lower'
>
> After i removed this line
>
> session.connect(request, response, db=db)
>
> I get this:
>
> Traceback (most recent call last):
>   File "X:\GAE\***\tests\test_fragments.py", line 25, in setUp
> exec_environment('applications/init/models/db.py')
>   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\shell.py",
>  line 93, in exec_environment
> execfile(pyfile, env)
>   File "applications/init/models/db.py", line 34, in 
> auth = Auth(db)  # authentication/authorization
>   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\tools.py",
>  line 1144, in __init__
> request = current.request
> AttributeError: 'thread._local' object has no attribute 'request'
>
> There is no request object?
>
>
> On Sunday, October 13, 2013 2:51:35 PM UTC+2, Niphlod wrote:
>>
>> I think that that's a problem on how by default web2py recognize a GAE 
>> environment. If I'm right, you didn't change at all the db.py lines that do 
>> something like this
>>
>> if not request.env.web2py_runtime_gae:
>> ## if NOT running on Google App Engine use SQLite or other DB
>> db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
>> else:
>> ## connect to Google BigTable (optional 'google:datastore://namespace')
>> db = DAL('google:datastore')
>>
>>
>> I think that you run your tests where request.env.web2py_runtime_gae is 
>> False. To confirm this, strip that part and just use
>>
>> db = DAL('google:datastore')
>>
>> On Sunday, October 13, 2013 2:35:14 PM UTC+2, Quint wrote:
>>>
>>> Hi,
>>>
>>> I am trying to create a test for one of my modules.
>>> This module depends on several global variables like "Resonse" and some 
>>> extra things i store in current from one of my Models. (current.myapp.*** ).
>>> So to be able to run the test i need to execute some of the models like 
>>> this. (Is this the correct way?)
>>> (The testbed stuff is for GAE to create stubs for GAE services)
>>>
>>> def setUp (self):
>>> self.testbed = testbed.Testbed()
>>> self.testbed.activate()
>>> self.testbed.init_datastore_v3_stub()
>>> self.testbed.init_memcache_stub()
>>> exec_environment('applications/init/models/0.py')
>>> exec_environment('applications/init/models/db.py')
>>>
>>> I am using GAE with web2py 2.6.4 source and Python 2.7.3
>>>
>>> Now when i run the test i get this error:
>>>
>>> No handlers could be found for logger "web2py"
>>> DEBUG: connect attempt 0, connection error:
>>> Traceback (most recent call last):
>>>   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\dal.py", l
>>> ine 7854, in __init__
>>> self._adapter = ADAPTERS[self._dbname](**kwargs)
>>>   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\dal.py", l
>>> ine 2288, in __init__
>>> if do_connect: self.find_driver(adapter_args)
>>>   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\dal.py", l
>>> ine 791, in find_driver
>>> raise RuntimeError("no driver available %s" % str(self.drivers))
>>> RuntimeError: no driver available ('sqlite2', 'sqlite3')
>>>
>>> So it looks like DAL is instantiated and by default it tries to connect 
>>> to sqlite?
>>>
>>> What can i do about this?
>>>
>>> BTW when i try to start the web2py shell i get a similar error only now 
>>> i says that it find a "google" driver:
>>>
>>> No handlers could be found for logger "web2py"
>>> web2py Web Framework
>>> Created by Massimo Di Pierro, Copyright 2007-2013
>>> Version 2.6.4-stable+timestamp.2013.09.22.01.43.37
>>> Database drivers available: google
>>> DEBUG: connect attempt 0, connection error:
>>> Traceback (most recent call last):
>>>   File "X:\GAE\***\gluon\dal.py", line 7854, in __init__
>>> self._adapter = ADAPTERS[self._dbname](**kwargs)
>>>   File "X:\GAE\***\gluon\dal.py", line 2288, in __init__
>>> if do_connect: self.find_driver(adapter_args)
>>>   File "X:\GAE\***\gluon\dal.py", line 791, in find_driver
>>> raise RuntimeError("no dri

[web2py] Re: How to use shell with GAE dev server

2013-10-14 Thread Quint
I created an issue:

https://code.google.com/p/web2py/issues/detail?id=1722


On Sunday, October 13, 2013 6:36:36 PM UTC+2, Quint wrote:
>
> I have an update regarding this question.
>
> After i changed these lines, i'm getting a step further:
>
> if not request.env.web2py_runtime_gae:
> ## if NOT running on Google App Engine use SQLite or other DB
> db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
> else:
> ## connect to Google BigTable (optional 'google:datastore://namespace')
> db = DAL('google:datastore')
>
>
> to:
>
> db = DAL('google:datastore')
>
> I got this error:
>
> Traceback (most recent call last):
>   File "X:\GAE\***\gluon\restricted.py", line 217, in restricted
> exec ccode in environment
>   File "applications\init\models\menu.py", line 32, in 
> categories = db(db.category).select(orderby=db.category.name, 
> cache=(cache.r
> am, 60))
>   File "X:\GAE\***\gluon\dal.py", line 10403, in select
> return adapter.select(self.query,fields,attributes)
>   File "X:\GAE\***\gluon\dal.py", line 4995, in select
> for t in fields] for item in items]
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\ext\db\_
> _init__.py", line 2094, in __iter__
> return self.run()
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\ext\db\_
> _init__.py", line 2075, in run
> raw_query = self._get_query()
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\ext\db\_
> _init__.py", line 2480, in _get_query
> _app=self._app)
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\data
> store.py", line 1343, in __init__
> self.__app = datastore_types.ResolveAppId(_app)
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\data
> store_types.py", line 225, in ResolveAppId
> ValidateString(app, 'app', datastore_errors.BadArgumentError)
>   File "C:\Program Files 
> (x86)\Google\google_appengine\google\appengine\api\data
> store_types.py", line 173, in ValidateString
> raise exception('%s must not be empty.' % name)*BadArgumentError: app 
> must not be empty.*
>
> This error occurs because GAE needs the APPLICATION_ID os environ to be set.
>
> I had some db operations in my menu.py model and when i removed that code i 
> could successfully start the web2py shell.
>
> But i cannot do any db queries from the shell because of the missing 
> APPLICATION_ID environ.
>
> How can i make this work?
>
>
> Thanks!
>
>
>
>
> On Sunday, June 16, 2013 10:33:40 AM UTC+2, Massimo Di Pierro wrote:
>>
>> Please open a ticket. This is supposed to work, with quirks, but it 
>> should work.
>>
>> On Wednesday, 12 June 2013 12:20:16 UTC-5, Quint wrote:
>>>
>>> Hello,
>>>
>>> I'm trying to use the interactive shell with the GAE dev server on 
>>> Windows.
>>> Wahet do i need to do to getthis working?
>>>
>>> I'm now getting this error 5 times:
>>>
>>> web2py Web Framework
>>> Created by Massimo Di Pierro, Copyright 2007-2013
>>> Version 2.4.7-stable+timestamp.2013.05.24.17.48.47
>>> Database drivers available: SQLite(sqlite3), PostgreSQL(pg8000), 
>>> MSSQL(pyodbc),
>>> DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), CouchDB(couchdb), 
>>> IMAP(imaplib)
>>> DEBUG: connect attempt 0, connection error:
>>> Traceback (most recent call last):
>>>   File "C:\Users\*\gluon\dal.py", line
>>> 7429, in __init__
>>> self._adapter = ADAPTERS[self._dbname](**kwargs)
>>>   File "*\gluon\dal.py", line
>>> 2220, in __init__
>>> if do_connect: self.reconnect()
>>>   File "C:\Users\*\gluon\dal.py", line
>>> 603, in reconnect
>>> self.connection = f()
>>>   File "C:\Users\*\gluon\dal.py", line
>>> 2218, in connector
>>> return self.driver.Connection(dbpath, **driver_args)
>>> OperationalError: unable to open database file
>>>
>>>
>>> I'v tried adding this folder to my PATH with the GAE modules.
>>>
>>> PATH=%PATH%;C:\Program Files 
>>> (x86)\Google\google_appengine\google\appengine\ext
>>>
>>> Thanks!
>>>
>>>

-- 
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/groups/opt_out.


[web2py] Re: web2py binary contest

2013-10-14 Thread Niphlod
bump (@moderators, this is just to keep it in the first posts in this week)

>
>

-- 
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/groups/opt_out.


[web2py] Re: Download file from string not triggering

2013-10-14 Thread Niphlod
you can't get a "save as" dialog if the contents of the file are retrieved 
via ajax (browsers don't work like that). Open a new window pointing to the 
download url (it will soon close as there's no content to show, and the 
"save as" dialog will pop up).

PS: you'd really want to use another system than the simple concatenation 
to build the url... if "content" in your case contains csv data, you will 
never be able to reach that url (because it won't be a valid url). 
As last resort, at least urlencode the content. But you'll then face the 
limitation of url size, and that's why usually those kind of things are 
made with intermediate temp files or (slightly more complicated in a new 
window) POST requests :P 

On Monday, October 14, 2013 6:15:51 PM UTC+2, Kariloy Markief wrote:
>
> Hello,
>
> I'm writing an app that at some point has a text string dynamically 
> generated in a view via javascript.
> What I would like to do is download that text as a file.
> For that purpose my attempted approach has been...:
>
> - on the same js function that generates the string I call:
>
> ajax('download_test?content='+content, [], '');
>
>
> and on the controller I have:
>
>
> def download_test():
> 
> content = request.vars.content
> 
> response.headers['Content-Type'] = 'text/csv'
> attachment = 'attachment;filename=data.csv'
> response.headers['Content-Disposition'] = attachment
> 
> raise HTTP(200,str(content),
>**{'Content-Type':'text/csv',
>   'Content-Disposition':attachment + ';'})
>
>
> I've tried several variations around this approach, and the only thing 
> that I can confirm is that the desired content is effectively passed from 
> the the view to the controller (and back to the view if I define a 
> container as the 3rd parameter of the ajax() function, but that's not what 
> I want).
>
> So the problem here seems to be be triggering the download. 
>
> I've tried this on firefox (running my app), and also on chromium (via 
> minimal app just to reproduce this issue). 
>
> I'm running web2py version 2.4.7
>
> Also the most similar reported issue I've found in this list was:
> https://groups.google.com/forum/#!topic/web2py/GH2HVCGPMKo
>
> Because no answer was found then and I was unsure about this group's 
> policy of reviving old threads, I published mine as a new question. Hope 
> this is ok.
>
>
>
>
>
>
>
>
>
>

-- 
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/groups/opt_out.


[web2py] web2py - one step deployment - now what? :)

2013-10-14 Thread lesssugar
Hi,

I'm planning to bring my app "to life". So far, I have followed 
one-step-production deployment guides and used this script:

http://web2py.googlecode.com/hg/scripts/setup-web2py-nginx-uwsgi-centos64.sh

All the setup has been completed on my server, now I would like to upload 
my application and test it online. Could anyone tell me how do I continue? 
Couldn't find much about that in the book.

-- 
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/groups/opt_out.


[web2py] Re: web2py - one step deployment - now what? :)

2013-10-14 Thread Anthony
One option is to upload it through the admin interface.

On Monday, October 14, 2013 3:53:43 PM UTC-4, lesssugar wrote:
>
> Hi,
>
> I'm planning to bring my app "to life". So far, I have followed 
> one-step-production deployment guides and used this script:
>
>
> http://web2py.googlecode.com/hg/scripts/setup-web2py-nginx-uwsgi-centos64.sh
>
> All the setup has been completed on my server, now I would like to upload 
> my application and test it online. Could anyone tell me how do I continue? 
> Couldn't find much about that in the book.
>

-- 
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/groups/opt_out.


[web2py] How to map custom code to specific user roles to determine the auth_user field?

2013-10-14 Thread Apple Mason
Suppose I have three different types of users: buyer, distributor, and 
reseller.

All buyers, distributors, and resellers have an email, password, and 
ratings. Since email and password are already part of auth_user, the 
ratings Field will be an extra field in auth_user.

To separate the user roles, we can user auth_membership and auth_group to 
designate an auth_user as a 'buyer', 'distributor', or 'reseller'. 

Although each user role uses the same backend code for storing email and 
password (through auth_user), how would one go about storing a custom 
rating mechanism for each user role?

For example, let's say:

A buyer is rated with some combination of # of product reviews written and 
credible purchase history.

A reseller is rated with some combination of buyer reviews and warranty 
service.

A distributor is rated with reseller reviews.

Assuming I have the following functions which returns on an integer with 
range 1 - 100 for ratings:

def buyer_calc_rating():  # Random calcluation for this example
 comment_num = len(db(db.comments.user == db.buyer.id).select())
 purchase_history = #... some calculation that returns int

 return comment_num + purchase_history

def reseller_calc_rating();   # Assume similar calculation returns int
def distributor_calc_rating();  # Assume similar calculation returns int

I have two questions:

- How would I go about assigning these functions to user's ratings Field in 
auth_user?

- How would the ratings be dynamically updated each time something changes 
pertaining to rating calculation (ie, when a buyer rates a seller, etc)?

   Would the preferred way be to stick the above functions in a module 
which is then called wherever some controller function changes ratings? I 
would always get an update-to-date rating on the user this way (simply by 
querying 'db.auth_user.rating'), but that would also be a code-maintanence 
nightmare since I would have to keep track of all the places in the code 
that manipulates ratings?

Thanks in advance.


-- 
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/groups/opt_out.


[web2py] Re: web2py - one step deployment - now what? :)

2013-10-14 Thread lesssugar
Sure, I understand. But let's say I want to display the welcome 
application. When I run web2py.py on the server I still get the information 
that I should visit http://127.0.0.1:8000/. So when I go to 
[my_domain]/welcome I get "Not found" error. My knowledge here is basic, 
just so you guys know.

On Monday, October 14, 2013 10:06:53 PM UTC+2, Anthony wrote:
>
> One option is to upload it through the admin interface.
>
> On Monday, October 14, 2013 3:53:43 PM UTC-4, lesssugar wrote:
>>
>> Hi,
>>
>> I'm planning to bring my app "to life". So far, I have followed 
>> one-step-production deployment guides and used this script:
>>
>>
>> http://web2py.googlecode.com/hg/scripts/setup-web2py-nginx-uwsgi-centos64.sh
>>
>> All the setup has been completed on my server, now I would like to upload 
>> my application and test it online. Could anyone tell me how do I continue? 
>> Couldn't find much about that in the book.
>>
>

-- 
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/groups/opt_out.


[web2py] Re: GAE: Running test. issue with exec_environment()

2013-10-14 Thread Quint
I figured out that when i use env() in stead of exec_environment() i can 
successfully load my environment.
Is this the recommended way?

def setUp (self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()


#env = exec_environment()
environment = env('init', True)


On Monday, October 14, 2013 8:31:34 PM UTC+2, Quint wrote:
>
> Guys,
>
> What are the steps i need to take to be able to run tests while using GAE?
>
> Do you want me to to create an issue?
>
>
>
> On Sunday, October 13, 2013 3:14:46 PM UTC+2, Quint wrote:
>>
>> That indeed had something to do with it.
>> After i changed it to this:
>>
>> db = DAL('google:datastore')
>> session.connect(request, response, db=db)
>>
>> I got this error:
>>
>> Traceback (most recent call last):
>>   File "X:\GAE\***\tests\test_fragments.py", line 25, in setUp
>> exec_environment('applications/init/models/db.py')
>>   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\shell.py",
>>  line 93, in exec_environment
>> execfile(pyfile, env)
>>   File "applications/init/models/db.py", line 30, in 
>> session.connect(request, response, db=db)
>>   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\globals.py
>> ", line 730, in connect
>> response.session_id_name = 'session_id_%s' % masterapp.lower()
>> AttributeError: 'NoneType' object has no attribute 'lower'
>>
>> After i removed this line
>>
>> session.connect(request, response, db=db)
>>
>> I get this:
>>
>> Traceback (most recent call last):
>>   File "X:\GAE\***\tests\test_fragments.py", line 25, in setUp
>> exec_environment('applications/init/models/db.py')
>>   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\shell.py",
>>  line 93, in exec_environment
>> execfile(pyfile, env)
>>   File "applications/init/models/db.py", line 34, in 
>> auth = Auth(db)  # authentication/authorization
>>   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\tools.py",
>>  line 1144, in __init__
>> request = current.request
>> AttributeError: 'thread._local' object has no attribute 'request'
>>
>> There is no request object?
>>
>>
>> On Sunday, October 13, 2013 2:51:35 PM UTC+2, Niphlod wrote:
>>>
>>> I think that that's a problem on how by default web2py recognize a GAE 
>>> environment. If I'm right, you didn't change at all the db.py lines that do 
>>> something like this
>>>
>>> if not request.env.web2py_runtime_gae:
>>> ## if NOT running on Google App Engine use SQLite or other DB
>>> db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
>>> else:
>>> ## connect to Google BigTable (optional 'google:datastore://namespace')
>>> db = DAL('google:datastore')
>>>
>>>
>>> I think that you run your tests where request.env.web2py_runtime_gae is 
>>> False. To confirm this, strip that part and just use
>>>
>>> db = DAL('google:datastore')
>>>
>>> On Sunday, October 13, 2013 2:35:14 PM UTC+2, Quint wrote:

 Hi,

 I am trying to create a test for one of my modules.
 This module depends on several global variables like "Resonse" and some 
 extra things i store in current from one of my Models. (current.myapp.*** 
 ).
 So to be able to run the test i need to execute some of the models like 
 this. (Is this the correct way?)
 (The testbed stuff is for GAE to create stubs for GAE services)

 def setUp (self):
 self.testbed = testbed.Testbed()
 self.testbed.activate()
 self.testbed.init_datastore_v3_stub()
 self.testbed.init_memcache_stub()
 exec_environment('applications/init/models/0.py')
 exec_environment('applications/init/models/db.py')

 I am using GAE with web2py 2.6.4 source and Python 2.7.3

 Now when i run the test i get this error:

 No handlers could be found for logger "web2py"
 DEBUG: connect attempt 0, connection error:
 Traceback (most recent call last):
   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\dal.py", l
 ine 7854, in __init__
 self._adapter = ADAPTERS[self._dbname](**kwargs)
   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\dal.py", l
 ine 2288, in __init__
 if do_connect: self.find_driver(adapter_args)
   File "C:\Users\Quint\Documents\Projects\GAE\***\gluon\dal.py", l
 ine 791, in find_driver
 raise RuntimeError("no driver available %s" % str(self.drivers))
 RuntimeError: no driver available ('sqlite2', 'sqlite3')

 So it looks like DAL is instantiated and by default it tries to connect 
 to sqlite?

 What can i do about this?

 BTW when i try to start the web2py shell i get a similar error only now 
 i says that it find a "google" driver:

 No handlers could be found for logger "web2py"
 web2py Web Fr

[web2py] Re: How to map custom code to specific user roles to determine the auth_user field?

2013-10-14 Thread Niphlod
Things can get messy in no-time with a field that is constantly 
recalculated every time (e.g.) a row gets inserted into the "ratings" table.
Plan carefully those "updating functions" because if that function takes 
0.15 sec to execute, than you incur in AT LEAST 0.15 sec delay for every 
insert/update/delete out there.
The way to go for "real-time" is using DAL callbacks 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#before-and-after-callbacks

I'd instead go for a scheduled function that every n minutes recalculates 
what is there to recalculate (and I'll plan carefully that too).


On Monday, October 14, 2013 10:12:26 PM UTC+2, Apple Mason wrote:
>
> Suppose I have three different types of users: buyer, distributor, and 
> reseller.
>
> All buyers, distributors, and resellers have an email, password, and 
> ratings. Since email and password are already part of auth_user, the 
> ratings Field will be an extra field in auth_user.
>
> To separate the user roles, we can user auth_membership and auth_group to 
> designate an auth_user as a 'buyer', 'distributor', or 'reseller'. 
>
> Although each user role uses the same backend code for storing email and 
> password (through auth_user), how would one go about storing a custom 
> rating mechanism for each user role?
>
> For example, let's say:
>
> A buyer is rated with some combination of # of product reviews written and 
> credible purchase history.
>
> A reseller is rated with some combination of buyer reviews and warranty 
> service.
>
> A distributor is rated with reseller reviews.
>
> Assuming I have the following functions which returns on an integer with 
> range 1 - 100 for ratings:
>
> def buyer_calc_rating():  # Random calcluation for this example
>  comment_num = len(db(db.comments.user == db.buyer.id).select())
>  purchase_history = #... some calculation that returns int
>
>  return comment_num + purchase_history
>
> def reseller_calc_rating();   # Assume similar calculation returns int
> def distributor_calc_rating();  # Assume similar calculation returns int
>
> I have two questions:
>
> - How would I go about assigning these functions to user's ratings Field 
> in auth_user?
>
> - How would the ratings be dynamically updated each time something changes 
> pertaining to rating calculation (ie, when a buyer rates a seller, etc)?
>
>Would the preferred way be to stick the above functions in a module 
> which is then called wherever some controller function changes ratings? I 
> would always get an update-to-date rating on the user this way (simply by 
> querying 'db.auth_user.rating'), but that would also be a code-maintanence 
> nightmare since I would have to keep track of all the places in the code 
> that manipulates ratings?
>
> Thanks in advance.
>
>
>

-- 
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/groups/opt_out.


[web2py] Re: web2py - one step deployment - now what? :)

2013-10-14 Thread Anthony
If you used the setup script, then web2py is being served via nginx and 
uwsgi. You should not "run" web2py (i.e., do not enter "python web2py.py" 
at the command line) -- that serves web2py using the built-in Rocket web 
server, which you are not using. Once you have run the setup script and 
have nginx/uwsgi running, you can get to your application by visiting 
http://[server ip address]/yourapp, or assuming you have registered a 
domain name, http://[host name]/yourapp. To get to admin, just go to 
https://[host name]/admin (note, because the setup script created a 
self-signed SSL certificate, you will get a browser warning -- if you 
install an SSL certificate from a certificate authority, that warning will 
go away).

Anthony

On Monday, October 14, 2013 4:19:03 PM UTC-4, lesssugar wrote:
>
> Sure, I understand. That's the main question: how do I get to admin or any 
> other application now?
>
> Let's say I want to display the welcome application. When I run web2py.py 
> on the server I still get the information that I should visit 
> http://127.0.0.1:8000/. So when I go to [my_domain]/welcome I get "Not 
> found" error. My knowledge here is basic, just so you guys know.
>
> On Monday, October 14, 2013 10:06:53 PM UTC+2, Anthony wrote:
>>
>> One option is to upload it through the admin interface.
>>
>> On Monday, October 14, 2013 3:53:43 PM UTC-4, lesssugar wrote:
>>>
>>> Hi,
>>>
>>> I'm planning to bring my app "to life". So far, I have followed 
>>> one-step-production deployment guides and used this script:
>>>
>>>
>>> http://web2py.googlecode.com/hg/scripts/setup-web2py-nginx-uwsgi-centos64.sh
>>>
>>> All the setup has been completed on my server, now I would like to 
>>> upload my application and test it online. Could anyone tell me how do I 
>>> continue? Couldn't find much about that in the book.
>>>
>>

-- 
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/groups/opt_out.


[web2py] Re: web2py - one step deployment - now what? :)

2013-10-14 Thread lesssugar
OK, I had apache running and blocking the port. Stopped apache, resterted 
nginx, all works fine.

On Monday, October 14, 2013 10:28:47 PM UTC+2, Anthony wrote:
>
> If you used the setup script, then web2py is being served via nginx and 
> uwsgi. You should not "run" web2py (i.e., do not enter "python web2py.py" 
> at the command line) -- that serves web2py using the built-in Rocket web 
> server, which you are not using. Once you have run the setup script and 
> have nginx/uwsgi running, you can get to your application by visiting 
> http://[server ip address]/yourapp, or assuming you have registered a 
> domain name, http://[host name]/yourapp. To get to admin, just go to 
> https://[host name]/admin (note, because the setup script created a 
> self-signed SSL certificate, you will get a browser warning -- if you 
> install an SSL certificate from a certificate authority, that warning will 
> go away).
>
> Anthony
>
> On Monday, October 14, 2013 4:19:03 PM UTC-4, lesssugar wrote:
>>
>> Sure, I understand. That's the main question: how do I get to admin or 
>> any other application now?
>>
>> Let's say I want to display the welcome application. When I run web2py.py 
>> on the server I still get the information that I should visit 
>> http://127.0.0.1:8000/. So when I go to [my_domain]/welcome I get "Not 
>> found" error. My knowledge here is basic, just so you guys know.
>>
>> On Monday, October 14, 2013 10:06:53 PM UTC+2, Anthony wrote:
>>>
>>> One option is to upload it through the admin interface.
>>>
>>> On Monday, October 14, 2013 3:53:43 PM UTC-4, lesssugar wrote:

 Hi,

 I'm planning to bring my app "to life". So far, I have followed 
 one-step-production deployment guides and used this script:


 http://web2py.googlecode.com/hg/scripts/setup-web2py-nginx-uwsgi-centos64.sh

 All the setup has been completed on my server, now I would like to 
 upload my application and test it online. Could anyone tell me how do I 
 continue? Couldn't find much about that in the book.

>>>

-- 
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/groups/opt_out.


[web2py] Re: How to map custom code to specific user roles to determine the auth_user field?

2013-10-14 Thread Cliff Kachinske
What I like about my solution is you can just let the db compute the 
average of the ratings for any given user when it's needed.

Admittedly this gets a little hairy if you want to rank sellers according 
to rating in an index list, or show the ratings in such a list. 

On Monday, October 14, 2013 4:26:42 PM UTC-4, Niphlod wrote:
>
> Things can get messy in no-time with a field that is constantly 
> recalculated every time (e.g.) a row gets inserted into the "ratings" table.
> Plan carefully those "updating functions" because if that function takes 
> 0.15 sec to execute, than you incur in AT LEAST 0.15 sec delay for every 
> insert/update/delete out there.
> The way to go for "real-time" is using DAL callbacks 
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#before-and-after-callbacks
>
> I'd instead go for a scheduled function that every n minutes recalculates 
> what is there to recalculate (and I'll plan carefully that too).
>
>
> On Monday, October 14, 2013 10:12:26 PM UTC+2, Apple Mason wrote:
>>
>> Suppose I have three different types of users: buyer, distributor, and 
>> reseller.
>>
>> All buyers, distributors, and resellers have an email, password, and 
>> ratings. Since email and password are already part of auth_user, the 
>> ratings Field will be an extra field in auth_user.
>>
>> To separate the user roles, we can user auth_membership and auth_group to 
>> designate an auth_user as a 'buyer', 'distributor', or 'reseller'. 
>>
>> Although each user role uses the same backend code for storing email and 
>> password (through auth_user), how would one go about storing a custom 
>> rating mechanism for each user role?
>>
>> For example, let's say:
>>
>> A buyer is rated with some combination of # of product reviews written 
>> and credible purchase history.
>>
>> A reseller is rated with some combination of buyer reviews and warranty 
>> service.
>>
>> A distributor is rated with reseller reviews.
>>
>> Assuming I have the following functions which returns on an integer with 
>> range 1 - 100 for ratings:
>>
>> def buyer_calc_rating():  # Random calcluation for this example
>>  comment_num = len(db(db.comments.user == db.buyer.id).select())
>>  purchase_history = #... some calculation that returns int
>>
>>  return comment_num + purchase_history
>>
>> def reseller_calc_rating();   # Assume similar calculation returns int
>> def distributor_calc_rating();  # Assume similar calculation returns int
>>
>> I have two questions:
>>
>> - How would I go about assigning these functions to user's ratings Field 
>> in auth_user?
>>
>> - How would the ratings be dynamically updated each time something 
>> changes pertaining to rating calculation (ie, when a buyer rates a seller, 
>> etc)?
>>
>>Would the preferred way be to stick the above functions in a module 
>> which is then called wherever some controller function changes ratings? I 
>> would always get an update-to-date rating on the user this way (simply by 
>> querying 'db.auth_user.rating'), but that would also be a code-maintanence 
>> nightmare since I would have to keep track of all the places in the code 
>> that manipulates ratings?
>>
>> Thanks in advance.
>>
>>
>>

-- 
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/groups/opt_out.


[web2py] Re: How to map custom code to specific user roles to determine the auth_user field?

2013-10-14 Thread Cliff Kachinske
You probably should rethink your database design. You will surely do not 
wish to prohibit your sellers from buying things on your commerce site.

So leave your auth_user table alone and create three other tables, like so:

db.define_table('reseller_rating', Field('rating', 'integer'), 
Field('reseller', 'reference auth_user, requires=IS_IN_DB(db, 'auth_user.id 

db.define_table('distributor_rating', Field('rating', 'integer'), 
Field('distributor', 'reference  auth_user, requires=IS_IN_DB(db, 
'auth_user.id 
db.define_table('buyer_rating', Field('rating', 'integer'), Field('buyer', 
'reference auth_user', requires = IS_IN_DB

Actually, unless you have a clear difference in mind between distributors 
and resellers, I think you can get rid of the  reseller table.

Then you create a controller called 'distributor_rating' with a function 
called 'add.'

If you want to compute the average rating in the controller, user 
SQLFORM.factory or SQLFORM.custom_form. You can read up on those on the 
on-line book in the "Forms and Validators" chapter.



On Monday, October 14, 2013 4:12:26 PM UTC-4, Apple Mason wrote:
>
> Suppose I have three different types of users: buyer, distributor, and 
> reseller.
>
> All buyers, distributors, and resellers have an email, password, and 
> ratings. Since email and password are already part of auth_user, the 
> ratings Field will be an extra field in auth_user.
>
> To separate the user roles, we can user auth_membership and auth_group to 
> designate an auth_user as a 'buyer', 'distributor', or 'reseller'. 
>
> Although each user role uses the same backend code for storing email and 
> password (through auth_user), how would one go about storing a custom 
> rating mechanism for each user role?
>
> For example, let's say:
>
> A buyer is rated with some combination of # of product reviews written and 
> credible purchase history.
>
> A reseller is rated with some combination of buyer reviews and warranty 
> service.
>
> A distributor is rated with reseller reviews.
>
> Assuming I have the following functions which returns on an integer with 
> range 1 - 100 for ratings:
>
> def buyer_calc_rating():  # Random calcluation for this example
>  comment_num = len(db(db.comments.user == db.buyer.id).select())
>  purchase_history = #... some calculation that returns int
>
>  return comment_num + purchase_history
>
> def reseller_calc_rating();   # Assume similar calculation returns int
> def distributor_calc_rating();  # Assume similar calculation returns int
>
> I have two questions:
>
> - How would I go about assigning these functions to user's ratings Field 
> in auth_user?
>
> - How would the ratings be dynamically updated each time something changes 
> pertaining to rating calculation (ie, when a buyer rates a seller, etc)?
>
>Would the preferred way be to stick the above functions in a module 
> which is then called wherever some controller function changes ratings? I 
> would always get an update-to-date rating on the user this way (simply by 
> querying 'db.auth_user.rating'), but that would also be a code-maintanence 
> nightmare since I would have to keep track of all the places in the code 
> that manipulates ratings?
>
> Thanks in advance.
>
>
>

-- 
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/groups/opt_out.


[web2py] Re: web2py - one step deployment - now what? :)

2013-10-14 Thread lesssugar
Now, however, I can't get to admin. The password was set during the one 
step deployment but I cannot get to admin panel with the pass. Any way to 
retrieve it?

On Monday, October 14, 2013 10:56:57 PM UTC+2, lesssugar wrote:
>
> OK, I had apache running and blocking the port. Stopped apache, resterted 
> nginx, all works fine.
>
> On Monday, October 14, 2013 10:28:47 PM UTC+2, Anthony wrote:
>>
>> If you used the setup script, then web2py is being served via nginx and 
>> uwsgi. You should not "run" web2py (i.e., do not enter "python web2py.py" 
>> at the command line) -- that serves web2py using the built-in Rocket web 
>> server, which you are not using. Once you have run the setup script and 
>> have nginx/uwsgi running, you can get to your application by visiting 
>> http://[server ip address]/yourapp, or assuming you have registered a 
>> domain name, http://[host name]/yourapp. To get to admin, just go to 
>> https://[host name]/admin (note, because the setup script created a 
>> self-signed SSL certificate, you will get a browser warning -- if you 
>> install an SSL certificate from a certificate authority, that warning will 
>> go away).
>>
>> Anthony
>>
>> On Monday, October 14, 2013 4:19:03 PM UTC-4, lesssugar wrote:
>>>
>>> Sure, I understand. That's the main question: how do I get to admin or 
>>> any other application now?
>>>
>>> Let's say I want to display the welcome application. When I run 
>>> web2py.py on the server I still get the information that I should visit 
>>> http://127.0.0.1:8000/. So when I go to [my_domain]/welcome I get "Not 
>>> found" error. My knowledge here is basic, just so you guys know.
>>>
>>> On Monday, October 14, 2013 10:06:53 PM UTC+2, Anthony wrote:

 One option is to upload it through the admin interface.

 On Monday, October 14, 2013 3:53:43 PM UTC-4, lesssugar wrote:
>
> Hi,
>
> I'm planning to bring my app "to life". So far, I have followed 
> one-step-production deployment guides and used this script:
>
>
> http://web2py.googlecode.com/hg/scripts/setup-web2py-nginx-uwsgi-centos64.sh
>
> All the setup has been completed on my server, now I would like to 
> upload my application and test it online. Could anyone tell me how do I 
> continue? Couldn't find much about that in the book.
>


-- 
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/groups/opt_out.


[web2py] Change in ImapAdapter content field

2013-10-14 Thread Alan Etkin
> The previous versions of web2py used to store the Content as
> a List whereby the Text part and HTML part could be extracted
> using: Content[0] and Content[1] formats. For some reasons, the new
> update seems to store the Content as a String and not a List.

Since some releases back, the way of extracting html or text from
email row contents is this (similar to attachments, with lists of
dictionaries):

# get the message
>>> row = imap.inbox[i]
# get the text from the first text part
>>> text = row.content[0]["text"]
"blah blah"
# get the content type
>>> text = row.content[0]["mime"]
text/plain

> Q: Can you implement an Email Parsing function to the DAL so that we
> can retrieve multipart emails in a List or even Dict format?

Done (see above)

> What is the best way to retrieve Attachments too?

Attachments are retrieved in a similar way but they have payload
instead of text elements.

-- 
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/groups/opt_out.


[web2py] Re: web2py - one step deployment - now what? :)

2013-10-14 Thread lesssugar
Nevermind, figured it out.

On Monday, October 14, 2013 11:09:31 PM UTC+2, lesssugar wrote:
>
> Now, however, I can't get to admin. The password was set during the one 
> step deployment but I cannot get to admin panel with the pass. Any way to 
> retrieve it?
>
> On Monday, October 14, 2013 10:56:57 PM UTC+2, lesssugar wrote:
>>
>> OK, I had apache running and blocking the port. Stopped apache, resterted 
>> nginx, all works fine.
>>
>> On Monday, October 14, 2013 10:28:47 PM UTC+2, Anthony wrote:
>>>
>>> If you used the setup script, then web2py is being served via nginx and 
>>> uwsgi. You should not "run" web2py (i.e., do not enter "python web2py.py" 
>>> at the command line) -- that serves web2py using the built-in Rocket web 
>>> server, which you are not using. Once you have run the setup script and 
>>> have nginx/uwsgi running, you can get to your application by visiting 
>>> http://[server ip address]/yourapp, or assuming you have registered a 
>>> domain name, http://[host name]/yourapp. To get to admin, just go to 
>>> https://[host name]/admin (note, because the setup script created a 
>>> self-signed SSL certificate, you will get a browser warning -- if you 
>>> install an SSL certificate from a certificate authority, that warning will 
>>> go away).
>>>
>>> Anthony
>>>
>>> On Monday, October 14, 2013 4:19:03 PM UTC-4, lesssugar wrote:

 Sure, I understand. That's the main question: how do I get to admin or 
 any other application now?

 Let's say I want to display the welcome application. When I run 
 web2py.py on the server I still get the information that I should visit 
 http://127.0.0.1:8000/. So when I go to [my_domain]/welcome I get "Not 
 found" error. My knowledge here is basic, just so you guys know.

 On Monday, October 14, 2013 10:06:53 PM UTC+2, Anthony wrote:
>
> One option is to upload it through the admin interface.
>
> On Monday, October 14, 2013 3:53:43 PM UTC-4, lesssugar wrote:
>>
>> Hi,
>>
>> I'm planning to bring my app "to life". So far, I have followed 
>> one-step-production deployment guides and used this script:
>>
>>
>> http://web2py.googlecode.com/hg/scripts/setup-web2py-nginx-uwsgi-centos64.sh
>>
>> All the setup has been completed on my server, now I would like to 
>> upload my application and test it online. Could anyone tell me how do I 
>> continue? Couldn't find much about that in the book.
>>
>

-- 
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/groups/opt_out.


[web2py] Re: Download file from string not triggering

2013-10-14 Thread Kariloy Markief
Thanks,

Yeah it figures it would be something dumb on my part like that. :s 
I'm actually trying to port an old site I've made over a couple of years 
back...

So, basically on that js I processed everything I wanted out of the page 
and then...


(...)

var hidden_list = document.createElement('input');
hidden_list.type = 'hidden';
hidden_list.id = 'protlist';
hidden_list.name = 'protlist';
hidden_list.value = tsv;


var save_as = document.createElement('input');
save_as.type = 'hidden';
save_as.id = 'save_as';
save_as.name = 'save_as';
save_as.value = file_name;


form.appendChild(hidden_list);
form.appendChild(save_as);


form.action = '/path/to/cgiscript/saver.py'
form.submit();
form.removeChild(hidden_list);
form.removeChild(save_as);

and then on the saver.py file


import cgi


form = cgi.FieldStorage()


filename = form.getvalue("save_as")


print "Content-type: text/tsv"
print "Content-disposition: attachment; filename= %s" %filename 
print


protlist = form.getvalue("protlist")


print protlist


I even tried to get cheeky and cheat-y and plug that in, and/or convert it 
(and it may just be what you suggested last, but failed miserably to adapt 
it)


Right now, with your first suggestion and as a quick test I've done:


var tsv2 = "cenas";
window.open(encodeURI('download_prots?filename='+file_name+'&text='+tsv2),
'_target'); 

only to be greeted with a

*invalid request*


So, probably it's best to try and adapt my old strategy... could I still 
submit an "hand-crafted" form like that to a controller function? and how 
would I "unpack" the variables? (cgi didn't seem to work here).

Well I'll keep at it and hopefully find a way, but appreciate any help 
getting there :)





On Monday, October 14, 2013 8:18:15 PM UTC+1, Niphlod wrote:
>
> you can't get a "save as" dialog if the contents of the file are retrieved 
> via ajax (browsers don't work like that). Open a new window pointing to the 
> download url (it will soon close as there's no content to show, and the 
> "save as" dialog will pop up).
>
> PS: you'd really want to use another system than the simple concatenation 
> to build the url... if "content" in your case contains csv data, you will 
> never be able to reach that url (because it won't be a valid url). 
> As last resort, at least urlencode the content. But you'll then face the 
> limitation of url size, and that's why usually those kind of things are 
> made with intermediate temp files or (slightly more complicated in a new 
> window) POST requests :P 
>
> On Monday, October 14, 2013 6:15:51 PM UTC+2, Kariloy Markief wrote:
>>
>> Hello,
>>
>> I'm writing an app that at some point has a text string dynamically 
>> generated in a view via javascript.
>> What I would like to do is download that text as a file.
>> For that purpose my attempted approach has been...:
>>
>> - on the same js function that generates the string I call:
>>
>> ajax('download_test?content='+content, [], '');
>>
>>
>> and on the controller I have:
>>
>>
>> def download_test():
>> 
>> content = request.vars.content
>> 
>> response.headers['Content-Type'] = 'text/csv'
>> attachment = 'attachment;filename=data.csv'
>> response.headers['Content-Disposition'] = attachment
>> 
>> raise HTTP(200,str(content),
>>**{'Content-Type':'text/csv',
>>   'Content-Disposition':attachment + ';'})
>>
>>
>> I've tried several variations around this approach, and the only thing 
>> that I can confirm is that the desired content is effectively passed from 
>> the the view to the controller (and back to the view if I define a 
>> container as the 3rd parameter of the ajax() function, but that's not what 
>> I want).
>>
>> So the problem here seems to be be triggering the download. 
>>
>> I've tried this on firefox (running my app), and also on chromium (via 
>> minimal app just to reproduce this issue). 
>>
>> I'm running web2py version 2.4.7
>>
>> Also the most similar reported issue I've found in this list was:
>> https://groups.google.com/forum/#!topic/web2py/GH2HVCGPMKo
>>
>> Because no answer was found then and I was unsure about this group's 
>> policy of reviving old threads, I published mine as a new question. Hope 
>> this is ok.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>

-- 
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/groups/opt_out.


[web2py] odbc error question, when running scheduler_test app.

2013-10-14 Thread Andrew W
Hello,
I've hit an odbc error using the Scheduler_Test app against an experimental 
instance on Teradata.

When I turn on the scheduler monitoring I sometimes get:

Error: ('HY000', '[HY000] [Teradata][ODBC Teradata Driver] Beyond 
SQL_ACTIVE_STATEMENTS limit')

I've improved things a bit by setting a pool_size and increasing the scheduler 
poll interval but it still occurs.   I think the time to complete a login on 
Teradata (on my system anyway) may contribute - perhaps the next poll cycle 
comes up while the last one is still running.

I've found that it has to do with the hstmt limit being reached in the odbc 
driver.  Not really sure what that means.

*This isn't necessarily a web2py, scheduler, or pyodbc error, but maybe one of 
controlling the odbc activity to within limits.  Has anyone seen this before 
and been able to manage it ?It may be a limitation in the Teradata odbc driver 
that may limit its effectiveness for high concurrency web apps.*

*Thanks*

*Andrew W*

-- 
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/groups/opt_out.


[web2py] Getting JSON data from a select into Javascript

2013-10-14 Thread david.waldrop
All I am trying to pass data from a function to javascript

here is the function in web2py:

def getitemtags(inid):
jurisdictions = db(db.jurisdiction.aid == 
inid).select(db.jurisdiction.id, db.jurisdiction.jurisdiction, 
db.jurisdiction.training, db.jurisdiction.predicted)
data = [[row.id, row.jurisdiction, row.training, row.predicted] for row 
in jurisdictions]
return json.dumps(data)

In the view I have the following:

  $().ready(function(){ 
console.log('--- all is loaded  ' + Date());
var itemtags = 
jQuery.parseJSON({{=getitemtags(results.update_form.custom.dspval.id)}});
console.log(itemtags);
// all data should be here now and we can get started
  });   



Here is the error output :


var itemtags = jQuery.parseJSON([[403, "United States", true, null]])



Does anyone know how to cleanly pas json data to the client?

-- 
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/groups/opt_out.


[web2py] Re: Download file from string not triggering

2013-10-14 Thread Kariloy Markief
Ok, as usual my blindness/dumbness knows no boundaries, as I suspect.

Thankfully a new set of eyes usually helps me to in the right track, 
basically what I had to do what use my old JS code... change the cgi target 
to a controller function

and that function was:

def testdownform():

filename = request.vars.save_as
protlist = request.vars.protlist

response.headers['Content-Type'] = 'text/csv'
response.headers['Content-Disposition'] = \
"attachment; filename=%s" % filename

return protlist

Not using my head beyond just shoulder decoration, I forgot to remember 
that basically a form is POSTed and I could just retrieve the request.vars 
... I might have attempted that, but probably had some syntax error (like 
trying to print protlist *cough* instead of returning it) that led me 
astray from that path :s

Anyhow, *problem solved*! 

Thanks again Niphlod for helping me see the light :)
 

~KM

On Monday, October 14, 2013 10:50:55 PM UTC+1, Kariloy Markief wrote:
>
> Thanks,
>
> Yeah it figures it would be something dumb on my part like that. :s 
> I'm actually trying to port an old site I've made over a couple of years 
> back...
>
> So, basically on that js I processed everything I wanted out of the page 
> and then...
>
>
> (...)
>
> var hidden_list = document.createElement('input');
> hidden_list.type = 'hidden';
> hidden_list.id = 'protlist';
> hidden_list.name = 'protlist';
> hidden_list.value = tsv;
>
>
> var save_as = document.createElement('input');
> save_as.type = 'hidden';
> save_as.id = 'save_as';
> save_as.name = 'save_as';
> save_as.value = file_name;
>
>
> form.appendChild(hidden_list);
> form.appendChild(save_as);
>
>
> form.action = '/path/to/cgiscript/saver.py'
> form.submit();
> form.removeChild(hidden_list);
> form.removeChild(save_as);
>
> and then on the saver.py file
>
>
> import cgi
>
>
> form = cgi.FieldStorage()
>
>
> filename = form.getvalue("save_as")
>
>
> print "Content-type: text/tsv"
> print "Content-disposition: attachment; filename= %s" %filename 
> print
>
>
> protlist = form.getvalue("protlist")
>
>
> print protlist
>
>
> I even tried to get cheeky and cheat-y and plug that in, and/or convert it 
> (and it may just be what you suggested last, but failed miserably to adapt 
> it)
>
>
> Right now, with your first suggestion and as a quick test I've done:
>
>
> var tsv2 = "cenas";
> window.open(encodeURI('download_prots?filename='+file_name+'&text='+tsv2),
> '_target'); 
>
> only to be greeted with a
>
> *invalid request*
>
>
> So, probably it's best to try and adapt my old strategy... could I still 
> submit an "hand-crafted" form like that to a controller function? and how 
> would I "unpack" the variables? (cgi didn't seem to work here).
>
> Well I'll keep at it and hopefully find a way, but appreciate any help 
> getting there :)
>
>
>
>
>
> On Monday, October 14, 2013 8:18:15 PM UTC+1, Niphlod wrote:
>>
>> you can't get a "save as" dialog if the contents of the file are 
>> retrieved via ajax (browsers don't work like that). Open a new window 
>> pointing to the download url (it will soon close as there's no content to 
>> show, and the "save as" dialog will pop up).
>>
>> PS: you'd really want to use another system than the simple concatenation 
>> to build the url... if "content" in your case contains csv data, you will 
>> never be able to reach that url (because it won't be a valid url). 
>> As last resort, at least urlencode the content. But you'll then face the 
>> limitation of url size, and that's why usually those kind of things are 
>> made with intermediate temp files or (slightly more complicated in a new 
>> window) POST requests :P 
>>
>> On Monday, October 14, 2013 6:15:51 PM UTC+2, Kariloy Markief wrote:
>>>
>>> Hello,
>>>
>>> I'm writing an app that at some point has a text string dynamically 
>>> generated in a view via javascript.
>>> What I would like to do is download that text as a file.
>>> For that purpose my attempted approach has been...:
>>>
>>> - on the same js function that generates the string I call:
>>>
>>> ajax('download_test?content='+content, [], '');
>>>
>>>
>>> and on the controller I have:
>>>
>>>
>>> def download_test():
>>> 
>>> content = request.vars.content
>>> 
>>> response.headers['Content-Type'] = 'text/csv'
>>> attachment = 'attachment;filename=data.csv'
>>> response.headers['Content-Disposition'] = attachment
>>> 
>>> raise HTTP(200,str(content),
>>>**{'Content-Type':'text/csv',
>>>   'Content-Disposition':attachment + ';'})
>>>
>>>
>>> I've tried several variations around this approach, and the only thing 
>>> that I can confirm is that the desired content is effectively passed from 
>>> the the view to the controller (and back to the view if I define a 
>>> container as the 3rd parameter of the ajax() function, but that's not what 
>>> I want).
>>>
>>> So the problem here seems to

[web2py] Re: Getting JSON data from a select into Javascript

2013-10-14 Thread Alan Etkin

>
> Does anyone know how to cleanly pas json data to the client?
>

How about

jdata = db(query).select(...).as_json()

Then the js part:

{{=SCRIPT("""
var myObject = %(jdata)s;
""" % dict(jdata=jdata))}}

-- 
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/groups/opt_out.


[web2py] Re: Change in ImapAdapter content field

2013-10-14 Thread PRACHI VAKHARIA

 



How does one query the IMAP server based on the new format?

 

Previously, to get messages from a given sender in a given mailbox, the 
following worked »

messages = imapdb(imapdb.INBOX.sender.contains("SenderName")).select()

Or an email on a given date by »

messages = imapdb(imapdb.INBOX.created == datetime.date(2013,1,25)).select()


And UID by »

messages = imapdb(imapdb.INBOX.uid == '3869').select().first()

messages = imapdb(imapdb.INBOX.uid.belongs('1000')).select()




*Q»  How is the new IMAP DAL Query to be written? What is the new Query 
Format or Schema?*





 







-- 
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/groups/opt_out.


[web2py] Programmatically Start/Restart

2013-10-14 Thread Auden RovelleQuartz
is there a way to programmatically start or restart a web2py application?

-- 
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/groups/opt_out.


[web2py] Re: Embed PDF

2013-10-14 Thread Ari Lion BR Sp
I have reallized my mistakes.

First of all, I didnt created my 'pdfs' folder under 'static' what I should 
have done. 
Second, I was using wrong sintaxe request.http_host instead off request.env.
http_host

Thanks for listening



Em segunda-feira, 14 de outubro de 2013 10h41min31s UTC-3, Ari Lion BR Sp 
escreveu:
>
> Hi to all, 
>
> I do generate PDFs at my my application, and do store it at a folder at my 
> aapication, and I want to embed it as a preview at my View page.
> I was using  tag in order to do so:
>
>  src="http://www.mysite.com/local_where_i_saved_my_pdf/pdf_name.pdf
> " width="100%" height="375">
>
> But I need it to be flexible, and I do not succeed to map *src *to point 
> to the absolute URL (I guess also due to routing etc). 
>
> I have also tried the below without success.
>
> os.path.join(request.http_host, request.folder,
> 'local_where_i_saved_my_pdf', 
> 'pdf_name
> .pdf')
>
>
> What should be the correct, and which alternatives do I have?
>
> Thanks and regards!
>

-- 
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/groups/opt_out.


[web2py] Re: Change in ImapAdapter content field

2013-10-14 Thread Alan Etkin

>
> How does one query the IMAP server based on the new format?
>
>
You can use the same queries as before. The difference is on record 
representation. The Row object content attribute returned with selects is 
now a list object containing a dictionary for each message part.

-- 
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/groups/opt_out.


Re: [web2py] Re: Load with ajax doesn't work since upgrade > 1.6

2013-10-14 Thread Michael Helbling

this load works in 2.5.1 (please take a look at web2py.app.test251.w2p). 
;-) 

the web2py.js is available on the page, because it is imported in test(), 
and the trigger was able to call this js. 


Am Montag, 14. Oktober 2013 16:43:38 UTC+2 schrieb Niphlod:
>
> wait a sec. before (< 2.6.0) the js to "trigger" the load was inlined, but 
> web2py.js HAD to be available nonetheless to make that happen. What's 
> changed is that now web2py.js takes also care of the "trigger".
>
> def test2()
> ret = DIV(XML("test2 "))
> ret.append(LOAD(f='test3', ajax=True))
> return ret
>
> def test3():
> return DIV('test 3')
>
>
> Opening test2 as it is and hoping that it loads test3 doesn't work in  > 
> 2.6.0 AND doesn't work in < 2.6.0 , because neither test2 nor test3 load 
> web2py.js.
>
> Il giorno lunedì 14 ottobre 2013 15:43:21 UTC+2, Michael Helbling ha 
> scritto:
>>
>>
>> Yes, but there was no need to load the js two times on the same page < 
>> 2.6. Even if there was an ajax call between the initially page load and the 
>> LOAD. 
>> if you import the web2py.app.test251.w2p into w2p 2.5.1, you will see, 
>> this behavior worked before the upgrade. And there are a lot of these Loads 
>> in 7 different applications. 
>>
>> Do you mean something like this?
>> def test2():
>> ret = DIV(XML("test2 "))
>> ret.append(XML("> type='text/javascript'>"))
>> ret.append(XML("> type='text/javascript'>"))
>> ret.append(LOAD(f='test3', ajax=True))
>> return ret
>>
>> *This works :/ but this will cause a lot of work to find and expand every 
>> ajax call which has a LOAD in it. 
>>
>> If you have an idea, how to solve this properly in an other way, please 
>> let me know. 
>> Else, thanks a lot for your support and patience! It's good to know the 
>> reason, even if I can not solve it immediately :D
>>
>>
>>
>> Am Montag, 14. Oktober 2013 14:54:36 UTC+2 schrieb Niphlod:
>>>
>>> You aren't using any view if you return raw HTML tags (as in return 
>>> DIV('...'))
>>>
>>> Il giorno lunedì 14 ottobre 2013 14:38:02 UTC+2, Michael Helbling ha 
>>> scritto:



 hmm, in the view test.html is the layout included, in the layout the 
 web2py_ajax.html and there are the js included.? :S
 do you mean the web2py_ajax.html? 

 i tried to copy the app to w2p 2.5.1 too, but it seems there were some 
 changes, that needs more changes to migrate an app to a lower version :/ 
 sorry, i didn't test this direction before..


 if i create a new simple app in w2p 2.5.1, insert the code for the test 
 functions and views. It works. I attached the app from 2.5.1 
 (web2py.app.test251)

 then i packed the app and installed it in w2p 2.7.2. After this, i 
 copied the web2py.js, jquery.js and appadmin controller/view as in the 
 changelog described. But the load still doesn't work. I attached this app 
 too (web2py.app.test272.w2p) 
 are there more files that needs an update? *i'm not sure which template 
 you mean




 Am Montag, 14. Oktober 2013 13:55:05 UTC+2 schrieb Niphlod:
>
> of course it doesn't. but it won't work even with pre-2.6.0 
> releases . you aren't including the template which holds the js to 
> load 
> the component! :D 
>
> Il giorno lunedì 14 ottobre 2013 08:13:36 UTC+2, Michael Helbling ha 
> scritto:
>>
>>
>> Dear Niphlod
>>
>> Attached is a minimal App. In w2p 2.7.2 i just created a new simple 
>> application and inserted the test code, I posted last time. The load of 
>> "test3" doesn't work and in the div is just "loading..."
>>
>> I tried it on 2 different pcs (at home and work) in firefox and 
>> chrome, so the client shouldn't be the problem. Can you reproduce the 
>> problem with the attached app? the whole code is original, except the 3 
>> test functions in the default controller and the view default/test.html
>>
>>
>>
>> Am Freitag, 11. Oktober 2013 22:15:22 UTC+2 schrieb José L.:
>>>
>>>
>>> El 11/10/2013 21:52, "Niphlod"  escribió:
>>> >
>>> > talking about minimal app, heh anyway, better than nothing.
>>>
>>> I know, but I am answering from my phone, without a PC available ;)
>>>
>>> > taken movuca, setupped, doesn't work (as advertised in web2py's 
>>> changelog).
>>> > Take web2py.js from welcome and overwrite web2py.js in 
>>> /static/bootstrap/js/web2py.js
>>> > Next issue, movuca ships jquery 1.7.1 (november 2011). 
>>> > web2py.js requires something jquery having $.parseHTML ... update 
>>> jquery too and you'll only receive a problem about 
>>> bootstrap-transition.js, 
>>> that is trying to do something with the (now unsupported) $.browser.
>>> > Update bootstrap-transition.js and movuca works like a charm.
>>> >
>>>
>>> I will check it again, maybe I made some mistake copying those 

[web2py] Re: odbc error question, when running scheduler_test app.

2013-10-14 Thread Andrew W
I've found out that a cursor maps to a odbc hstmt.   I also found out that 
Teradata supports 16 open result sets (hstmt) for each session.   So it 
appears that web2py is reusing the same database session for multiple 
simultaneous requests, or isn't closing them correctly before starting the 
next request. 
 
To rephrase my question a bit,  Does a web2py connection equate to a 
database session ?   Does a new request reserve a connection until it's 
complete, i.e another request can't issue database statements 
simultaneously on the same connection ?
 
So, I think the closing of a connection, or the returning of it to the 
pool, is not working properly on Teradata.  Perhaps the cursors are staying 
open and new cursors are created instead of reusing the existing ones (with 
pool_size>0).   I see there is a self._adapter.close() line in dal.py (line 
8056)  so I may need to add something to the TeradataAdapter to make this 
more robust.
 
Does that sound right ?  Thanks.
 

 

-- 
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/groups/opt_out.


Re: [web2py] Re: Load with ajax doesn't work since upgrade > 1.6

2013-10-14 Thread Niphlod
yep, but that's because ajax() doesn't raise a finger when talking about 
components: ajax() is meant to submit form values to an action, not to load 
components

In fact, the recommended way (that continues to work) for the functionality 
you want is to use

A('test', callback=URL(f='test2'), target='test')

Il giorno martedì 15 ottobre 2013 07:52:57 UTC+2, Michael Helbling ha 
scritto:
>
>
> this load works in 2.5.1 (please take a look at web2py.app.test251.w2p). 
> ;-) 
>
> the web2py.js is available on the page, because it is imported in test(), 
> and the trigger was able to call this js. 
>
>
> Am Montag, 14. Oktober 2013 16:43:38 UTC+2 schrieb Niphlod:
>>
>> wait a sec. before (< 2.6.0) the js to "trigger" the load was inlined, 
>> but web2py.js HAD to be available nonetheless to make that happen. What's 
>> changed is that now web2py.js takes also care of the "trigger".
>>
>> def test2()
>> ret = DIV(XML("test2 "))
>> ret.append(LOAD(f='test3', ajax=True))
>> return ret
>>
>> def test3():
>> return DIV('test 3')
>>
>>
>> Opening test2 as it is and hoping that it loads test3 doesn't work in  > 
>> 2.6.0 AND doesn't work in < 2.6.0 , because neither test2 nor test3 load 
>> web2py.js.
>>
>> Il giorno lunedì 14 ottobre 2013 15:43:21 UTC+2, Michael Helbling ha 
>> scritto:
>>>
>>>
>>> Yes, but there was no need to load the js two times on the same page < 
>>> 2.6. Even if there was an ajax call between the initially page load and the 
>>> LOAD. 
>>> if you import the web2py.app.test251.w2p into w2p 2.5.1, you will see, 
>>> this behavior worked before the upgrade. And there are a lot of these Loads 
>>> in 7 different applications. 
>>>
>>> Do you mean something like this?
>>> def test2():
>>> ret = DIV(XML("test2 "))
>>> ret.append(XML(">> type='text/javascript'>"))
>>> ret.append(XML(">> type='text/javascript'>"))
>>> ret.append(LOAD(f='test3', ajax=True))
>>> return ret
>>>
>>> *This works :/ but this will cause a lot of work to find and expand 
>>> every ajax call which has a LOAD in it. 
>>>
>>> If you have an idea, how to solve this properly in an other way, please 
>>> let me know. 
>>> Else, thanks a lot for your support and patience! It's good to know the 
>>> reason, even if I can not solve it immediately :D
>>>
>>>
>>>
>>> Am Montag, 14. Oktober 2013 14:54:36 UTC+2 schrieb Niphlod:

 You aren't using any view if you return raw HTML tags (as in return 
 DIV('...'))

 Il giorno lunedì 14 ottobre 2013 14:38:02 UTC+2, Michael Helbling ha 
 scritto:
>
>
>
> hmm, in the view test.html is the layout included, in the layout the 
> web2py_ajax.html and there are the js included.? :S
> do you mean the web2py_ajax.html? 
>
> i tried to copy the app to w2p 2.5.1 too, but it seems there were some 
> changes, that needs more changes to migrate an app to a lower version :/ 
> sorry, i didn't test this direction before..
>
>
> if i create a new simple app in w2p 2.5.1, insert the code for the 
> test functions and views. It works. I attached the app from 2.5.1 
> (web2py.app.test251)
>
> then i packed the app and installed it in w2p 2.7.2. After this, i 
> copied the web2py.js, jquery.js and appadmin controller/view as in the 
> changelog described. But the load still doesn't work. I attached this app 
> too (web2py.app.test272.w2p) 
> are there more files that needs an update? *i'm not sure which 
> template you mean
>
>
>
>
> Am Montag, 14. Oktober 2013 13:55:05 UTC+2 schrieb Niphlod:
>>
>> of course it doesn't. but it won't work even with pre-2.6.0 
>> releases . you aren't including the template which holds the js to 
>> load 
>> the component! :D 
>>
>> Il giorno lunedì 14 ottobre 2013 08:13:36 UTC+2, Michael Helbling ha 
>> scritto:
>>>
>>>
>>> Dear Niphlod
>>>
>>> Attached is a minimal App. In w2p 2.7.2 i just created a new simple 
>>> application and inserted the test code, I posted last time. The load of 
>>> "test3" doesn't work and in the div is just "loading..."
>>>
>>> I tried it on 2 different pcs (at home and work) in firefox and 
>>> chrome, so the client shouldn't be the problem. Can you reproduce the 
>>> problem with the attached app? the whole code is original, except the 3 
>>> test functions in the default controller and the view default/test.html
>>>
>>>
>>>
>>> Am Freitag, 11. Oktober 2013 22:15:22 UTC+2 schrieb José L.:


 El 11/10/2013 21:52, "Niphlod"  escribió:
 >
 > talking about minimal app, heh anyway, better than nothing.

 I know, but I am answering from my phone, without a PC available ;)

 > taken movuca, setupped, doesn't work (as advertised in web2py's 
 changelog).
 > Take web2py.js from welcome and overwrite