[web2py] Re: Web Development Introduction Based On Web2py

2012-03-27 Thread BlueShadow
Hey Marco,
great tutorial but I got stuck at section 4.3 when we write the first test. 
when startng the funktional_tests.py! The Program writes ran 0 Tests! 0.0 
seconds. Not even the firefox is opening. Anyone knows whats wrong. or what 
I could do?
running Win7 python 2.7 selenium 2.20
thanks for your help.


[web2py] Re: @auth.requires(lambda: auth.has_membership(VCARD))

2012-03-27 Thread Wikus van de Merwe
You need web2py >= 1.99.3 for the lambda to work.


[web2py] Re: difference between

2012-03-27 Thread Wikus van de Merwe
You *have to* set the response.files first, then include web2py_ajax.html. 
Look how this is done in the example app:
http://code.google.com/p/web2py/source/browse/applications/welcome/views/layout.html

Also notice that web2py_ajax.html already includes jquery and web2py.js:
http://code.google.com/p/web2py/source/browse/applications/welcome/views/web2py_ajax.html

Check the generated HTML to see exactly what scripts you include and in 
what order and post it here if you still have problems.


Re: [web2py] Re: DAL and schema

2012-03-27 Thread Johann Spies
On 26 March 2012 20:22, adesst  wrote:

> @Johann, i don't know if you would copy paste the diff i've made into
> PgAdapter,
> and do some tests and post the results. Pg and Oracle schema works in
> the same way.
>
>
I have downloaded and looked at MyDal and the README but I am not sure
which 'diff' you refer to.

I have looked at your code buit seems a bit risky for my to jump in before
I understand fully what you are doing.
I will have to spend some time to work through it.

I was hoping that you will open a ticket and that the schema-option may
become an official part of DAL.
Maybe you are working in that direction.

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


[web2py] Re: Using single instance of LibreOffice to convert documents - is this safe?

2012-03-27 Thread Wikus van de Merwe
If this processing is done after the form submission you can delegate that 
to a background task.
Having a queue of tasks end executing them one by one should solve the 
concurrent access
problem. Check out the book section on scheduler:
http://web2py.com/books/default/chapter/29/4#Scheduler-%28experimental%29



[web2py] Re: DAL Challenge

2012-03-27 Thread Niphlod
On the cache side.

function test(x):
if cache.ram('key_%s' % x, 5):
 return cache.ram('key_%s' % x, 5)
else:
 .
cache.ram('key_%s' % x, lambda: x , 5)




[web2py] Re: Bug? The DAL gives different SQL when query is provided as string.

2012-03-27 Thread Niphlod
you're right.
the "query" actually is only the "where" part, and if you serialize that as 
a string it loses other attributes necessary to construct the other parts 
of the query.

Now, I don't understand why this is a problem: you can:
- cache the results without hitting the database twice using the cache 
argument of the select
- display technically what query produced that results, you can use the 
._select() 
- save the query and then retrieve the results you can, the only caveat is 
having the condition linking the tables "alive" and not serialized

linkwebpage2comment = (db.comment.page_id == db.webpage.id)

cond = (db.comment.id > 0) & (db.webpage.title == 'FAQ') 
print cond
print 'a'
print db(linkwebpage2comment)(cond)._select(db.comment.body)
print 'b'
cond = str(cond)
print db(linkwebpage2comment)(cond)._select(db.comment.body)

- serialize full query with the _select() and then retrieve results with 
executesql()

I'm just missing the point: is this functionality really a limit to your 
application ?

Il giorno martedì 27 marzo 2012 01:38:32 UTC+2, Limedrop ha scritto:
>
> Hi Niphlod, 
>
> Thanks for your reply.  I'm running 1.99.7 and here's the model: 
>
> db.define_table('webpage', 
> Field('title'), 
> Field('body', 'text')) 
>
> db.define_table('comment', 
> Field('page_id', db.webpage), 
> Field('body', 'text')) 
>
> The issue is when you have an implicit inner join, but where you only 
> want one table in the output. 
> I've found a thread where Massimo says that support for stings in 
> queries is "clanky" and that 
> you need a db(db.table) or db(db.table.field) to determine which table 
> is needed. 
>
> http://groups.google.com/group/web2py/browse_thread/thread/2024f660a8981558/d4b0e90d701833bb
>  
>
> So I guess it isn't supported? 
>
>
> On Mar 27, 12:15 am, Niphlod  wrote: 
> > damn mobile phone screen 
> > I got it, seems a simple join, and for my simple model works without a 
> > hitch. 
> > 
> > can you please post your model and tell what web2py version are you 
> running 
> > ? 
> > 
> > Il giorno lunedì 26 marzo 2012 01:58:31 UTC+2, Limedrop ha scritto: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > The difference is in the FROM clause.  In the second SQL the webpage 
> > > table is missing. 
> > 
> > > On Mar 26, 12:51 pm, Niphlod  wrote: 
> > > > is that because of the "extra" () ? 
> > > > every time you call db() the where clause gets "encapsulated" in a 
> pair 
> > > of 
> > > > parenthesis. 
> > 
> > > > db(db.auth_user.id>0)(db.auth_​user.email==localhost) 
> > 
> > > > and 
> > 
> > > > db((db.auth_user.id>0) & (db.auth_user.email==​localhost)) 
> > 
> > > > give you different raw strings, but the same exact result. 
> > 
> > > > Il giorno sabato 24 marzo 2012 21:49:58 UTC+1, Limedrop ha scritto: 
> > 
> > > > > I've copied this from the bottom of another thread. 
> > 
> > > > > The DAL gives different SQL when a query is provided in string 
> format. 
> > > > > Is this a bug, or should I not expect this to work? 
> > 
> > > > > See the example below, the first SQL works, the second SQL raises 
> an 
> > > > > error. 
> > 
> > > > > >>>from gluon.dal import Query 
> > > > > >>>query = (db.comment.id > 0) & (db.webpage.title == 'FAQ') & 
> > > > > (db.comment.page_id == db.webpage.id) 
> > > > > >>>query_as_string = str(query) 
> > > > > >>>query_from_string = Query(db, query_as_string) 
> > > > > >>>print db(query)._select(db.comment.​​body) 
> > 
> > > > > SELECT  comment.body FROM comment, webpage WHERE (((comment.id > 
> 0) 
> > > > > AND (webpage.title = 'FAQ')) AND (comment.page_id = webpage.id)); 
> > 
> > > > > >>>print db(query_from_string)._select(​​db.comment.body) 
> > 
> > > > > SELECT  comment.body FROM comment WHERE comment.id > 0) AND 
> > > > > (webpage.title = 'FAQ')) AND (comment.page_id = webpage.id))); 
> > 
> > > > > Why do this?  If the were possible it would enable you to easily 
> save 
> > > > > a query in the session.  For example: 
> > 
> > > > > ==Controller 1== 
> > > > > query1 = (db.comment.id > 0) & (db.webpage.title == 'FAQ') & 
> > > > > (db.comment.page_id == db.webpage.id) 
> > > > > session.query = str(query1) 
> > 
> > > > > ==Controller 2== 
> > > > > from gluon.dal import Query 
> > > > > query2 = Query(db, session.query) 
> > 
> > > > > This does NOT work because the DAL gives different SQL for query1 
> and 
> > > > > query2.



[web2py] Re: DAL Challenge

2012-03-27 Thread Wikus van de Merwe
When working with GAE datastore you want to execute minimum number of 
queries necessary to avoid delays and
limit the use of DB API calls. Fetching comments one by one is not the best 
option then (even if done with ajax).

Probably the most efficient way would be to store the list of comment ids 
as an attribute of each article entity. Then
you could get all comment ids with a single query. Having the ids you could 
build a list of GAE keys, and fetch all
needed comment entities at once. We discussed that recently here:
https://groups.google.com/d/topic/web2py/7dvo_jqIR38/discussion

I'm also guessing that this might be quite common GAE use case and you 
might find a better solution already optimised
for this on GAE forum. The other option is to show comments only on the 
article individual page (not on the list of articles).

If you use the wrapper for caching, then you could memorize the entire 
response, so this is very efficient as the views
are not rendered but read straight from cache. If you need some extra 
parametrisation inside the controller you could
either move some of the code to a separate function which output is cached 
or simply cache only the queries:
http://web2py.com/books/default/chapter/29/6#Caching-selects



[web2py] Re: Problem with GAE and Cloud SQL

2012-03-27 Thread Matt
I've managed to figure out a solution. (Not sure if it's 100% correct 
though but it seems to work fine).

The GoogleSqlAdapter needs the following change:

class GoogleSQLAdapter(UseDatabaseStoredFile,MySQLAdapter):
uploads_in_blob = True

Hope this helps somebody else.

Matt

On Tuesday, 27 March 2012 11:21:57 UTC+13, Matt wrote:
>
> Hi there,
>
> I'm trying to install a web2py application on GAE using Cloud SQL.
>
> When I try and submit a form that contains an upload field I get the 
> following exception:
>
> dal.py", line 6124, in store os.makedirs(path)
> AttributeError: 'module' object has no attribute 'makedirs'
>
> I'm currently running on web2py-1.99.7-stable.
>
> Any suggestions in fix this or is this a bug with the combination of GAE 
> and Cloud SQL?
>
> Thanks in advance,
> Matt
>


[web2py] Re: web2py 1.99.7 is OUT

2012-03-27 Thread IVINH


In my app, LOAD not work fine with 1.99.7, i'm try a test:
1. copy my view (contain js script), example: index.html to index.load
2. run :  .../index.html and then .../index.load

Both work well with the 1.99.4, but the second was not correct with 1.99.7
I think this is problem of extension .html & .load
 


Vào 11:00:15 UTC+7 Thứ ba, ngày 27 tháng ba năm 2012, Anthony đã viết:
>
> Can you describe the problem? Is the below view the index.load view? What 
> is in plugin_app/layout.html? Should that be extended rather than included?
>
> Anthony
>
> On Monday, March 26, 2012 11:23:34 PM UTC-4, IVINH wrote:
>>
>>
>>
>> I have two views similar but different extension (index.html & index.
>> load).
>> Both work well with the 1.99.4, but index.load was not for 1.99.7?
>>
>> My view:
>>
>> {{include 'plugin_app/layout.html'}}
>> > src="{{=URL(r=request,c='static',f='plugin_chart/jqplot/jquery.jqplot.js')}}"
>>  
>> type="text/javascript">
>> > src="{{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.pieRenderer.min.js')}}"
>>  
>> type="text/javascript">
>> > src="{{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.donutRenderer.min.js')}}"
>>  
>> type="text/javascript">
>> > href="{{=URL(r=request,c='static',f='plugin_chart/jqplot/jquery.jqplot.css')}}"
>>  
>> rel="stylesheet" type="text/css" />
>>
>> > src="{{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.barRenderer.min.js')}}"
>>  
>> type="text/javascript">
>> > src="{{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.categoryAxisRenderer.min.js')}}"
>>  
>> type="text/javascript">
>> > src="{{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.pointLabels.min.js')}}"
>>  
>> type="text/javascript">
>>
>> > src="{{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.canvasTextRenderer.min.js')}}"
>>  
>> type="text/javascript">
>> > src="{{=URL(r=request,c='static',f='plugin_chart/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js')}}"
>>  
>> type="text/javascript">
>>
>> 
>> {{=content}}
>> 
>>
>>
>>
>>
>>  
>>
>> Vào 05:29:43 UTC+7 Thứ hai, ngày 05 tháng ba năm 2012, Massimo Di Pierro 
>> đã viết:
>>>
>>> Same as 1.99.5 and 1.99.6 but should solve all the outstanding 
>>> compatibility issues.
>>>
>>> Massimo
>>>
>>
>> Vào 05:29:43 UTC+7 Thứ hai, ngày 05 tháng ba năm 2012, Massimo Di Pierro 
>> đã viết:
>>>
>>> Same as 1.99.5 and 1.99.6 but should solve all the outstanding 
>>> compatibility issues.
>>>
>>> Massimo
>>>
>>

[web2py] Re: web2py file location

2012-03-27 Thread Ron McOuat
Have you done a right click on web2py.app and then Show Contents from the pop 
up menu. You should see a Contents directory which you can now explore.


<    1   2