[web2py] Re: raspberry pi

2012-03-15 Thread Andrew

Thanks antonio, I have never heard of this.  I will suggest this to my
kid's school

On Mar 13, 11:36 pm, Bruno Rocha  wrote:
> I see no problem to install Python and web2py on this, You just need to
> boot from an SD card with python and web2py on it.
>
> 2012/3/13 António Ramos 
>
> > it would be nice to be able to install web2py in raspberry pi
>
> >http://www.raspberrypi.org/
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]


[web2py] Re: pg8000: ProgrammingError: ('ERROR', '42P07', 'relation "auth_user" already exists')

2012-03-15 Thread Ron McOuat

I believe that any time the database connection string is changed then the 
hash in front of the .table file names changes in the databases directory. 
I noticed this just trying to change the database password because I wanted 
it different at another physical location of the application I work on. 
However all the tables in the database still exist from the original 
driver. The fake_migrate option should help when the tables in the database 
already exist but the .table files in the databases directory don't.

Ron


[web2py] No DB queries in web2py shell?

2012-03-15 Thread Stefan Scholl
web2py 1.99.7 for Windows.

Example app, inserted 1 person and 1 dog.

In the shell:

dogs = db().select(db.dog.ALL)


Nothing there. And "dogs" isn't defined.





[web2py] Re: web2py recipe book

2012-03-15 Thread Johan
Hi,

The ebook is now available and can be downloaded.

Johan

On Monday, March 12, 2012 8:18:43 AM UTC+1, Massimo Di Pierro wrote:
>
> The web2py recipes book is finally out:
>
>
> http://www.packtpub.com/web2py-application-development-recipes-to-master-python-web-framework-cookbook/book
>
> Congratulations to all those who contributed.
>
> Massimo
>


Re: [web2py] Re: autocompleteWidget improvement

2012-03-15 Thread Manuele Pesenti

Il 14/03/2012 23:25, Alan Etkin ha scritto:

I bet if you declared the widget custom class in the model, you wouldn
have this request object issue. Is there any particular need to use a
module instead of normal model code?
I'll try to cut and paste the widget definition from the module to the 
model as soon as possible and I'll tell you if the problem persists.


Thank you very mutch for your replay

Manuele


Re: [web2py] No DB queries in web2py shell?

2012-03-15 Thread Michele Comitini
did you do?

python web2py.py -M -S 

mic

Il 15 marzo 2012 09:12, Stefan Scholl  ha scritto:
> web2py 1.99.7 for Windows.
>
> Example app, inserted 1 person and 1 dog.
>
> In the shell:
>
>        dogs = db().select(db.dog.ALL)
>
>
> Nothing there. And "dogs" isn't defined.
>
>
>


[web2py] How to check the extension of file from the controller

2012-03-15 Thread Sanjeet Kumar
I have the upload field in table i want to check the file extension from 
the controller during the upload i am using :-

SQLFORM.factory(db.emp_detail)
if form.accepts(request.vars, session):
 img = form.vars.image
if file.extension == 'something':
 update query


Re: [web2py] Re: {{pass}} problems

2012-03-15 Thread Wikus van de Merwe
So you are saying the problem is now solved? Can you share with us what was 
the cause of this strange "missing pass in view" error?


[web2py] Offtopic: What is the most important thing that every software developer should know?

2012-03-15 Thread António Ramos
just forwarding

-- Forwarded message --
From: Nikhil Marathe 
Date: 2012/1/23
Subject: [nodejs] Offtopic: What is the most important thing that every
software developer should know?
To: nod...@googlegroups.com


Hi,

I would really appreciate it if you could take 2 minutes to fill out
this survey (1 text field and 1 optional text area, that's it!).
It is strictly for research purposes, and once I have enough results I
will publish them.

https://docs.google.com/spreadsheet/viewform?formkey=dENscnc3U2oxU3RyLXZVUHZIVGZTM2c6MQ

Thanks,
Nikhil

--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


[web2py] Re: Download file dialog to local PC when running from PythonAnywhere

2012-03-15 Thread Wikus van de Merwe
It looks to me that when you say "download" you mean "upload". If a user 
sends a file to a server, she uploads it.
I recommend you to read about upload field in the book:
http://web2py.com/books/default/chapter/29/7#SQLFORM-and-uploads



[web2py] Generate the render the html file in to doc file

2012-03-15 Thread Sanjeet Kumar
How can i render the html file in to the doc file

[web2py] Web2py support the netherlands

2012-03-15 Thread Rene Dohmen
Hi Web2py users,

I would like to announce web2py support for the Netherlands by Formatics.nl
.
We did a couple of sites with web2py and I personally think it's the best
invention since sliced bread ;-)

Can we be included on the web2py professional support page?
(I don't know if this is the correct place to request it)

Kind Regards,

Rene Dohmen


[web2py] Gluino status

2012-03-15 Thread Voltron
Full circle, well almost. My largest application was built with
web2py( some years back). Hi Massimo, what is the status on Gluino?
Would you say its stable enough for production? Is the MongoDB/DAL
support coming along?

Thanks


[web2py] Re: How to check the extension of file from the controller

2012-03-15 Thread Alan Etkin
To access the extension in the request you can use request.extension:

"...
request.extension: the extension of the requested action. It defaults
to
"html". If the controller function returns a dictionary and does not
specify
a view, this is used to determine the extension of the view file that
will
render the dictionary (parsed from the request.env.path_info).
..."

web2py book, 4.7

On Mar 15, 7:18 am, Sanjeet Kumar  wrote:
> I have the upload field in table i want to check the file extension from
> the controller during the upload i am using :-
>
> SQLFORM.factory(db.emp_detail)
> if form.accepts(request.vars, session):
>          img = form.vars.image
> if file.extension == 'something':
>          update query


[web2py] Re: Generate the render the html file in to doc file

2012-03-15 Thread Alan Etkin
If you want to render html output as .rtf (a similar type of document
that will work in old ms-word versions) check the book at 10.3.2
(PyRTF)

On Mar 15, 8:15 am, Sanjeet Kumar  wrote:
> How can i render the html file in to the doc file


[web2py] Re: bug in unicode decoding/encoding upload file?

2012-03-15 Thread Wikus van de Merwe
The decoder detection seems to focus on 2-4 byte encoding. Many times you 
will get a text in iso-8859-1
or cp-1250 or other 1 byte encoding and none of this is covered there. I 
might not make sense to extend the
decoder if it is not meant for 1 byte encoding. In that case adding the 
alternative decoder to contrib would be
a better idea.

BTW, you the best way to do the conversion is probably customization of the 
file store method.
In your model you do:
Field("my_file", "upload", autodelete=True, custom_store=store_my_file)

And then implement store_my_file based on the original Field.store method:
http://code.google.com/p/web2py/source/browse/gluon/dal.py#7334




Re: [web2py] Re: web2py ported to bottle, flask, pyramid, tornado, wsgiref

2012-03-15 Thread Martín Mulone
Yes sorry I delete some old thread in my blog the last month. But yes I
worked integrating web2py dal in bottle some months ago, here
https://bitbucket.org/mulonemartin/bottle-web2pydal/overview now I think is
obsolete, go into gluino instead. Perhaps need a lot of test, some time
ago, I remember I have trouble with wsgi and bottle in the way of the
example in gluino perhaps adapating to use install like this:

from bottle import route, view, run, debug, install
from bottle_dal import DALPlugin, Field

def define_tables(db):
"""My tables definitions here"""
db.define_table('person',Field('name','string'))

install(DALPlugin('sqlite://storage.sqlite',
  define_tables = lambda db: define_tables(db)))

@route('/')
def index(db):
""" Index Example """

if db(db.person.id>0).count()==0:
db.person.insert(name='James')
db.person.insert(name='Michael')
db.person.insert(name='Steve')
db.person.insert(name='Robert')
db.commit()

persons = db(db.person.id>0).select()

return dict(persons=persons.json())

if __name__ == '__main__':
debug(True)
run(host='localhost', port=8080)




2012/3/15 Andrew 

> When would I choose something like Bottle over using straight web2py?
> What's the difference from bottle with gluino, and web2py?
>
> Martin M, you used to have bottle on your blog site. I went to have a
> look but it's gone.
>
> So many choices !?
>
> Thanks
>
> Andrew
>
>
> On Mar 14, 4:22 pm, Bruno Rocha  wrote:
> > Amazing! just installed using easy_install on windows!
> >
> > *c:\Python27\Scripts>easy_install.exe gluino*
> > Searching for gluino
> > Readinghttp://pypi.python.org/simple/gluino/
> > Readinghttps://github.com/mdipierro/gluino
> > Best match: Gluino 0.1
> > Downloadinghttp://
> pypi.python.org/packages/source/G/Gluino/Gluino-0.1.tar.gz#md
> > 5=
> > 89d645322f6a0af56f80ba8df6f84e34
> > Processing Gluino-0.1.tar.gz
> > Running Gluino-0.1\setup.py -q bdist_egg --dist-dir
> > c:\users\rochac~1\appdata\lo
> > cal\temp\easy_install-qcludi\Gluino-0.1\egg-dist-tmp-m_pspc
> > zip_safe flag not set; analyzing archive contents...
> > gluino.custom_import: module references __file__
> > Adding gluino 0.1 to easy-install.pth file
> >
> > Installed c:\python27\lib\site-packages\gluino-0.1-py2.7.egg
> > Processing dependencies for gluino
> > Finished processing dependencies for gluino
> >
> > c:\Python27\Scripts>python
> > Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
> > on win
> > 32
> > Type "help", "copyright", "credits" or "license" for more information.
> > *>>> from gluino import **
> > No handlers could be found for logger "web2py"
> >
> >
> >
> >
> >
> >
> >
> >
>



-- 
 http://www.tecnodoc.com.ar


[web2py] Re: GAE email 'reply_to'

2012-03-15 Thread David Manns
Thanks,

I added, issue 719.


[web2py] Re: Web2py support the netherlands

2012-03-15 Thread Massimo Di Pierro
Of course. Please email me personally your contact info. Also, sign up at 
experts4solutions.com

Massimo

On Wednesday, 14 March 2012 20:42:23 UTC-5, acidjunk wrote:
>
> Hi Web2py users, 
>
> I would like to announce web2py support for the Netherlands by 
> Formatics.nl .
> We did a couple of sites with web2py and I personally think it's the best 
> invention since sliced bread ;-)
>
> Can we be included on the web2py professional support page?
> (I don't know if this is the correct place to request it)
>
> Kind Regards,
>
> Rene Dohmen
>
>
>
>

Re: [web2py] Re: Generate the render the html file in to doc file

2012-03-15 Thread Sanjeet Kumar
ok thanks Allan

On Thu, Mar 15, 2012 at 5:13 PM, Alan Etkin  wrote:

> If you want to render html output as .rtf (a similar type of document
> that will work in old ms-word versions) check the book at 10.3.2
> (PyRTF)
>
> On Mar 15, 8:15 am, Sanjeet Kumar  wrote:
> > How can i render the html file in to the doc file
>


[web2py] Re: subdomain routes for websites

2012-03-15 Thread Wikus van de Merwe

>
> I'm trying to use a single controller for all my functions, including the 
> "web/site" controller/function.


OK, but why? While it might be possible to achieve what you want to do this 
way too, it is definitely not going to be easier.


[web2py] Re: Gluino status

2012-03-15 Thread Massimo Di Pierro
Hello Voltron,  we missed you.

Gluino needs testing. Moreover the API may still change a little. The main 
issue is that every framework has different request, session and response 
objects. Right now it only tries to normalize request via 
wrapper.get_variables(request) and ignores session and response. It assume 
for every framework you use the native API. Perhaps we will find that we 
want to provide a more abstract request, session and response objects.

I am skeptical to do this now because the larger python community is 
discussing where these should be a standard.

Massimo

On Thursday, 15 March 2012 05:30:51 UTC-5, Voltron wrote:
>
> Full circle, well almost. My largest application was built with 
> web2py( some years back). Hi Massimo, what is the status on Gluino? 
> Would you say its stable enough for production? Is the MongoDB/DAL 
> support coming along? 
>
> Thanks



[web2py] Re: web2py ported to bottle, flask, pyramid, tornado, wsgiref

2012-03-15 Thread Massimo Di Pierro
I make some comments about this here:
https://github.com/mdipierro/gluino

If you like web2py I strongly recommend straight web2py. You lose lots of 
features and you loose the promise of backward compatibility using other 
frameworks. You would also be using something new and poorly tested. I can 
also tell you each one of those frameworks done something weird that first 
of all you have to face. Anyway, if you have simple app with lots of 
models, bottle+gluino may be faster than web2py because models are executed 
only ones and not at every request. It is hard to compile apples to apples 
since web2py has conditional models.

On Thursday, 15 March 2012 01:50:05 UTC-5, Andrew wrote:
>
> When would I choose something like Bottle over using straight web2py? 
> What's the difference from bottle with gluino, and web2py? 
>
> Martin M, you used to have bottle on your blog site. I went to have a 
> look but it's gone. 
>
> So many choices !? 
>
> Thanks 
>
> Andrew 
>
>
> On Mar 14, 4:22 pm, Bruno Rocha  wrote: 
> > Amazing! just installed using easy_install on windows! 
> > 
> > *c:\Python27\Scripts>easy_install.exe gluino* 
> > Searching for gluino 
> > Readinghttp://pypi.python.org/simple/gluino/ 
> > Readinghttps://github.com/mdipierro/gluino 
> > Best match: Gluino 0.1 
> > Downloadinghttp://
> pypi.python.org/packages/source/G/Gluino/Gluino-0.1.tar.gz#md 
> > 5= 
> > 89d645322f6a0af56f80ba8df6f84e34 
> > Processing Gluino-0.1.tar.gz 
> > Running Gluino-0.1\setup.py -q bdist_egg --dist-dir 
> > c:\users\rochac~1\appdata\lo 
> > cal\temp\easy_install-qcludi\Gluino-0.1\egg-dist-tmp-m_pspc 
> > zip_safe flag not set; analyzing archive contents... 
> > gluino.custom_import: module references __file__ 
> > Adding gluino 0.1 to easy-install.pth file 
> > 
> > Installed c:\python27\lib\site-packages\gluino-0.1-py2.7.egg 
> > Processing dependencies for gluino 
> > Finished processing dependencies for gluino 
> > 
> > c:\Python27\Scripts>python 
> > Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit 
> (Intel)] 
> > on win 
> > 32 
> > Type "help", "copyright", "credits" or "license" for more information. 
> > *>>> from gluino import ** 
> > No handlers could be found for logger "web2py" 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >



[web2py] Re: Web2py cookbook

2012-03-15 Thread Simon Ashley
Its available now on packtpub

On Monday, March 12, 2012 8:27:44 PM UTC+10, bussiere adrien wrote:
>
> Does anyone know when the web2py cookbook will be available please ?
>
> Regards
> Bussiere
>
> "Les nouvelles technologies offrent pleins de nouvelles possibilités,
> pleins de possibilités d'erreurs surtout en fait."
> insurance.aes256 : http://goo.gl/gHyAY
>
>

Re: [web2py] Modules on Google App Engine

2012-03-15 Thread Udi Milo
I found the problem (which leads to a new problem).
my module was using "import requests"
requests is http://docs.python-requests.org/en/v0.10.7/index.html that I 
have installed on my machine.
I guess I need to tell web2py to install it when it deploys.

do you know how I do that? and if its not possible, how to overcome this 
issue?

On Wednesday, March 14, 2012 11:32:20 PM UTC-4, rochacbruno wrote:
>
> I guess your module is trying to do something denied in GAE, some python 
> std modules are not available on GAE, and also you cannot access filesystem.
>
> Another common problem is incompatibility with Python2.5
>
> Take a look at LOG tab at your google app engine admin page, may be the 
> traceback is there.
>
> On Thu, Mar 15, 2012 at 12:19 AM, Udi Milo  wrote:
>
>> The thing is that locally, it works.
>> only when I deploy to GAE it is missing...
>>
>> which files do you recommend I look into to try and find the reason for 
>> this weird problem?
>>
>>
>> On Tuesday, March 13, 2012 5:32:52 PM UTC-4, rochacbruno wrote:
>>>
>>> Maybe you have a syntax error or an error with imports inside the api 
>>> module, the web2py custom importer does not shows complete traceback for 
>>> that cases.
>>>
>>> On Tue, Mar 13, 2012 at 10:48 AM, Udi Milo  wrote:
>>>
 Hi all,

 I've added a new api.py file to the /modules directory.
 I've also added a call from my default.py "from api import Api"

 working locally, everything is fine.
 when deploying to GAE, I get 
  No module named api

 can anyone suggest an answer to my problem?

>>>
>>>
>>>
>>> -- 
>>>
>>> Bruno Rocha
>>> [http://rochacbruno.com.br]
>>>
>>>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>

Re: [web2py] Modules on Google App Engine

2012-03-15 Thread Bruno Rocha
It is not possible on gae. You have to change your app to use urllib or
fetch

http://zerp.ly/rochacbruno
Em 15/03/2012 09:56, "Udi Milo"  escreveu:

> I found the problem (which leads to a new problem).
> my module was using "import requests"
> requests is http://docs.python-requests.org/en/v0.10.7/index.html that I
> have installed on my machine.
> I guess I need to tell web2py to install it when it deploys.
>
> do you know how I do that? and if its not possible, how to overcome this
> issue?
>
> On Wednesday, March 14, 2012 11:32:20 PM UTC-4, rochacbruno wrote:
>>
>> I guess your module is trying to do something denied in GAE, some python
>> std modules are not available on GAE, and also you cannot access filesystem.
>>
>> Another common problem is incompatibility with Python2.5
>>
>> Take a look at LOG tab at your google app engine admin page, may be the
>> traceback is there.
>>
>> On Thu, Mar 15, 2012 at 12:19 AM, Udi Milo  wrote:
>>
>>> The thing is that locally, it works.
>>> only when I deploy to GAE it is missing...
>>>
>>> which files do you recommend I look into to try and find the reason for
>>> this weird problem?
>>>
>>>
>>> On Tuesday, March 13, 2012 5:32:52 PM UTC-4, rochacbruno wrote:

 Maybe you have a syntax error or an error with imports inside the api
 module, the web2py custom importer does not shows complete traceback for
 that cases.

 On Tue, Mar 13, 2012 at 10:48 AM, Udi Milo  wrote:

> Hi all,
>
> I've added a new api.py file to the /modules directory.
> I've also added a call from my default.py "from api import Api"
>
> working locally, everything is fine.
> when deploying to GAE, I get
>  No module named api
>
> can anyone suggest an answer to my problem?
>



 --

 Bruno Rocha
 [http://rochacbruno.com.br]


>>
>>
>> --
>>
>> Bruno Rocha
>> [http://rochacbruno.com.br]
>>
>>


[web2py] Re: How to check the extension of file from the controller

2012-03-15 Thread Anthony
request.vars.image.filename.split('.')[-1]

or

import os
os.path.splitext(request.vars.image.filename)[1][1:]

Anthony

On Thursday, March 15, 2012 6:18:10 AM UTC-4, Sanjeet Kumar wrote:
>
> I have the upload field in table i want to check the file extension from 
> the controller during the upload i am using :-
>
> SQLFORM.factory(db.emp_detail)
> if form.accepts(request.vars, session):
>  img = form.vars.image
> if file.extension == 'something':
>  update query
>


[web2py] Re: No DB queries in web2py shell?

2012-03-15 Thread Anthony
Did you do the insert in the shell also? If so, when you do inserts, 
updates, deletes in the shell, you have to follow with db.commit() in order 
to commit the transaction. This is not necessary in application code 
because the framework does that automatically at the end of a request. I 
have also found that in some cases, the web-based shell in admin does not 
work for database transactions, so you may need to use a regular OS shell.

Anthony

On Thursday, March 15, 2012 4:12:10 AM UTC-4, Stefan Scholl wrote:
>
> web2py 1.99.7 for Windows.
>
> Example app, inserted 1 person and 1 dog.
>
> In the shell:
>
> dogs = db().select(db.dog.ALL)
>
>
> Nothing there. And "dogs" isn't defined.
>
>

[web2py] Plugin Sortable Table

2012-03-15 Thread Neveen Adel
Dears,

Am using  Sortable Table plugin but a lot of time  the 'search' and
'entries' fields are not displaying in the page and also the paging
not working (All records are displayed)

{{=plugin_datatable(rows,_class='datatable',_id='woId',truncate=100)}}

Any Advice??


Thanks in Advance

Neveen Adel


Re: [web2py] Re: Is there any way to calculate distance between two points(lat and long) inside of sqlite?

2012-03-15 Thread Wikus van de Merwe
You wrote you know how to do it with mysql. DAL doesn't care what db you 
use. Trigonometric functions are not supported by DAL anyway.
So I recommend you to apply your mysql solution using raw sql queries, 
suggested already by Alan:
http://web2py.com/books/default/chapter/29/6#Raw-sql


[web2py] Where is base.css referenced?

2012-03-15 Thread Edward Shave
I feel I must be missing something obvious, but despite the references to 
base.css in the book and the comments in the file itself, I can't find 
where it is referenced by the welcome app?

[web2py] Re: Where is base.css referenced?

2012-03-15 Thread Anthony
There is no longer a base.css -- it is now web2py.css.

Anthony

On Thursday, March 15, 2012 11:44:07 AM UTC-4, Edward Shave wrote:
>
> I feel I must be missing something obvious, but despite the references to 
> base.css in the book and the comments in the file itself, I can't find 
> where it is referenced by the welcome app?



[web2py] Re: Where is base.css referenced?

2012-03-15 Thread Edward Shave
Oh, I went straight to base.css after reading the following in the the 
review section of the book...

*Configuring the layout*

*You can configure the default layout by editing "views/layout.html" but 
you can also configure it without editing the HTML. In fact, the 
"static/base.css" stylesheet is well documented and described in Chapter 5. 
You can change color, columns, size, borders and background without editing 
the HTML. If you want to edit the menu, the title or the subtitle, you can 
do so in any model file. The scaffolding app, sets default values of these 
parameters in the file "models/menu.py":*
Thanks for putting me right,
Ed

On Thursday, 15 March 2012 15:50:49 UTC, Anthony wrote:
>
> There is no longer a base.css -- it is now web2py.css.
>
> Anthony
>
> On Thursday, March 15, 2012 11:44:07 AM UTC-4, Edward Shave wrote:
>>
>> I feel I must be missing something obvious, but despite the references to 
>> base.css in the book and the comments in the file itself, I can't find 
>> where it is referenced by the welcome app?
>
>
On Thursday, 15 March 2012 15:50:49 UTC, Anthony wrote:
>
> There is no longer a base.css -- it is now web2py.css.
>
> Anthony
>
> On Thursday, March 15, 2012 11:44:07 AM UTC-4, Edward Shave wrote:
>>
>> I feel I must be missing something obvious, but despite the references to 
>> base.css in the book and the comments in the file itself, I can't find 
>> where it is referenced by the welcome app?
>
>

[web2py] Re: How to check the extension of file from the controller

2012-03-15 Thread Alan Etkin
Anthony's answer is the right one, mine is for retrieving the
extension of the url requested

On 15 mar, 10:40, Anthony  wrote:
> request.vars.image.filename.split('.')[-1]
>
> or
>
> import os
> os.path.splitext(request.vars.image.filename)[1][1:]
>
> Anthony
>
>
>
>
>
>
>
> On Thursday, March 15, 2012 6:18:10 AM UTC-4, Sanjeet Kumar wrote:
>
> > I have the upload field in table i want to check the file extension from
> > the controller during the upload i am using :-
>
> > SQLFORM.factory(db.emp_detail)
> > if form.accepts(request.vars, session):
> >          img = form.vars.image
> > if file.extension == 'something':
> >          update query


Re: [web2py] Re: web2py recipe book

2012-03-15 Thread Bruce Wade
Cool just bought it. I am interested to see how some things are implemented
in the book which I have already implemented in my project.

On Thu, Mar 15, 2012 at 1:14 AM, Johan  wrote:

> Hi,
>
> The ebook is now available and can be downloaded.
>
> Johan
>
>
> On Monday, March 12, 2012 8:18:43 AM UTC+1, Massimo Di Pierro wrote:
>>
>> The web2py recipes book is finally out:
>>
>> http://www.packtpub.com/**web2py-application-**
>> development-recipes-to-master-**python-web-framework-cookbook/**book
>>
>> Congratulations to all those who contributed.
>>
>> Massimo
>>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] unable to save file with online code editor

2012-03-15 Thread Alan Etkin
When I click in the diskette for saving the file in the source code
editor, the file is not saved, and a js error message is sent to the
debugging feature in the browser:

"area is not defined"

The file that causes the error is ajax_editor.js, at line 33

Here is the highlighted code:

...
function doClickSave() {
try {
var data = eamy.instances[0].getText();
} catch(e) {
var data = area.textarea.value;
}
...

web2py: Version 1.99.7 (2012-03-13 21:35:53) dev
browser: Firefox 10.0


[web2py] Re: web2py recipe book

2012-03-15 Thread Francois
If one of you got the ebook in PDF format, can you confirm if it
possible to annotate it (write comments and put bookmarks) ?

Thanks,

-Francois.

On Mar 15, 12:46 pm, Bruce Wade  wrote:
> Cool just bought it. I am interested to see how some things are implemented
> in the book which I have already implemented in my project.
>
>
>
>
>
> On Thu, Mar 15, 2012 at 1:14 AM, Johan  wrote:
> > Hi,
>
> > The ebook is now available and can be downloaded.
>
> > Johan
>
> > On Monday, March 12, 2012 8:18:43 AM UTC+1, Massimo Di Pierro wrote:
>
> >> The web2py recipes book is finally out:
>
> >>http://www.packtpub.com/**web2py-application-**
> >> development-recipes-to-master-**python-web-framework-cookbook/**book
>
> >> Congratulations to all those who contributed.
>
> >> Massimo
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com-
>  Hide quoted text -
>
> - Show quoted text -


Re: [web2py] Re: web2py recipe book

2012-03-15 Thread Bruce Wade
You can add bookmarks, I have no idea how to write comments using Evince on
Ubuntu though.

On Thu, Mar 15, 2012 at 10:08 AM, Francois  wrote:

> If one of you got the ebook in PDF format, can you confirm if it
> possible to annotate it (write comments and put bookmarks) ?
>
> Thanks,
>
> -Francois.
>
> On Mar 15, 12:46 pm, Bruce Wade  wrote:
> > Cool just bought it. I am interested to see how some things are
> implemented
> > in the book which I have already implemented in my project.
> >
> >
> >
> >
> >
> > On Thu, Mar 15, 2012 at 1:14 AM, Johan  wrote:
> > > Hi,
> >
> > > The ebook is now available and can be downloaded.
> >
> > > Johan
> >
> > > On Monday, March 12, 2012 8:18:43 AM UTC+1, Massimo Di Pierro wrote:
> >
> > >> The web2py recipes book is finally out:
> >
> > >>http://www.packtpub.com/**web2py-application-**
> > >> development-recipes-to-master-**python-web-framework-cookbook/**book<
> http://www.packtpub.com/web2py-application-development-recipes-to-mas...>
> >
> > >> Congratulations to all those who contributed.
> >
> > >> Massimo
> >
> > --
> > --
> > Regards,
> > Bruce Wadehttp://
> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com-Hide
>  quoted text -
> >
> > - Show quoted text -
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Cookbook found bug with web2py

2012-03-15 Thread Alan Etkin
How are you running the code? Did you install the app from the apps
folder?

On Mar 15, 2:29 pm, Bruce Wade  wrote:
> Chapter 10: Creating PDF reports
>
> Error:
>
> Traceback (most recent call last):
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py",
> line 204, in restricted
>     exec ccode in environment
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/views/generic.pdf",
> line 9, in 
>     pass
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
> line 63, in pdf_from_html
>     return pyfpdf_from_html(html)
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
> line 55, in pyfpdf_from_html
>     pdf.write_html(html,image_map=image_map)
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/html.py",
> line 388, in write_html
>     h2p.feed(text)
>   File "/usr/lib/python2.7/HTMLParser.py", line 109, in feed
>     self.goahead(0)
>   File "/usr/lib/python2.7/HTMLParser.py", line 151, in goahead
>     k = self.parse_starttag(i)
>   File "/usr/lib/python2.7/HTMLParser.py", line 272, in parse_starttag
>     self.handle_startendtag(tag, attrs)
>   File "/usr/lib/python2.7/HTMLParser.py", line 334, in handle_startendtag
>     self.handle_starttag(tag, attrs)
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/html.py",
> line 262, in handle_starttag
>     x, y, w, h, link=self.href)
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/fpdf.py",
> line 807, in image
>     info=self._parsepng(name)
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/fpdf.py",
> line 1296, in _parsepng
>     f = urllib.urlopen(name)
>   File "/usr/lib/python2.7/urllib.py", line 84, in urlopen
>     return opener.open(url)
>   File "/usr/lib/python2.7/urllib.py", line 205, in open
>     return getattr(self, name)(url)
>   File "/usr/lib/python2.7/urllib.py", line 331, in open_http
>     h = httplib.HTTP(host)
>   File "/usr/lib/python2.7/httplib.py", line 1061, in __init__
>     self._setup(self._connection_class(host, port, strict))
>   File "/usr/lib/python2.7/httplib.py", line 693, in __init__
>     self._set_hostport(host, port)
>   File "/usr/lib/python2.7/httplib.py", line 718, in _set_hostport
>     raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
> InvalidURL: nonnumeric port: ''
>
> I also found this argument list to look very strange, look at the host
> string, plus port is NoneFunction argument list
>
> (self=, host='127.0.0.1:8000http:',
> port=None)
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


Re: [web2py] Re: Cookbook found bug with web2py

2012-03-15 Thread Bruce Wade
Install what app? I am following the instructions to create a PDF.

On Thu, Mar 15, 2012 at 10:47 AM, Alan Etkin  wrote:

> How are you running the code? Did you install the app from the apps
> folder?
>
> On Mar 15, 2:29 pm, Bruce Wade  wrote:
> > Chapter 10: Creating PDF reports
> >
> > Error:
> >
> > Traceback (most recent call last):
> >   File
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py",
> > line 204, in restricted
> > exec ccode in environment
> >   File
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/views/generic.pdf",
> > line 9, in 
> > pass
> >   File
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
> > line 63, in pdf_from_html
> > return pyfpdf_from_html(html)
> >   File
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
> > line 55, in pyfpdf_from_html
> > pdf.write_html(html,image_map=image_map)
> >   File
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/html.py",
> > line 388, in write_html
> > h2p.feed(text)
> >   File "/usr/lib/python2.7/HTMLParser.py", line 109, in feed
> > self.goahead(0)
> >   File "/usr/lib/python2.7/HTMLParser.py", line 151, in goahead
> > k = self.parse_starttag(i)
> >   File "/usr/lib/python2.7/HTMLParser.py", line 272, in parse_starttag
> > self.handle_startendtag(tag, attrs)
> >   File "/usr/lib/python2.7/HTMLParser.py", line 334, in
> handle_startendtag
> > self.handle_starttag(tag, attrs)
> >   File
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/html.py",
> > line 262, in handle_starttag
> > x, y, w, h, link=self.href)
> >   File
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/fpdf.py",
> > line 807, in image
> > info=self._parsepng(name)
> >   File
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/fpdf.py",
> > line 1296, in _parsepng
> > f = urllib.urlopen(name)
> >   File "/usr/lib/python2.7/urllib.py", line 84, in urlopen
> > return opener.open(url)
> >   File "/usr/lib/python2.7/urllib.py", line 205, in open
> > return getattr(self, name)(url)
> >   File "/usr/lib/python2.7/urllib.py", line 331, in open_http
> > h = httplib.HTTP(host)
> >   File "/usr/lib/python2.7/httplib.py", line 1061, in __init__
> > self._setup(self._connection_class(host, port, strict))
> >   File "/usr/lib/python2.7/httplib.py", line 693, in __init__
> > self._set_hostport(host, port)
> >   File "/usr/lib/python2.7/httplib.py", line 718, in _set_hostport
> > raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
> > InvalidURL: nonnumeric port: ''
> >
> > I also found this argument list to look very strange, look at the host
> > string, plus port is NoneFunction argument list
> >
> > (self=, host='127.0.0.1:8000http:',
> > port=None)
> >
> > --
> > --
> > Regards,
> > Bruce Wadehttp://
> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: Cookbook found bug with web2py

2012-03-15 Thread Bruce Wade
Fresh blank version of web2py, in default controller:

def report():
import os
response.title = "web2py sample report"

# include a chart from google chart
url = "
http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=500x200&ch1=Hello|World&.png
"
chart = IMG(_src=url, _width="250", _height="100")

# create a small table with some data:
rows = [THEAD(TR(TH("Key", _width="70%"),
TH("Value", _width="30%"))),
TBODY(TR(TD("Hello"), TD("60")),
TR(TD("World"), TD("40")))]

table = TABLE(*rows, _border="0", _align="center", _width="50%")

if request.extension == "pdf":
from gluon.contrib.pyfpdf import FPDF, HTMLMixin

# create a custom class with the required functionalities
class MyFPDF(FPDF, HTMLMixin):
def header(self):
"hook to draw custom page header (logo and title)"

# remember to copy logo_pb.png to static/images (and remove
alpha channel)
#logo = os.path.join(request.folder, "static", "images",
"logo_pb.png")
#self.image(logo, 10, 8, 33)
self.set_font("Arial", "B", 15)
self.cell(65)   # padding
self.cell(60, 10, response.title, 1, 0, 'C')
self.ln(20)

def footer(self):
"hook to draw custom page footer (printing page numbers)"
self.set_y(-15)
self.set_font('Arial', 'I', 8)
txt = 'Page %s of %s' % (self.page_no(),
self.alias_nb_pages())
self.cell(0, 10, txt, 0, 0, 'C')
pdf = MyFPDF()

# create a page and serialize/render HTML objects
pdf.add_page()
pdf.write_html(table.xml())
#pdf.write_html(CENTER(chart).xml())

# prepare PDF to download:
response.headers['Content-Type'] = 'application/pdf'
return pdf.output(dest='S')

# else normal html view
return dict(chart=chart, table=table)

I thought it was the logo so I commented it out, but still the exact same
error.

Looks like it is failing here:
def _parsepng(self, name):
#Extract info from a PNG file
if name.startswith("http://";) or name.startswith("https://";):
import urllib
f = urllib.urlopen(name)

Which I am not sure why considering there is no PNG in my code so I guess
it is doing something behind the scene. I even commented out the chart line
so there should be no image issues.

On Thu, Mar 15, 2012 at 10:49 AM, Bruce Wade  wrote:

> Install what app? I am following the instructions to create a PDF.
>
>
> On Thu, Mar 15, 2012 at 10:47 AM, Alan Etkin  wrote:
>
>> How are you running the code? Did you install the app from the apps
>> folder?
>>
>> On Mar 15, 2:29 pm, Bruce Wade  wrote:
>> > Chapter 10: Creating PDF reports
>> >
>> > Error:
>> >
>> > Traceback (most recent call last):
>> >   File
>> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py",
>> > line 204, in restricted
>> > exec ccode in environment
>> >   File
>> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/views/generic.pdf",
>> > line 9, in 
>> > pass
>> >   File
>> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
>> > line 63, in pdf_from_html
>> > return pyfpdf_from_html(html)
>> >   File
>> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
>> > line 55, in pyfpdf_from_html
>> > pdf.write_html(html,image_map=image_map)
>> >   File
>> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/html.py",
>> > line 388, in write_html
>> > h2p.feed(text)
>> >   File "/usr/lib/python2.7/HTMLParser.py", line 109, in feed
>> > self.goahead(0)
>> >   File "/usr/lib/python2.7/HTMLParser.py", line 151, in goahead
>> > k = self.parse_starttag(i)
>> >   File "/usr/lib/python2.7/HTMLParser.py", line 272, in parse_starttag
>> > self.handle_startendtag(tag, attrs)
>> >   File "/usr/lib/python2.7/HTMLParser.py", line 334, in
>> handle_startendtag
>> > self.handle_starttag(tag, attrs)
>> >   File
>> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/html.py",
>> > line 262, in handle_starttag
>> > x, y, w, h, link=self.href)
>> >   File
>> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/fpdf.py",
>> > line 807, in image
>> > info=self._parsepng(name)
>> >   File
>> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/fpdf.py",
>> > line 1296, in _parsepng
>> > f = urllib.urlopen(name)
>> >   File "/usr/lib/python2.7/urllib.py", line 84, in urlopen
>> > return opener.open(url)
>> >   File "/usr/lib/python2.7/urllib.py", line 205, in open
>> > return getattr(self, name)(url)
>> >   File "/usr/lib/python2.7/urllib.py", line 331, in open_http
>> > h = h

[web2py] Cookbook - No indentation ??

2012-03-15 Thread Marcello
Hello,

I just bought my web2py Application Development Cookbook from Amazon 
(Kindle version)...

I noticed that all python code is not indented

Is it ?

Ebook or PDF has the same problem ??


Thanks,
Marcello


Re: [web2py] Cookbook - No indentation ??

2012-03-15 Thread Bruce Wade
The PDF has indentation but it is off and not consistent in some parts.

On Thu, Mar 15, 2012 at 11:04 AM, Marcello  wrote:

> Hello,
>
> I just bought my web2py Application Development Cookbook from Amazon
> (Kindle version)..
>
> I noticed that all python code is not indented
>
> Is it ?
>
> Ebook or PDF has the same problem ??
>
>
> Thanks,
> Marcello
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Cookbook found bug with web2py

2012-03-15 Thread Alan Etkin
I should check the code in the book, but I used a controller example
that should be available in the book's support files at
http://www.packtpub.com/support and it worked for my environment:

Python 2.6.5
Mandriva GNU/Linux 2010
web2py (last mercurial version)

A complete working installer can be downloaded from the same url (in
the apps folder)

On Mar 15, 2:54 pm, Bruce Wade  wrote:
> Fresh blank version of web2py, in default controller:
>
> def report():
>     import os
>     response.title = "web2py sample report"
>
>     # include a chart from google chart
>     url = 
> "http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=500x200&ch1...World&.png
> "
>     chart = IMG(_src=url, _width="250", _height="100")
>
>     # create a small table with some data:
>     rows = [THEAD(TR(TH("Key", _width="70%"),
>         TH("Value", _width="30%"))),
>         TBODY(TR(TD("Hello"), TD("60")),
>         TR(TD("World"), TD("40")))]
>
>     table = TABLE(*rows, _border="0", _align="center", _width="50%")
>
>     if request.extension == "pdf":
>         from gluon.contrib.pyfpdf import FPDF, HTMLMixin
>
>         # create a custom class with the required functionalities
>         class MyFPDF(FPDF, HTMLMixin):
>             def header(self):
>                 "hook to draw custom page header (logo and title)"
>
>                 # remember to copy logo_pb.png to static/images (and remove
> alpha channel)
>                 #logo = os.path.join(request.folder, "static", "images",
> "logo_pb.png")
>                 #self.image(logo, 10, 8, 33)
>                 self.set_font("Arial", "B", 15)
>                 self.cell(65)   # padding
>                 self.cell(60, 10, response.title, 1, 0, 'C')
>                 self.ln(20)
>
>             def footer(self):
>                 "hook to draw custom page footer (printing page numbers)"
>                 self.set_y(-15)
>                 self.set_font('Arial', 'I', 8)
>                 txt = 'Page %s of %s' % (self.page_no(),
> self.alias_nb_pages())
>                 self.cell(0, 10, txt, 0, 0, 'C')
>                 pdf = MyFPDF()
>
>                 # create a page and serialize/render HTML objects
>                 pdf.add_page()
>                 pdf.write_html(table.xml())
>                 #pdf.write_html(CENTER(chart).xml())
>
>                 # prepare PDF to download:
>                 response.headers['Content-Type'] = 'application/pdf'
>                 return pdf.output(dest='S')
>
>     # else normal html view
>     return dict(chart=chart, table=table)
>
> I thought it was the logo so I commented it out, but still the exact same
> error.
>
> Looks like it is failing here:
> def _parsepng(self, name):
>         #Extract info from a PNG file
>         if name.startswith("http://";) or name.startswith("https://";):
>             import urllib
>             f = urllib.urlopen(name)
>
> Which I am not sure why considering there is no PNG in my code so I guess
> it is doing something behind the scene. I even commented out the chart line
> so there should be no image issues.
>
>
>
>
>
>
>
>
>
> On Thu, Mar 15, 2012 at 10:49 AM, Bruce Wade  wrote:
> > Install what app? I am following the instructions to create a PDF.
>
> > On Thu, Mar 15, 2012 at 10:47 AM, Alan Etkin  wrote:
>
> >> How are you running the code? Did you install the app from the apps
> >> folder?
>
> >> On Mar 15, 2:29 pm, Bruce Wade  wrote:
> >> > Chapter 10: Creating PDF reports
>
> >> > Error:
>
> >> > Traceback (most recent call last):
> >> >   File
> >> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py",
> >> > line 204, in restricted
> >> >     exec ccode in environment
> >> >   File
> >> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/views/generic.pdf",
> >> > line 9, in 
> >> >     pass
> >> >   File
> >> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
> >> > line 63, in pdf_from_html
> >> >     return pyfpdf_from_html(html)
> >> >   File
> >> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
> >> > line 55, in pyfpdf_from_html
> >> >     pdf.write_html(html,image_map=image_map)
> >> >   File
> >> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/html.py",
> >> > line 388, in write_html
> >> >     h2p.feed(text)
> >> >   File "/usr/lib/python2.7/HTMLParser.py", line 109, in feed
> >> >     self.goahead(0)
> >> >   File "/usr/lib/python2.7/HTMLParser.py", line 151, in goahead
> >> >     k = self.parse_starttag(i)
> >> >   File "/usr/lib/python2.7/HTMLParser.py", line 272, in parse_starttag
> >> >     self.handle_startendtag(tag, attrs)
> >> >   File "/usr/lib/python2.7/HTMLParser.py", line 334, in
> >> handle_startendtag
> >> >     self.handle_starttag(tag, attrs)
> >> >   File
> >> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/html.py",
> >> > line 262, in handle_starttag
> >> >     x, y, w, h, link=self.href)

[web2py] Re: Where is base.css referenced?

2012-03-15 Thread Anthony
Yes, the book needs to be updated.

On Thursday, March 15, 2012 12:10:18 PM UTC-4, Edward Shave wrote:
>
> Oh, I went straight to base.css after reading the following in the the 
> review section of the book...
>
> *Configuring the layout*
>
> *You can configure the default layout by editing "views/layout.html" but 
> you can also configure it without editing the HTML. In fact, the 
> "static/base.css" stylesheet is well documented and described in Chapter 5. 
> You can change color, columns, size, borders and background without editing 
> the HTML. If you want to edit the menu, the title or the subtitle, you can 
> do so in any model file. The scaffolding app, sets default values of these 
> parameters in the file "models/menu.py":*
> Thanks for putting me right,
> Ed
>
> On Thursday, 15 March 2012 15:50:49 UTC, Anthony wrote:
>>
>> There is no longer a base.css -- it is now web2py.css.
>>
>> Anthony
>>
>> On Thursday, March 15, 2012 11:44:07 AM UTC-4, Edward Shave wrote:
>>>
>>> I feel I must be missing something obvious, but despite the references 
>>> to base.css in the book and the comments in the file itself, I can't find 
>>> where it is referenced by the welcome app?
>>
>>
> On Thursday, 15 March 2012 15:50:49 UTC, Anthony wrote:
>>
>> There is no longer a base.css -- it is now web2py.css.
>>
>> Anthony
>>
>> On Thursday, March 15, 2012 11:44:07 AM UTC-4, Edward Shave wrote:
>>>
>>> I feel I must be missing something obvious, but despite the references 
>>> to base.css in the book and the comments in the file itself, I can't find 
>>> where it is referenced by the welcome app?
>>
>>

[web2py] Re: No DB queries in web2py shell?

2012-03-15 Thread Stefan Scholl
Sorry, my "bug report" was a bit short. Was called to a meeting 5
minutes earlier than planned.

I tested this with the example app because I wanted a clear test
case. The bug was first seen in a bigger applicationi(, where I
wanted to see why the common_filter feature only worked in the
database admin interface and not in simple queries inside the
app.)


Person and dog inserted via database admin. After that the shell
from the admin interface was used. The variable dogs was
undefined after that. And no output with just
"db().select(db.dog.ALL)".


This isn't the case with older versions. I don't know which
version first had this bug. Maybe I'm the only one using this
interactive shell on the web interface.
Somewhere between 1.91.x and 1.99.7


Anthony  wrote:
> 
> Did you do the insert in the shell also? If so, when you do inserts, 
> updates, deletes in the shell, you have to follow with db.commit() in order 
> to commit the transaction. This is not necessary in application code 
> because the framework does that automatically at the end of a request. I 
> have also found that in some cases, the web-based shell in admin does not 
> work for database transactions, so you may need to use a regular OS shell.
> 
> Anthony
> 
> On Thursday, March 15, 2012 4:12:10 AM UTC-4, Stefan Scholl wrote:
>>
>> web2py 1.99.7 for Windows.
>>
>> Example app, inserted 1 person and 1 dog.
>>
>> In the shell:
>>
>> dogs = db().select(db.dog.ALL)
>>
>>
>> Nothing there. And "dogs" isn't defined.
>>
>>


-- 
Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/




[web2py] Re: No DB queries in web2py shell?

2012-03-15 Thread Stefan Scholl
Web interface. On Windows, 127.0.0.1:8000


Michele Comitini  wrote:
> did you do?
> 
> python web2py.py -M -S 
> 
> mic
> 
> Il 15 marzo 2012 09:12, Stefan Scholl  ha scritto:
>> web2py 1.99.7 for Windows.
>>
>> Example app, inserted 1 person and 1 dog.
>>
>> In the shell:
>>
>>        dogs = db().select(db.dog.ALL)
>>
>>
>> Nothing there. And "dogs" isn't defined.



[web2py] Re: Cookbook - No indentation ??

2012-03-15 Thread Alan Etkin
For customers, the example source code with standard indentation
should be available for download with the book support files:
http://www.packtpub.com/support

On 15 mar, 15:04, Marcello  wrote:
> Hello,
>
> I just bought my web2py Application Development Cookbook from Amazon
> (Kindle version)...
>
> I noticed that all python code is not indented
>
> Is it ?
>
> Ebook or PDF has the same problem ??
>
> Thanks,
> Marcello


[web2py] Re: Cookbook - No indentation ??

2012-03-15 Thread Marcello
I bought mine from Amazon... don't know if I have access to that

But my interest in the moment is not run code.
I want to read the book

And read the code without indentation is almost impossible...

If my book is correct, it is almost useless.



On Thursday, March 15, 2012 4:26:24 PM UTC-3, Alan Etkin wrote:
>
> For customers, the example source code with standard indentation 
> should be available for download with the book support files: 
> http://www.packtpub.com/support 
>
>

Re: [web2py] Cookbook - No indentation ??

2012-03-15 Thread greenpoise
I noticed page 124 to be blank..Not sure if there was something in it.





On Thursday, 15 March 2012 11:05:40 UTC-7, Detectedstealth wrote:
>
> The PDF has indentation but it is off and not consistent in some parts.
>
> On Thu, Mar 15, 2012 at 11:04 AM, Marcello  wrote:
>
>> Hello,
>>
>> I just bought my web2py Application Development Cookbook from Amazon 
>> (Kindle version)..
>>
>> I noticed that all python code is not indented
>>
>> Is it ?
>>
>> Ebook or PDF has the same problem ??
>>
>>
>> Thanks,
>> Marcello
>>
>
>
>
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>


[web2py] share data across uwsgi processes

2012-03-15 Thread Carlos
Hi,

My production environment is: latest web2py trunk, ubuntu 10.04, postgresql 
8.4, nginx, uwsgi.

I need to have data shared (not cached for certain time) across the uwsgi 
processes.

Currently I'm accessing such data via db select, but I'm wondering if 
there's a faster ram method (which auto-clears when restarting uwsgi 
server), with no need to access the database.

Is cache.ram or memcache or redis what I need?, preferably something simple 
to setup.

Note that I do not need to cache anything for certain time, but instead 
share data (set/get common data) across my uwsgi processes.

Thanks!,

   Carlos



Re: [web2py] share data across uwsgi processes

2012-03-15 Thread Roberto De Ioris

> Hi,
>
> My production environment is: latest web2py trunk, ubuntu 10.04,
> postgresql
> 8.4, nginx, uwsgi.
>
> I need to have data shared (not cached for certain time) across the uwsgi
> processes.
>
> Currently I'm accessing such data via db select, but I'm wondering if
> there's a faster ram method (which auto-clears when restarting uwsgi
> server), with no need to access the database.
>
> Is cache.ram or memcache or redis what I need?, preferably something
> simple
> to setup.
>
> Note that I do not need to cache anything for certain time, but instead
> share data (set/get common data) across my uwsgi processes.
>
>

dict-based:

http://projects.unbit.it/uwsgi/wiki/CachingFramework

queue-based:

http://projects.unbit.it/uwsgi/wiki/QueueFramework

raw-memory:

http://projects.unbit.it/uwsgi/wiki/SharedArea


-- 
Roberto De Ioris
http://unbit.it


[web2py] Correct way to use memcache on GAE with web2py

2012-03-15 Thread Sushant Taneja
Hi,

I have a tags table which will be available to all logged in users. The 
table has the following structure:

db.define_table('META_TAG',
Field('tag','string',notnull=True),
Field('root_tag','string',notnull=True),
Field('active_ind','string',length=1,default='Y')
)

This table will be rarely (once a month) updated via an administrative 
interface.
I read various web2py based examples and gae examples on using memcache. 
Each followed a different approach.
As per my understanding from appengine documentation, I have written the 
following helper function in a controller to use memcache:

*from google.appengine.api import memcache*

def get_tags():
"""This function returns cached value for META_TAG table"""
tags = memcache.get("tags")
if not words:
words = 
db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
memcache.add("tags",tags)
return tags
else:
return tags

Will the above code ensure that the correct data is always available in the 
memcache ?


Re: [web2py] Re: Cookbook found bug with web2py

2012-03-15 Thread Bruce Wade
Okay so the downloaded code the pdf works but the normal HTML view doesn't.

invalid view (default/report.html)
On Thu, Mar 15, 2012 at 11:48 AM, Alan Etkin  wrote:

> I should check the code in the book, but I used a controller example
> that should be available in the book's support files at
> http://www.packtpub.com/support and it worked for my environment:
>
> Python 2.6.5
> Mandriva GNU/Linux 2010
> web2py (last mercurial version)
>
> A complete working installer can be downloaded from the same url (in
> the apps folder)
>
> On Mar 15, 2:54 pm, Bruce Wade  wrote:
> > Fresh blank version of web2py, in default controller:
> >
> > def report():
> > import os
> > response.title = "web2py sample report"
> >
> > # include a chart from google chart
> > url = "
> http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=500x200&ch1...World&.png
> > "
> > chart = IMG(_src=url, _width="250", _height="100")
> >
> > # create a small table with some data:
> > rows = [THEAD(TR(TH("Key", _width="70%"),
> > TH("Value", _width="30%"))),
> > TBODY(TR(TD("Hello"), TD("60")),
> > TR(TD("World"), TD("40")))]
> >
> > table = TABLE(*rows, _border="0", _align="center", _width="50%")
> >
> > if request.extension == "pdf":
> > from gluon.contrib.pyfpdf import FPDF, HTMLMixin
> >
> > # create a custom class with the required functionalities
> > class MyFPDF(FPDF, HTMLMixin):
> > def header(self):
> > "hook to draw custom page header (logo and title)"
> >
> > # remember to copy logo_pb.png to static/images (and
> remove
> > alpha channel)
> > #logo = os.path.join(request.folder, "static", "images",
> > "logo_pb.png")
> > #self.image(logo, 10, 8, 33)
> > self.set_font("Arial", "B", 15)
> > self.cell(65)   # padding
> > self.cell(60, 10, response.title, 1, 0, 'C')
> > self.ln(20)
> >
> > def footer(self):
> > "hook to draw custom page footer (printing page numbers)"
> > self.set_y(-15)
> > self.set_font('Arial', 'I', 8)
> > txt = 'Page %s of %s' % (self.page_no(),
> > self.alias_nb_pages())
> > self.cell(0, 10, txt, 0, 0, 'C')
> > pdf = MyFPDF()
> >
> > # create a page and serialize/render HTML objects
> > pdf.add_page()
> > pdf.write_html(table.xml())
> > #pdf.write_html(CENTER(chart).xml())
> >
> > # prepare PDF to download:
> > response.headers['Content-Type'] = 'application/pdf'
> > return pdf.output(dest='S')
> >
> > # else normal html view
> > return dict(chart=chart, table=table)
> >
> > I thought it was the logo so I commented it out, but still the exact same
> > error.
> >
> > Looks like it is failing here:
> > def _parsepng(self, name):
> > #Extract info from a PNG file
> > if name.startswith("http://";) or name.startswith("https://";):
> > import urllib
> > f = urllib.urlopen(name)
> >
> > Which I am not sure why considering there is no PNG in my code so I guess
> > it is doing something behind the scene. I even commented out the chart
> line
> > so there should be no image issues.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Mar 15, 2012 at 10:49 AM, Bruce Wade 
> wrote:
> > > Install what app? I am following the instructions to create a PDF.
> >
> > > On Thu, Mar 15, 2012 at 10:47 AM, Alan Etkin 
> wrote:
> >
> > >> How are you running the code? Did you install the app from the apps
> > >> folder?
> >
> > >> On Mar 15, 2:29 pm, Bruce Wade  wrote:
> > >> > Chapter 10: Creating PDF reports
> >
> > >> > Error:
> >
> > >> > Traceback (most recent call last):
> > >> >   File
> > >>
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py",
> > >> > line 204, in restricted
> > >> > exec ccode in environment
> > >> >   File
> > >>
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/views/generic.pdf",
> > >> > line 9, in 
> > >> > pass
> > >> >   File
> > >>
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
> > >> > line 63, in pdf_from_html
> > >> > return pyfpdf_from_html(html)
> > >> >   File
> > >>
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
> > >> > line 55, in pyfpdf_from_html
> > >> > pdf.write_html(html,image_map=image_map)
> > >> >   File
> > >>
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/pyfpdf/html.py",
> > >> > line 388, in write_html
> > >> > h2p.feed(text)
> > >> >   File "/usr/lib/python2.7/HTMLParser.py", line 109, in feed
> > >> > self.goahead(0)
> > >> >   File "/usr/lib/python2.7/HTMLParser.py", line 151, in goahead
> > >> > k = self.parse_startta

[web2py] Re: unable to save file with online code editor

2012-03-15 Thread Alan Etkin
The problem was in my browser cookies. I've cleaned the browser data
and the problem didn't reproduce. This is probably due to recent
changes in the online editor.

On 15 mar, 13:59, Alan Etkin  wrote:
> When I click in the diskette for saving the file in the source code
> editor, the file is not saved, and a js error message is sent to the
> debugging feature in the browser:
>
> "area is not defined"
>
> The file that causes the error is ajax_editor.js, at line 33
>
> Here is the highlighted code:
>
> ...
> function doClickSave() {
>     try {
>         var data = eamy.instances[0].getText();
>     } catch(e) {
>         var data = area.textarea.value;
>     }
> ...
>
> web2py: Version 1.99.7 (2012-03-13 21:35:53) dev
> browser: Firefox 10.0


Re: [web2py] Correct way to use memcache on GAE with web2py

2012-03-15 Thread Jonathan Lundell
On Mar 15, 2012, at 1:15 PM, Sushant Taneja wrote:
> I have a tags table which will be available to all logged in users. The table 
> has the following structure:
> 
> db.define_table('META_TAG',
> Field('tag','string',notnull=True),
> Field('root_tag','string',notnull=True),
> Field('active_ind','string',length=1,default='Y')
> )
> 
> This table will be rarely (once a month) updated via an administrative 
> interface.
> I read various web2py based examples and gae examples on using memcache. Each 
> followed a different approach.
> As per my understanding from appengine documentation, I have written the 
> following helper function in a controller to use memcache:
> 
> from google.appengine.api import memcache
> 
> def get_tags():
> """This function returns cached value for META_TAG table"""
> tags = memcache.get("tags")
> if not words:
> words = 
> db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
> memcache.add("tags",tags)
> return tags
> else:
> return tags
> 
> Will the above code ensure that the correct data is always available in the 
> memcache ?

You seem to be mixing the names 'words' and 'tags'.

As a matter of style, I'd move the return outside the if/else.

Don't forget to set the cache when you update the tags.

It's best to test for 'is None', in case your cached object can legitimately 
evaluate to False (an empty list or string, for example). So more like:

from google.appengine.api import memcache

def get_tags():
"""This function returns cached value for META_TAG table"""
tags = memcache.get("tags")
if tags is None:
tags = 
db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
memcache.add("tags",tags)
return tags



[web2py] Re: Cookbook found bug with web2py

2012-03-15 Thread Alan Etkin
That error page is likely to be sent because of the new generic view
security rule. I'm using the response.generic_patterns = ["*",] in the
controller file and it works well (the sentence wasn't included in the
original file).


On 15 mar, 17:15, Bruce Wade  wrote:
> Okay so the downloaded code the pdf works but the normal HTML view doesn't.
>
> invalid view (default/report.html)
>
>
>
>
>
>
>
>
>
> On Thu, Mar 15, 2012 at 11:48 AM, Alan Etkin  wrote:
> > I should check the code in the book, but I used a controller example
> > that should be available in the book's support files at
> >http://www.packtpub.com/supportand it worked for my environment:
>
> > Python 2.6.5
> > Mandriva GNU/Linux 2010
> > web2py (last mercurial version)
>
> > A complete working installer can be downloaded from the same url (in
> > the apps folder)
>
> > On Mar 15, 2:54 pm, Bruce Wade  wrote:
> > > Fresh blank version of web2py, in default controller:
>
> > > def report():
> > >     import os
> > >     response.title = "web2py sample report"
>
> > >     # include a chart from google chart
> > >     url = "
> >http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=500x200&ch1...
> > > "
> > >     chart = IMG(_src=url, _width="250", _height="100")
>
> > >     # create a small table with some data:
> > >     rows = [THEAD(TR(TH("Key", _width="70%"),
> > >         TH("Value", _width="30%"))),
> > >         TBODY(TR(TD("Hello"), TD("60")),
> > >         TR(TD("World"), TD("40")))]
>
> > >     table = TABLE(*rows, _border="0", _align="center", _width="50%")
>
> > >     if request.extension == "pdf":
> > >         from gluon.contrib.pyfpdf import FPDF, HTMLMixin
>
> > >         # create a custom class with the required functionalities
> > >         class MyFPDF(FPDF, HTMLMixin):
> > >             def header(self):
> > >                 "hook to draw custom page header (logo and title)"
>
> > >                 # remember to copy logo_pb.png to static/images (and
> > remove
> > > alpha channel)
> > >                 #logo = os.path.join(request.folder, "static", "images",
> > > "logo_pb.png")
> > >                 #self.image(logo, 10, 8, 33)
> > >                 self.set_font("Arial", "B", 15)
> > >                 self.cell(65)   # padding
> > >                 self.cell(60, 10, response.title, 1, 0, 'C')
> > >                 self.ln(20)
>
> > >             def footer(self):
> > >                 "hook to draw custom page footer (printing page numbers)"
> > >                 self.set_y(-15)
> > >                 self.set_font('Arial', 'I', 8)
> > >                 txt = 'Page %s of %s' % (self.page_no(),
> > > self.alias_nb_pages())
> > >                 self.cell(0, 10, txt, 0, 0, 'C')
> > >                 pdf = MyFPDF()
>
> > >                 # create a page and serialize/render HTML objects
> > >                 pdf.add_page()
> > >                 pdf.write_html(table.xml())
> > >                 #pdf.write_html(CENTER(chart).xml())
>
> > >                 # prepare PDF to download:
> > >                 response.headers['Content-Type'] = 'application/pdf'
> > >                 return pdf.output(dest='S')
>
> > >     # else normal html view
> > >     return dict(chart=chart, table=table)
>
> > > I thought it was the logo so I commented it out, but still the exact same
> > > error.
>
> > > Looks like it is failing here:
> > > def _parsepng(self, name):
> > >         #Extract info from a PNG file
> > >         if name.startswith("http://";) or name.startswith("https://";):
> > >             import urllib
> > >             f = urllib.urlopen(name)
>
> > > Which I am not sure why considering there is no PNG in my code so I guess
> > > it is doing something behind the scene. I even commented out the chart
> > line
> > > so there should be no image issues.
>
> > > On Thu, Mar 15, 2012 at 10:49 AM, Bruce Wade 
> > wrote:
> > > > Install what app? I am following the instructions to create a PDF.
>
> > > > On Thu, Mar 15, 2012 at 10:47 AM, Alan Etkin 
> > wrote:
>
> > > >> How are you running the code? Did you install the app from the apps
> > > >> folder?
>
> > > >> On Mar 15, 2:29 pm, Bruce Wade  wrote:
> > > >> > Chapter 10: Creating PDF reports
>
> > > >> > Error:
>
> > > >> > Traceback (most recent call last):
> > > >> >   File
>
> > "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py",
> > > >> > line 204, in restricted
> > > >> >     exec ccode in environment
> > > >> >   File
>
> > "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/views/generic.pdf",
> > > >> > line 9, in 
> > > >> >     pass
> > > >> >   File
>
> > "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
> > > >> > line 63, in pdf_from_html
> > > >> >     return pyfpdf_from_html(html)
> > > >> >   File
>
> > "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/contrib/generics.py",
> > > >> > line 55, in pyfpdf_from_html
> > > >> >     pdf.write_html(html,image_map=image_map)
> 

Re: [web2py] Re: Cookbook found bug with web2py

2012-03-15 Thread Bruce Wade
Does pyfpdf support Chinese yet? I tried using Chinese by the characters
were not rendered in Chinese. Or do I need to set some kind of font.

On Thu, Mar 15, 2012 at 1:35 PM, Alan Etkin  wrote:

> That error page is likely to be sent because of the new generic view
> security rule. I'm using the response.generic_patterns = ["*",] in the
> controller file and it works well (the sentence wasn't included in the
> original file).
>
>
> On 15 mar, 17:15, Bruce Wade  wrote:
> > Okay so the downloaded code the pdf works but the normal HTML view
> doesn't.
> >
> > invalid view (default/report.html)
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Mar 15, 2012 at 11:48 AM, Alan Etkin  wrote:
> > > I should check the code in the book, but I used a controller example
> > > that should be available in the book's support files at
> > >http://www.packtpub.com/supportand it worked for my environment:
> >
> > > Python 2.6.5
> > > Mandriva GNU/Linux 2010
> > > web2py (last mercurial version)
> >
> > > A complete working installer can be downloaded from the same url (in
> > > the apps folder)
> >
> > > On Mar 15, 2:54 pm, Bruce Wade  wrote:
> > > > Fresh blank version of web2py, in default controller:
> >
> > > > def report():
> > > > import os
> > > > response.title = "web2py sample report"
> >
> > > > # include a chart from google chart
> > > > url = "
> > >http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=500x200&ch1.
> ..
> > > > "
> > > > chart = IMG(_src=url, _width="250", _height="100")
> >
> > > > # create a small table with some data:
> > > > rows = [THEAD(TR(TH("Key", _width="70%"),
> > > > TH("Value", _width="30%"))),
> > > > TBODY(TR(TD("Hello"), TD("60")),
> > > > TR(TD("World"), TD("40")))]
> >
> > > > table = TABLE(*rows, _border="0", _align="center", _width="50%")
> >
> > > > if request.extension == "pdf":
> > > > from gluon.contrib.pyfpdf import FPDF, HTMLMixin
> >
> > > > # create a custom class with the required functionalities
> > > > class MyFPDF(FPDF, HTMLMixin):
> > > > def header(self):
> > > > "hook to draw custom page header (logo and title)"
> >
> > > > # remember to copy logo_pb.png to static/images (and
> > > remove
> > > > alpha channel)
> > > > #logo = os.path.join(request.folder, "static",
> "images",
> > > > "logo_pb.png")
> > > > #self.image(logo, 10, 8, 33)
> > > > self.set_font("Arial", "B", 15)
> > > > self.cell(65)   # padding
> > > > self.cell(60, 10, response.title, 1, 0, 'C')
> > > > self.ln(20)
> >
> > > > def footer(self):
> > > > "hook to draw custom page footer (printing page
> numbers)"
> > > > self.set_y(-15)
> > > > self.set_font('Arial', 'I', 8)
> > > > txt = 'Page %s of %s' % (self.page_no(),
> > > > self.alias_nb_pages())
> > > > self.cell(0, 10, txt, 0, 0, 'C')
> > > > pdf = MyFPDF()
> >
> > > > # create a page and serialize/render HTML objects
> > > > pdf.add_page()
> > > > pdf.write_html(table.xml())
> > > > #pdf.write_html(CENTER(chart).xml())
> >
> > > > # prepare PDF to download:
> > > > response.headers['Content-Type'] = 'application/pdf'
> > > > return pdf.output(dest='S')
> >
> > > > # else normal html view
> > > > return dict(chart=chart, table=table)
> >
> > > > I thought it was the logo so I commented it out, but still the exact
> same
> > > > error.
> >
> > > > Looks like it is failing here:
> > > > def _parsepng(self, name):
> > > > #Extract info from a PNG file
> > > > if name.startswith("http://";) or name.startswith("https://
> "):
> > > > import urllib
> > > > f = urllib.urlopen(name)
> >
> > > > Which I am not sure why considering there is no PNG in my code so I
> guess
> > > > it is doing something behind the scene. I even commented out the
> chart
> > > line
> > > > so there should be no image issues.
> >
> > > > On Thu, Mar 15, 2012 at 10:49 AM, Bruce Wade 
> > > wrote:
> > > > > Install what app? I am following the instructions to create a PDF.
> >
> > > > > On Thu, Mar 15, 2012 at 10:47 AM, Alan Etkin 
> > > wrote:
> >
> > > > >> How are you running the code? Did you install the app from the
> apps
> > > > >> folder?
> >
> > > > >> On Mar 15, 2:29 pm, Bruce Wade  wrote:
> > > > >> > Chapter 10: Creating PDF reports
> >
> > > > >> > Error:
> >
> > > > >> > Traceback (most recent call last):
> > > > >> >   File
> >
> > >
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py",
> > > > >> > line 204, in restricted
> > > > >> > exec ccode in environment
> > > > >> >   File
> >
> > >
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev

[web2py] a .contains() query with virtual field

2012-03-15 Thread monotasker
I had a nice query set up and working that looked for any match between 
items in a list and records in a list-reference field:

catXtags = [2,4,6,7,9]
curr_loc.id = 6

db((db.paths.tags.contains(catXtags)) & 
(db.paths.locations.contains(curr_loc.id))

I changed db.paths.tags to be a virtual field that constructs the same list 
of foreign id's dynamically. But now when I run the query I get this error:

 'tags'
The weird thing is that when I print db.paths.tags in the preceding line I 
get a nice list of integers. So the key 'tags' does seem to exist in 
db.paths.fields and the data should be the right format. I'm really not 
sure what I'm doing wrong!

Any help is much appreciated. For reference, the full error traceback is 
below.

Traceback (most recent call last):
  File "/home/ian/web/web2py/gluon/restricted.py", line 204, in restricted
exec ccode in environment
  File "/home/ian/web/web2py/applications/paideia/controllers/exploring.py" 
, 
line 104, in 
  File "/home/ian/web/web2py/gluon/globals.py", line 172, in 
self._caller = lambda f: f()
  File "/home/ian/web/web2py/gluon/tools.py", line 2533, in f
return action(*a, **b)
  File "/home/ian/web/web2py/applications/paideia/controllers/exploring.py" 
, 
line 95, in index
return step_init()
  File "/home/ian/web/web2py/applications/paideia/controllers/exploring.py" 
, 
line 21, in step_init
path_result = path.pick()
  File "applications/paideia/modules/paideia_exploring.py", line 196, in pick
p = self.find_paths(cat, curr_loc)
  File "applications/paideia/modules/paideia_exploring.py", line 232, in 
find_paths
catXpaths = db((db.paths.tags.contains(catXtags))
  File "/home/ian/web/web2py/gluon/dal.py", line 5542, in __getattr__
return self[key]
  File "/home/ian/web/web2py/gluon/dal.py", line 5482, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'tags'




Re: [web2py] a .contains() query with virtual field

2012-03-15 Thread Bruno Rocha
You cannot perform a query to a Virtual Field, queries run on database
level, virtual fields runs on app level.

You can just fetch a subset of rows then use .find() to fiter that rows.

On Thu, Mar 15, 2012 at 5:55 PM, monotasker  wrote:

> I had a nice query set up and working that looked for any match between
> items in a list and records in a list-reference field:
>
> catXtags = [2,4,6,7,9]
> curr_loc.id = 6
>
> db((db.paths.tags.contains(catXtags)) & (db.paths.locations.contains(
> curr_loc.id))
>
> I changed db.paths.tags to be a virtual field that constructs the same
> list of foreign id's dynamically. But now when I run the query I get this
> error:
>
>  'tags'
> The weird thing is that when I print db.paths.tags in the preceding line I
> get a nice list of integers. So the key 'tags' does seem to exist in
> db.paths.fields and the data should be the right format. I'm really not
> sure what I'm doing wrong!
>
> Any help is much appreciated. For reference, the full error traceback is
> below.
>
>
> Traceback (most recent call last):
>   File "/home/ian/web/web2py/gluon/restricted.py", line 204, in restricted
>
> exec ccode in environment
>   File "/home/ian/web/web2py/applications/paideia/controllers/exploring.py" 
> , 
> line 104, in 
>
>   File "/home/ian/web/web2py/gluon/globals.py", line 172, in 
>
> self._caller = lambda f: f()
>
>   File "/home/ian/web/web2py/gluon/tools.py", line 2533, in f
>
> return action(*a, **b)
>   File "/home/ian/web/web2py/applications/paideia/controllers/exploring.py" 
> , 
> line 95, in index
>
> return step_init()
>   File "/home/ian/web/web2py/applications/paideia/controllers/exploring.py" 
> , 
> line 21, in step_init
>
> path_result = path.pick()
>   File "applications/paideia/modules/paideia_exploring.py", line 196, in pick
>
> p = self.find_paths(cat, curr_loc)
>
>   File "applications/paideia/modules/paideia_exploring.py", line 232, in 
> find_paths
>
> catXpaths = db((db.paths.tags.contains(catXtags))
>
>   File "/home/ian/web/web2py/gluon/dal.py", line 5542, in __getattr__
>
> return self[key]
>   File "/home/ian/web/web2py/gluon/dal.py", line 5482, in __getitem__
>
> return dict.__getitem__(self, str(key))
> KeyError: 'tags'
>
>
>


-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] a .contains() query with virtual field

2012-03-15 Thread monotasker
Ahhh . . . now I just feel silly! Thanks.

Ian

On Thursday, March 15, 2012 4:57:58 PM UTC-4, rochacbruno wrote:
>
> You cannot perform a query to a Virtual Field, queries run on database 
> level, virtual fields runs on app level.
>
> You can just fetch a subset of rows then use .find() to fiter that rows.
>
> On Thu, Mar 15, 2012 at 5:55 PM, monotasker wrote:
>
>> I had a nice query set up and working that looked for any match between 
>> items in a list and records in a list-reference field:
>>
>> catXtags = [2,4,6,7,9]
>> curr_loc.id = 6
>>
>> db((db.paths.tags.contains(catXtags)) & (db.paths.locations.contains(
>> curr_loc.id))
>>
>> I changed db.paths.tags to be a virtual field that constructs the same 
>> list of foreign id's dynamically. But now when I run the query I get this 
>> error:
>>
>>  'tags'
>> The weird thing is that when I print db.paths.tags in the preceding line 
>> I get a nice list of integers. So the key 'tags' does seem to exist in 
>> db.paths.fields and the data should be the right format. I'm really not 
>> sure what I'm doing wrong!
>>
>> Any help is much appreciated. For reference, the full error traceback is 
>> below.
>>
>> Traceback (most recent call last):
>>   File "/home/ian/web/web2py/gluon/restricted.py", line 204, in restricted
>>
>>
>> exec ccode in environment
>>   File "/home/ian/web/web2py/applications/paideia/controllers/exploring.py" 
>> , 
>> line 104, in 
>>
>>
>>   File "/home/ian/web/web2py/gluon/globals.py", line 172, in 
>>
>>
>> self._caller = lambda f: f()
>>
>>
>>   File "/home/ian/web/web2py/gluon/tools.py", line 2533, in f
>>
>>
>> return action(*a, **b)
>>   File "/home/ian/web/web2py/applications/paideia/controllers/exploring.py" 
>> , 
>> line 95, in index
>>
>>
>> return step_init()
>>   File "/home/ian/web/web2py/applications/paideia/controllers/exploring.py" 
>> , 
>> line 21, in step_init
>>
>>
>> path_result = path.pick()
>>   File "applications/paideia/modules/paideia_exploring.py", line 196, in pick
>>
>>
>> p = self.find_paths(cat, curr_loc)
>>
>>
>>   File "applications/paideia/modules/paideia_exploring.py", line 232, in 
>> find_paths
>>
>>
>> catXpaths = db((db.paths.tags.contains(catXtags))
>>
>>
>>   File "/home/ian/web/web2py/gluon/dal.py", line 5542, in __getattr__
>>
>>
>> return self[key]
>>   File "/home/ian/web/web2py/gluon/dal.py", line 5482, in __getitem__
>>
>>
>> return dict.__getitem__(self, str(key))
>>
>> KeyError: 'tags'
>>
>>
>>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>

[web2py] Re: No DB queries in web2py shell?

2012-03-15 Thread Anthony
You're right, db selects do not appear to be working in the web-based 
shell, at least not on Windows using SQLite. Are you sure it used to work 
(specifically on Windows) -- I haven't tried it in a while, but I seem to 
recall having problems with this a long time ago? I always use a standard 
OS shell instead.

Anthony

On Thursday, March 15, 2012 3:14:56 PM UTC-4, Stefan Scholl wrote:
>
> Sorry, my "bug report" was a bit short. Was called to a meeting 5
> minutes earlier than planned.
>
> I tested this with the example app because I wanted a clear test
> case. The bug was first seen in a bigger applicationi(, where I
> wanted to see why the common_filter feature only worked in the
> database admin interface and not in simple queries inside the
> app.)
>
>
> Person and dog inserted via database admin. After that the shell
> from the admin interface was used. The variable dogs was
> undefined after that. And no output with just
> "db().select(db.dog.ALL)".
>
>
> This isn't the case with older versions. I don't know which
> version first had this bug. Maybe I'm the only one using this
> interactive shell on the web interface.
> Somewhere between 1.91.x and 1.99.7
>
>
> Anthony  wrote:
> > 
> > Did you do the insert in the shell also? If so, when you do inserts, 
> > updates, deletes in the shell, you have to follow with db.commit() in 
> order 
> > to commit the transaction. This is not necessary in application code 
> > because the framework does that automatically at the end of a request. I 
> > have also found that in some cases, the web-based shell in admin does 
> not 
> > work for database transactions, so you may need to use a regular OS 
> shell.
> > 
> > Anthony
> > 
> > On Thursday, March 15, 2012 4:12:10 AM UTC-4, Stefan Scholl wrote:
> >>
> >> web2py 1.99.7 for Windows.
> >>
> >> Example app, inserted 1 person and 1 dog.
> >>
> >> In the shell:
> >>
> >> dogs = db().select(db.dog.ALL)
> >>
> >>
> >> Nothing there. And "dogs" isn't defined.
> >>
> >>
>
>
> -- 
> Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/
> 
>
>

[web2py] Re: Cookbook found bug with web2py

2012-03-15 Thread Alan Etkin
I belive Chinese is not ported to pypdf (the php software supported it
via a special class). AFAIK the chinese fonts BIG5 or GB must be
installed in the server. Maybe you could start an issue for adding it
in the project page.

http://code.google.com/p/pyfpdf/

On 15 mar, 17:53, Bruce Wade  wrote:
> Does pyfpdf support Chinese yet? I tried using Chinese by the characters
> were not rendered in Chinese. Or do I need to set some kind of font.
>
>
>
>
>
>
>
>
>
> On Thu, Mar 15, 2012 at 1:35 PM, Alan Etkin  wrote:
> > That error page is likely to be sent because of the new generic view
> > security rule. I'm using the response.generic_patterns = ["*",] in the
> > controller file and it works well (the sentence wasn't included in the
> > original file).
>
> > On 15 mar, 17:15, Bruce Wade  wrote:
> > > Okay so the downloaded code the pdf works but the normal HTML view
> > doesn't.
>
> > > invalid view (default/report.html)
>
> > > On Thu, Mar 15, 2012 at 11:48 AM, Alan Etkin  wrote:
> > > > I should check the code in the book, but I used a controller example
> > > > that should be available in the book's support files at
> > > >http://www.packtpub.com/supportandit worked for my environment:
>
> > > > Python 2.6.5
> > > > Mandriva GNU/Linux 2010
> > > > web2py (last mercurial version)
>
> > > > A complete working installer can be downloaded from the same url (in
> > > > the apps folder)
>
> > > > On Mar 15, 2:54 pm, Bruce Wade  wrote:
> > > > > Fresh blank version of web2py, in default controller:
>
> > > > > def report():
> > > > >     import os
> > > > >     response.title = "web2py sample report"
>
> > > > >     # include a chart from google chart
> > > > >     url = "
> > > >http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=500x200&ch1.
> > ..
> > > > > "
> > > > >     chart = IMG(_src=url, _width="250", _height="100")
>
> > > > >     # create a small table with some data:
> > > > >     rows = [THEAD(TR(TH("Key", _width="70%"),
> > > > >         TH("Value", _width="30%"))),
> > > > >         TBODY(TR(TD("Hello"), TD("60")),
> > > > >         TR(TD("World"), TD("40")))]
>
> > > > >     table = TABLE(*rows, _border="0", _align="center", _width="50%")
>
> > > > >     if request.extension == "pdf":
> > > > >         from gluon.contrib.pyfpdf import FPDF, HTMLMixin
>
> > > > >         # create a custom class with the required functionalities
> > > > >         class MyFPDF(FPDF, HTMLMixin):
> > > > >             def header(self):
> > > > >                 "hook to draw custom page header (logo and title)"
>
> > > > >                 # remember to copy logo_pb.png to static/images (and
> > > > remove
> > > > > alpha channel)
> > > > >                 #logo = os.path.join(request.folder, "static",
> > "images",
> > > > > "logo_pb.png")
> > > > >                 #self.image(logo, 10, 8, 33)
> > > > >                 self.set_font("Arial", "B", 15)
> > > > >                 self.cell(65)   # padding
> > > > >                 self.cell(60, 10, response.title, 1, 0, 'C')
> > > > >                 self.ln(20)
>
> > > > >             def footer(self):
> > > > >                 "hook to draw custom page footer (printing page
> > numbers)"
> > > > >                 self.set_y(-15)
> > > > >                 self.set_font('Arial', 'I', 8)
> > > > >                 txt = 'Page %s of %s' % (self.page_no(),
> > > > > self.alias_nb_pages())
> > > > >                 self.cell(0, 10, txt, 0, 0, 'C')
> > > > >                 pdf = MyFPDF()
>
> > > > >                 # create a page and serialize/render HTML objects
> > > > >                 pdf.add_page()
> > > > >                 pdf.write_html(table.xml())
> > > > >                 #pdf.write_html(CENTER(chart).xml())
>
> > > > >                 # prepare PDF to download:
> > > > >                 response.headers['Content-Type'] = 'application/pdf'
> > > > >                 return pdf.output(dest='S')
>
> > > > >     # else normal html view
> > > > >     return dict(chart=chart, table=table)
>
> > > > > I thought it was the logo so I commented it out, but still the exact
> > same
> > > > > error.
>
> > > > > Looks like it is failing here:
> > > > > def _parsepng(self, name):
> > > > >         #Extract info from a PNG file
> > > > >         if name.startswith("http://";) or name.startswith("https://
> > "):
> > > > >             import urllib
> > > > >             f = urllib.urlopen(name)
>
> > > > > Which I am not sure why considering there is no PNG in my code so I
> > guess
> > > > > it is doing something behind the scene. I even commented out the
> > chart
> > > > line
> > > > > so there should be no image issues.
>
> > > > > On Thu, Mar 15, 2012 at 10:49 AM, Bruce Wade 
> > > > wrote:
> > > > > > Install what app? I am following the instructions to create a PDF.
>
> > > > > > On Thu, Mar 15, 2012 at 10:47 AM, Alan Etkin 
> > > > wrote:
>
> > > > > >> How are you running the code? Did you install the app from the
> > apps
> > > > > >> folder?
>
> > > > > >> On Mar 1

Re: [web2py] Re: export csv

2012-03-15 Thread Richard Vézina
I get it to work like this :


def export_csv():
rows = db((db.tab1.id == tab1_id)).select()
return dict(rows=rows)

def export_default_analysis_request():
tab1_subset = (db.tab1.bool1 == True)
form = SQLFORM.factory(
Field('tab1_id', requires=IS_IN_DB(db(tab1_subset),'tab1.id
','%(f1)s')),
submit_button=T('Submit'))
if form.accepts(request.vars, session):
response.flash = T('form accepted')
  * redirect(URL(a=request.application, c='C', f='export_csv.csv',
vars=dict(tab1_id=form.vars.tab1_id)))*
elif form.errors:
response.flash = T('form has errors')
else:
response.flash = T('please fill out the form')
return dict(form=form)

And I put this in /views/C/export_csv.csv as explain in the book :

{{
import cStringIO
stream=cStringIO.StringIO()
rows.export_to_csv_file(stream)
response.headers['Content-Type']='application/vnd.ms-excel'
response.write(stream.getvalue(), escape=False)
}}

And it works fine, the only thing is that I get a blank page... I could
probably set a ajax call instead of redirect later.

Richard


On Wed, Mar 14, 2012 at 8:18 PM, Richard Vézina  wrote:

> Ho yeah, I forget about that option...
>
> Thanks Alan
>
> Richard
>
>
> On Wed, Mar 14, 2012 at 6:53 PM, Alan Etkin  wrote:
>
>> I have not experience with the book csv output example, but it looks
>> different than your implementation:
>>
>> -It has a special view "/name.csv" to render the function output
>> -The Content-Type parameter is "application-vnd.ms-excel"
>>
>> I think you could change the response view parameter on form
>> validation to .../name.csv, have the function to return a dict object
>> and use the book example view to return the csv file response.
>>
>> The example I am refering to is in section 10.1.6
>>
>> On 14 mar, 18:19, Richard  wrote:
>> > Hello,
>> >
>> > I strungle with export of csv... I have this function that works great :
>> >
>> > def export_csv(tab1_id):
>> > import gluon.contenttype
>> > response.headers['Content-Type'] = \
>> > gluon.contenttype.contenttype('.csv')
>> > import cStringIO
>> > stream=cStringIO.StringIO()
>> > db((db.tab1.id == tab1_id)).select().export_to_csv_file(stream)
>> > response.headers['Content-disposition'] = 'attachment;
>> filename=%s.csv'
>> > % 'test12345'
>> > response.write(stream.getvalue())
>> >
>> > def export_default_analysis_request():
>> > tab1_subset = (db.tab1.bool1 == True)
>> > form = SQLFORM.factory(
>> > Field('tab1_id',
>> > requires=IS_IN_DB(db(tab1_subset),'tab1.id','%(f1)s')),
>> > submit_button=T('Submit'))
>> > if form.accepts(request.vars, session):
>> > response.flash = T('form accepted')
>> > export_csv(tab1_id = form.vars.tab1_id)
>> > elif form.errors:
>> > response.flash = T('form has errors')
>> > else:
>> > response.flash = T('please fill out the form')
>> > return dict(form=form)
>> >
>> > The problem is that I am getting the html page below the value I want to
>> > export...
>> >
>> > Do I need to redirect on a blank page? It likes if response contain the
>> > actual page that get out at the same time as the data...
>> >
>> > I just copy stuff from here and there, but I think I will have to better
>> > understand what is going on...
>> >
>> > Thanks
>> >
>> > Richard
>>
>
>


Re: [web2py] Re: export csv

2012-03-15 Thread Richard Vézina
Forget one thing :

def export_csv():
rows = db((db.tab1.id == *request.get_vars['tab1_id']*)).select()
return dict(rows=rows)

On Thu, Mar 15, 2012 at 6:16 PM, Richard Vézina  wrote:

> I get it to work like this :
>
>
> def export_csv():
> rows = db((db.tab1.id == tab1_id)).select()
> return dict(rows=rows)
>
> def export_default_analysis_request():
> tab1_subset = (db.tab1.bool1 == True)
> form = SQLFORM.factory(
> Field('tab1_id', requires=IS_IN_DB(db(tab1_subset),'tab1.id
> ','%(f1)s')),
> submit_button=T('Submit'))
> if form.accepts(request.vars, session):
> response.flash = T('form accepted')
>   * redirect(URL(a=request.application, c='C', f='export_csv.csv',
> vars=dict(tab1_id=form.vars.tab1_id)))*
> elif form.errors:
> response.flash = T('form has errors')
> else:
> response.flash = T('please fill out the form')
> return dict(form=form)
>
> And I put this in /views/C/export_csv.csv as explain in the book :
>
> {{
> import cStringIO
> stream=cStringIO.StringIO()
> rows.export_to_csv_file(stream)
> response.headers['Content-Type']='application/vnd.ms-excel'
> response.write(stream.getvalue(), escape=False)
> }}
>
> And it works fine, the only thing is that I get a blank page... I could
> probably set a ajax call instead of redirect later.
>
> Richard
>
>
> On Wed, Mar 14, 2012 at 8:18 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Ho yeah, I forget about that option...
>>
>> Thanks Alan
>>
>> Richard
>>
>>
>> On Wed, Mar 14, 2012 at 6:53 PM, Alan Etkin  wrote:
>>
>>> I have not experience with the book csv output example, but it looks
>>> different than your implementation:
>>>
>>> -It has a special view "/name.csv" to render the function output
>>> -The Content-Type parameter is "application-vnd.ms-excel"
>>>
>>> I think you could change the response view parameter on form
>>> validation to .../name.csv, have the function to return a dict object
>>> and use the book example view to return the csv file response.
>>>
>>> The example I am refering to is in section 10.1.6
>>>
>>> On 14 mar, 18:19, Richard  wrote:
>>> > Hello,
>>> >
>>> > I strungle with export of csv... I have this function that works great
>>> :
>>> >
>>> > def export_csv(tab1_id):
>>> > import gluon.contenttype
>>> > response.headers['Content-Type'] = \
>>> > gluon.contenttype.contenttype('.csv')
>>> > import cStringIO
>>> > stream=cStringIO.StringIO()
>>> > db((db.tab1.id == tab1_id)).select().export_to_csv_file(stream)
>>> > response.headers['Content-disposition'] = 'attachment;
>>> filename=%s.csv'
>>> > % 'test12345'
>>> > response.write(stream.getvalue())
>>> >
>>> > def export_default_analysis_request():
>>> > tab1_subset = (db.tab1.bool1 == True)
>>> > form = SQLFORM.factory(
>>> > Field('tab1_id',
>>> > requires=IS_IN_DB(db(tab1_subset),'tab1.id','%(f1)s')),
>>> > submit_button=T('Submit'))
>>> > if form.accepts(request.vars, session):
>>> > response.flash = T('form accepted')
>>> > export_csv(tab1_id = form.vars.tab1_id)
>>> > elif form.errors:
>>> > response.flash = T('form has errors')
>>> > else:
>>> > response.flash = T('please fill out the form')
>>> > return dict(form=form)
>>> >
>>> > The problem is that I am getting the html page below the value I want
>>> to
>>> > export...
>>> >
>>> > Do I need to redirect on a blank page? It likes if response contain the
>>> > actual page that get out at the same time as the data...
>>> >
>>> > I just copy stuff from here and there, but I think I will have to
>>> better
>>> > understand what is going on...
>>> >
>>> > Thanks
>>> >
>>> > Richard
>>>
>>
>>
>


[web2py] Re: Gluino status

2012-03-15 Thread Voltron
Thanks Massimo. I really owe a lot to Web2Py. The ticketing and admin
modules are great. I will kick Gluion's tires an see how far I can go
with it.



On Mar 15, 1:10 pm, Massimo Di Pierro 
wrote:
> Hello Voltron,  we missed you.
>
> Gluino needs testing. Moreover the API may still change a little. The main
> issue is that every framework has different request, session and response
> objects. Right now it only tries to normalize request via
> wrapper.get_variables(request) and ignores session and response. It assume
> for every framework you use the native API. Perhaps we will find that we
> want to provide a more abstract request, session and response objects.
>
> I am skeptical to do this now because the larger python community is
> discussing where these should be a standard.
>
> Massimo
>
>
>
>
>
>
>
> On Thursday, 15 March 2012 05:30:51 UTC-5, Voltron wrote:
>
> > Full circle, well almost. My largest application was built with
> > web2py( some years back). Hi Massimo, what is the status on Gluino?
> > Would you say its stable enough for production? Is the MongoDB/DAL
> > support coming along?
>
> > Thanks


Re: [web2py] Re: Cookbook found bug with web2py

2012-03-15 Thread Bruce Wade
Thanks I will have to look into it, or possibly just use reportlab.

On Thu, Mar 15, 2012 at 2:17 PM, Alan Etkin  wrote:

> I belive Chinese is not ported to pypdf (the php software supported it
> via a special class). AFAIK the chinese fonts BIG5 or GB must be
> installed in the server. Maybe you could start an issue for adding it
> in the project page.
>
> http://code.google.com/p/pyfpdf/
>
> On 15 mar, 17:53, Bruce Wade  wrote:
> > Does pyfpdf support Chinese yet? I tried using Chinese by the characters
> > were not rendered in Chinese. Or do I need to set some kind of font.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Mar 15, 2012 at 1:35 PM, Alan Etkin  wrote:
> > > That error page is likely to be sent because of the new generic view
> > > security rule. I'm using the response.generic_patterns = ["*",] in the
> > > controller file and it works well (the sentence wasn't included in the
> > > original file).
> >
> > > On 15 mar, 17:15, Bruce Wade  wrote:
> > > > Okay so the downloaded code the pdf works but the normal HTML view
> > > doesn't.
> >
> > > > invalid view (default/report.html)
> >
> > > > On Thu, Mar 15, 2012 at 11:48 AM, Alan Etkin 
> wrote:
> > > > > I should check the code in the book, but I used a controller
> example
> > > > > that should be available in the book's support files at
> > > > >http://www.packtpub.com/supportandit worked for my environment:
> >
> > > > > Python 2.6.5
> > > > > Mandriva GNU/Linux 2010
> > > > > web2py (last mercurial version)
> >
> > > > > A complete working installer can be downloaded from the same url
> (in
> > > > > the apps folder)
> >
> > > > > On Mar 15, 2:54 pm, Bruce Wade  wrote:
> > > > > > Fresh blank version of web2py, in default controller:
> >
> > > > > > def report():
> > > > > > import os
> > > > > > response.title = "web2py sample report"
> >
> > > > > > # include a chart from google chart
> > > > > > url = "
> > > > >
> http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=500x200&ch1.
> > > ..
> > > > > > "
> > > > > > chart = IMG(_src=url, _width="250", _height="100")
> >
> > > > > > # create a small table with some data:
> > > > > > rows = [THEAD(TR(TH("Key", _width="70%"),
> > > > > > TH("Value", _width="30%"))),
> > > > > > TBODY(TR(TD("Hello"), TD("60")),
> > > > > > TR(TD("World"), TD("40")))]
> >
> > > > > > table = TABLE(*rows, _border="0", _align="center",
> _width="50%")
> >
> > > > > > if request.extension == "pdf":
> > > > > > from gluon.contrib.pyfpdf import FPDF, HTMLMixin
> >
> > > > > > # create a custom class with the required functionalities
> > > > > > class MyFPDF(FPDF, HTMLMixin):
> > > > > > def header(self):
> > > > > > "hook to draw custom page header (logo and
> title)"
> >
> > > > > > # remember to copy logo_pb.png to static/images
> (and
> > > > > remove
> > > > > > alpha channel)
> > > > > > #logo = os.path.join(request.folder, "static",
> > > "images",
> > > > > > "logo_pb.png")
> > > > > > #self.image(logo, 10, 8, 33)
> > > > > > self.set_font("Arial", "B", 15)
> > > > > > self.cell(65)   # padding
> > > > > > self.cell(60, 10, response.title, 1, 0, 'C')
> > > > > > self.ln(20)
> >
> > > > > > def footer(self):
> > > > > > "hook to draw custom page footer (printing page
> > > numbers)"
> > > > > > self.set_y(-15)
> > > > > > self.set_font('Arial', 'I', 8)
> > > > > > txt = 'Page %s of %s' % (self.page_no(),
> > > > > > self.alias_nb_pages())
> > > > > > self.cell(0, 10, txt, 0, 0, 'C')
> > > > > > pdf = MyFPDF()
> >
> > > > > > # create a page and serialize/render HTML objects
> > > > > > pdf.add_page()
> > > > > > pdf.write_html(table.xml())
> > > > > > #pdf.write_html(CENTER(chart).xml())
> >
> > > > > > # prepare PDF to download:
> > > > > > response.headers['Content-Type'] =
> 'application/pdf'
> > > > > > return pdf.output(dest='S')
> >
> > > > > > # else normal html view
> > > > > > return dict(chart=chart, table=table)
> >
> > > > > > I thought it was the logo so I commented it out, but still the
> exact
> > > same
> > > > > > error.
> >
> > > > > > Looks like it is failing here:
> > > > > > def _parsepng(self, name):
> > > > > > #Extract info from a PNG file
> > > > > > if name.startswith("http://";) or
> name.startswith("https://
> > > "):
> > > > > > import urllib
> > > > > > f = urllib.urlopen(name)
> >
> > > > > > Which I am not sure why considering there is no PNG in my code
> so I
> > > guess
> > > > > > it is doing something behind the scene. I even commented out the
> > > chart
> > > > > line
> > > > > > s

[web2py] Re: Cookbook - No indentation ??

2012-03-15 Thread Monte Milanuk
On Thu, 15 Mar 2012 12:32:14 -0700, Marcello wrote:

> I bought mine from Amazon... don't know if I have access to that
> 
> But my interest in the moment is not run code. I want to read the
> book
> 
> And read the code without indentation is almost impossible...
> 
> If my book is correct, it is almost useless.
> 
> 

Packt Publishing has an on-going issue in this regard... I'd purchased a 
couple books from them directly - fairly readable in PDF format, but 
pretty much useless in Kindle format.  I noticed a number of folks over 
on Amazon who had purchased thru them, where you only get the .mobi 
format - and are effectively screwed - had the same problem.  Having 
purchased mine directly thru Packt, I could at least read it in PDF 
format.

If you look at any of their books for Python related subjects in 
Kindle/.mobi format, they are all screwed up.  I hounded the CS people 
about it - took them a long dang time to even respond.  They finally 
offered two other ebooks of my choice as compensation.  One of the ones I 
chose was this web2py cookbook - even with the release date slipping a 
couple months, and knowing full well it would probably be unusable on a 
Kindle.  

Oh, and if you look... I don't think I've ever seen any of their books 
showing *any* errata listed...

To be honest, I was rather surprised to see the Web2Py project working 
with these folks... I'd hoped maybe a change had occurred and things 
would be better, but opening the pdf and finding two typos in the first 
couple pages of the intro cured that idea.

Monte




[web2py] Re: web2py recipe book

2012-03-15 Thread Francois
Thanks Bruce,

I just bought the ebook from Packt Publishing and downloaded the PDF
format. I confirm that I can highlight text and write comments in the
PDF file using PDF-XChange Viewer by Tracker Software. To me this is
an important feature in order for an ebook to be more usable than a
traditional printed book.

On Mar 15, 12:40 pm, Bruce Wade  wrote:
> You can add bookmarks, I have no idea how to write comments using Evince on
> Ubuntu though.
>
>
>
>
>
>
>
>
>
> On Thu, Mar 15, 2012 at 10:08 AM, Francois  wrote:
> > If one of you got the ebook in PDF format, can you confirm if it
> > possible to annotate it (write comments and put bookmarks) ?
>
> > Thanks,
>
> > -Francois.
>
> > On Mar 15, 12:46 pm, Bruce Wade  wrote:
> > > Cool just bought it. I am interested to see how some things are
> > implemented
> > > in the book which I have already implemented in my project.
>
> > > On Thu, Mar 15, 2012 at 1:14 AM, Johan  wrote:
> > > > Hi,
>
> > > > The ebook is now available and can be downloaded.
>
> > > > Johan
>
> > > > On Monday, March 12, 2012 8:18:43 AM UTC+1, Massimo Di Pierro wrote:
>
> > > >> The web2py recipes book is finally out:
>
> > > >>http://www.packtpub.com/**web2py-application-**
> > > >> development-recipes-to-master-**python-web-framework-cookbook/**book<
> >http://www.packtpub.com/web2py-application-development-recipes-to-mas...>
>
> > > >> Congratulations to all those who contributed.
>
> > > >> Massimo
>
> > > --
> > > --
> > > Regards,
> > > Bruce Wadehttp://
> > ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.f...quoted
> >  text -
>
> > > - Show quoted text -
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


Re: [web2py] Re: Cookbook found bug with web2py

2012-03-15 Thread Massimo Di Pierro
I remind you that web2py comes with markmin2pdf too. It should work with 
most utf8 characters.


On Thursday, 15 March 2012 17:52:24 UTC-5, Detectedstealth wrote:
>
> Thanks I will have to look into it, or possibly just use reportlab.
>
> On Thu, Mar 15, 2012 at 2:17 PM, Alan Etkin  wrote:
>
>> I belive Chinese is not ported to pypdf (the php software supported it
>> via a special class). AFAIK the chinese fonts BIG5 or GB must be
>> installed in the server. Maybe you could start an issue for adding it
>> in the project page.
>>
>> http://code.google.com/p/pyfpdf/
>>
>> On 15 mar, 17:53, Bruce Wade  wrote:
>> > Does pyfpdf support Chinese yet? I tried using Chinese by the characters
>> > were not rendered in Chinese. Or do I need to set some kind of font.
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Thu, Mar 15, 2012 at 1:35 PM, Alan Etkin  wrote:
>> > > That error page is likely to be sent because of the new generic view
>> > > security rule. I'm using the response.generic_patterns = ["*",] in the
>> > > controller file and it works well (the sentence wasn't included in the
>> > > original file).
>> >
>> > > On 15 mar, 17:15, Bruce Wade  wrote:
>> > > > Okay so the downloaded code the pdf works but the normal HTML view
>> > > doesn't.
>> >
>> > > > invalid view (default/report.html)
>> >
>> > > > On Thu, Mar 15, 2012 at 11:48 AM, Alan Etkin  
>> wrote:
>> > > > > I should check the code in the book, but I used a controller 
>> example
>> > > > > that should be available in the book's support files at
>> > > > >http://www.packtpub.com/supportandit worked for my environment:
>> >
>> > > > > Python 2.6.5
>> > > > > Mandriva GNU/Linux 2010
>> > > > > web2py (last mercurial version)
>> >
>> > > > > A complete working installer can be downloaded from the same url 
>> (in
>> > > > > the apps folder)
>> >
>> > > > > On Mar 15, 2:54 pm, Bruce Wade  wrote:
>> > > > > > Fresh blank version of web2py, in default controller:
>> >
>> > > > > > def report():
>> > > > > > import os
>> > > > > > response.title = "web2py sample report"
>> >
>> > > > > > # include a chart from google chart
>> > > > > > url = "
>> > > > >
>> http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=500x200&ch1.
>> > > ..
>> > > > > > "
>> > > > > > chart = IMG(_src=url, _width="250", _height="100")
>> >
>> > > > > > # create a small table with some data:
>> > > > > > rows = [THEAD(TR(TH("Key", _width="70%"),
>> > > > > > TH("Value", _width="30%"))),
>> > > > > > TBODY(TR(TD("Hello"), TD("60")),
>> > > > > > TR(TD("World"), TD("40")))]
>> >
>> > > > > > table = TABLE(*rows, _border="0", _align="center", 
>> _width="50%")
>> >
>> > > > > > if request.extension == "pdf":
>> > > > > > from gluon.contrib.pyfpdf import FPDF, HTMLMixin
>> >
>> > > > > > # create a custom class with the required 
>> functionalities
>> > > > > > class MyFPDF(FPDF, HTMLMixin):
>> > > > > > def header(self):
>> > > > > > "hook to draw custom page header (logo and 
>> title)"
>> >
>> > > > > > # remember to copy logo_pb.png to static/images 
>> (and
>> > > > > remove
>> > > > > > alpha channel)
>> > > > > > #logo = os.path.join(request.folder, "static",
>> > > "images",
>> > > > > > "logo_pb.png")
>> > > > > > #self.image(logo, 10, 8, 33)
>> > > > > > self.set_font("Arial", "B", 15)
>> > > > > > self.cell(65)   # padding
>> > > > > > self.cell(60, 10, response.title, 1, 0, 'C')
>> > > > > > self.ln(20)
>> >
>> > > > > > def footer(self):
>> > > > > > "hook to draw custom page footer (printing page
>> > > numbers)"
>> > > > > > self.set_y(-15)
>> > > > > > self.set_font('Arial', 'I', 8)
>> > > > > > txt = 'Page %s of %s' % (self.page_no(),
>> > > > > > self.alias_nb_pages())
>> > > > > > self.cell(0, 10, txt, 0, 0, 'C')
>> > > > > > pdf = MyFPDF()
>> >
>> > > > > > # create a page and serialize/render HTML 
>> objects
>> > > > > > pdf.add_page()
>> > > > > > pdf.write_html(table.xml())
>> > > > > > #pdf.write_html(CENTER(chart).xml())
>> >
>> > > > > > # prepare PDF to download:
>> > > > > > response.headers['Content-Type'] = 
>> 'application/pdf'
>> > > > > > return pdf.output(dest='S')
>> >
>> > > > > > # else normal html view
>> > > > > > return dict(chart=chart, table=table)
>> >
>> > > > > > I thought it was the logo so I commented it out, but still the 
>> exact
>> > > same
>> > > > > > error.
>> >
>> > > > > > Looks like it is failing here:
>> > > > > > def _parsepng(self, name):
>> > > > > > #Extract info from a PNG file
>> > > > > > if name.startswith("http://";) or 
>> name.startswith("https:/

Re: [web2py] Re: Cookbook found bug with web2py

2012-03-15 Thread Bruce Wade
Ok thanks I will try that, just looking for the easiest solution because we
need to generate a lot of invoices.

On Thu, Mar 15, 2012 at 4:57 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I remind you that web2py comes with markmin2pdf too. It should work with
> most utf8 characters.
>
>
> On Thursday, 15 March 2012 17:52:24 UTC-5, Detectedstealth wrote:
>>
>> Thanks I will have to look into it, or possibly just use reportlab.
>>
>> On Thu, Mar 15, 2012 at 2:17 PM, Alan Etkin  wrote:
>>
>>> I belive Chinese is not ported to pypdf (the php software supported it
>>> via a special class). AFAIK the chinese fonts BIG5 or GB must be
>>> installed in the server. Maybe you could start an issue for adding it
>>> in the project page.
>>>
>>> http://code.google.com/p/**pyfpdf/ 
>>>
>>> On 15 mar, 17:53, Bruce Wade  wrote:
>>> > Does pyfpdf support Chinese yet? I tried using Chinese by the
>>> characters
>>> > were not rendered in Chinese. Or do I need to set some kind of font.
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > On Thu, Mar 15, 2012 at 1:35 PM, Alan Etkin 
>>> wrote:
>>> > > That error page is likely to be sent because of the new generic view
>>> > > security rule. I'm using the response.generic_patterns = ["*",] in
>>> the
>>> > > controller file and it works well (the sentence wasn't included in
>>> the
>>> > > original file).
>>> >
>>> > > On 15 mar, 17:15, Bruce Wade  wrote:
>>> > > > Okay so the downloaded code the pdf works but the normal HTML view
>>> > > doesn't.
>>> >
>>> > > > invalid view (default/report.html)
>>> >
>>> > > > On Thu, Mar 15, 2012 at 11:48 AM, Alan Etkin 
>>> wrote:
>>> > > > > I should check the code in the book, but I used a controller
>>> example
>>> > > > > that should be available in the book's support files at
>>> > > > >http://www.packtpub.com/**supportanditworked
>>> > > > > for my environment:
>>> >
>>> > > > > Python 2.6.5
>>> > > > > Mandriva GNU/Linux 2010
>>> > > > > web2py (last mercurial version)
>>> >
>>> > > > > A complete working installer can be downloaded from the same url
>>> (in
>>> > > > > the apps folder)
>>> >
>>> > > > > On Mar 15, 2:54 pm, Bruce Wade  wrote:
>>> > > > > > Fresh blank version of web2py, in default controller:
>>> >
>>> > > > > > def report():
>>> > > > > > import os
>>> > > > > > response.title = "web2py sample report"
>>> >
>>> > > > > > # include a chart from google chart
>>> > > > > > url = "
>>> > > > >http://chart.apis.google.com/**chart?cht=p3&chd=t:60,40&chs=**
>>> 500x200&ch1
>>> .
>>> > > ..
>>> > > > > > "
>>> > > > > > chart = IMG(_src=url, _width="250", _height="100")
>>> >
>>> > > > > > # create a small table with some data:
>>> > > > > > rows = [THEAD(TR(TH("Key", _width="70%"),
>>> > > > > > TH("Value", _width="30%"))),
>>> > > > > > TBODY(TR(TD("Hello"), TD("60")),
>>> > > > > > TR(TD("World"), TD("40")))]
>>> >
>>> > > > > > table = TABLE(*rows, _border="0", _align="center",
>>> _width="50%")
>>> >
>>> > > > > > if request.extension == "pdf":
>>> > > > > > from gluon.contrib.pyfpdf import FPDF, HTMLMixin
>>> >
>>> > > > > > # create a custom class with the required
>>> functionalities
>>> > > > > > class MyFPDF(FPDF, HTMLMixin):
>>> > > > > > def header(self):
>>> > > > > > "hook to draw custom page header (logo and
>>> title)"
>>> >
>>> > > > > > # remember to copy logo_pb.png to
>>> static/images (and
>>> > > > > remove
>>> > > > > > alpha channel)
>>> > > > > > #logo = os.path.join(request.folder, "static",
>>> > > "images",
>>> > > > > > "logo_pb.png")
>>> > > > > > #self.image(logo, 10, 8, 33)
>>> > > > > > self.set_font("Arial", "B", 15)
>>> > > > > > self.cell(65)   # padding
>>> > > > > > self.cell(60, 10, response.title, 1, 0, 'C')
>>> > > > > > self.ln(20)
>>> >
>>> > > > > > def footer(self):
>>> > > > > > "hook to draw custom page footer (printing page
>>> > > numbers)"
>>> > > > > > self.set_y(-15)
>>> > > > > > self.set_font('Arial', 'I', 8)
>>> > > > > > txt = 'Page %s of %s' % (self.page_no(),
>>> > > > > > self.alias_nb_pages())
>>> > > > > > self.cell(0, 10, txt, 0, 0, 'C')
>>> > > > > > pdf = MyFPDF()
>>> >
>>> > > > > > # create a page and serialize/render HTML
>>> objects
>>> > > > > > pdf.add_page()
>>> > > > > > pdf.write_html(table.xml())
>>> > > > > > #pdf.write_html(CENTER(chart).**xml())
>>> >
>>> > > > > > # prepare PDF to download:
>>> > > > > > response.headers['Content-**Type'] =
>>> 'application/pdf'

[web2py] web2py course and certificate program online

2012-03-15 Thread Massimo Di Pierro
Hello everybody,

I am teaching the online IPD certificate program again in Spring:

http://www.cdm.depaul.edu/ipd/Programs/Pages/WebDevelopmentwithPython.aspx

Students enrolled will be able to view online lectures recorded by me and 
will work on a project of their choice for 5 weeks. At the end they will 
get a certificate of completion by the  CDM IPD. No need to say web2py is 
the framework covered in the lectures.

Massimo

 


[web2py] LDAP queries on all subdomains under root?

2012-03-15 Thread IVINH
Hi all,

This my code for LDAP:

   from gluon.contrib.login_methods.ldap_auth import ldap_auth 
   
auth.settings.login_methods.append(ldap_auth(mode='cn',server='myserver',base_dn='ou=subdomain1,o=domain,c=com',port=389))
 


This works fine when I explicitely query SUBDOMAIN1 with the users that are 
in that domain (user1, user2, ...)
My problem is that at runtime, I don't know what subdomain the users are 
from and I don't want to query all subdomains one after the other to find 
user information.
Is these a way to query the entire directory (root) for users without 
knowing what subdomains they are in? If not, is there another better way to 
do this?

Thank advance.





Re: [web2py] Re: How to check the extension of file from the controller

2012-03-15 Thread Sanjeet Kumar
Thanks Anthony correct Alan i tried this working fine

On Thu, Mar 15, 2012 at 10:14 PM, Alan Etkin  wrote:

> Anthony's answer is the right one, mine is for retrieving the
> extension of the url requested
>
> On 15 mar, 10:40, Anthony  wrote:
> > request.vars.image.filename.split('.')[-1]
> >
> > or
> >
> > import os
> > os.path.splitext(request.vars.image.filename)[1][1:]
> >
> > Anthony
> >
> >
> >
> >
> >
> >
> >
> > On Thursday, March 15, 2012 6:18:10 AM UTC-4, Sanjeet Kumar wrote:
> >
> > > I have the upload field in table i want to check the file extension
> from
> > > the controller during the upload i am using :-
> >
> > > SQLFORM.factory(db.emp_detail)
> > > if form.accepts(request.vars, session):
> > >  img = form.vars.image
> > > if file.extension == 'something':
> > >  update query
>


Re: [web2py] Correct way to use memcache on GAE with web2py

2012-03-15 Thread howesc
note that on GAE the web2py cache.ram, and cache.disk both point to 
memcache.

On Thursday, March 15, 2012 1:34:42 PM UTC-7, Jonathan Lundell wrote:
>
> On Mar 15, 2012, at 1:15 PM, Sushant Taneja wrote:
> > I have a tags table which will be available to all logged in users. The 
> table has the following structure:
> > 
> > db.define_table('META_TAG',
> > Field('tag','string',notnull=True),
> > Field('root_tag','string',notnull=True),
> > Field('active_ind','string',length=1,default='Y')
> > )
> > 
> > This table will be rarely (once a month) updated via an administrative 
> interface.
> > I read various web2py based examples and gae examples on using memcache. 
> Each followed a different approach.
> > As per my understanding from appengine documentation, I have written the 
> following helper function in a controller to use memcache:
> > 
> > from google.appengine.api import memcache
> > 
> > def get_tags():
> > """This function returns cached value for META_TAG table"""
> > tags = memcache.get("tags")
> > if not words:
> > words = 
> db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
> > memcache.add("tags",tags)
> > return tags
> > else:
> > return tags
> > 
> > Will the above code ensure that the correct data is always available in 
> the memcache ?
>
> You seem to be mixing the names 'words' and 'tags'.
>
> As a matter of style, I'd move the return outside the if/else.
>
> Don't forget to set the cache when you update the tags.
>
> It's best to test for 'is None', in case your cached object can 
> legitimately evaluate to False (an empty list or string, for example). So 
> more like:
>
> from google.appengine.api import memcache
>
> def get_tags():
> """This function returns cached value for META_TAG table"""
> tags = memcache.get("tags")
> if tags is None:
> tags = 
> db(db.META_TAG.active_ind=='Y').select(db.META_TAG.tag,db.META_TAG.root_tag)
> memcache.add("tags",tags)
> return tags
>
>

Re: [web2py] Modules on Google App Engine

2012-03-15 Thread howesc
if the library is self-contained, is not written in C, and does not use 
un-permitted features, you can just put the library in site-packages inside 
web2py and it will upload with your app.

On Thursday, March 15, 2012 5:56:49 AM UTC-7, Udi Milo wrote:
>
> I found the problem (which leads to a new problem).
> my module was using "import requests"
> requests is http://docs.python-requests.org/en/v0.10.7/index.html that I 
> have installed on my machine.
> I guess I need to tell web2py to install it when it deploys.
>
> do you know how I do that? and if its not possible, how to overcome this 
> issue?
>
> On Wednesday, March 14, 2012 11:32:20 PM UTC-4, rochacbruno wrote:
>>
>> I guess your module is trying to do something denied in GAE, some python 
>> std modules are not available on GAE, and also you cannot access filesystem.
>>
>> Another common problem is incompatibility with Python2.5
>>
>> Take a look at LOG tab at your google app engine admin page, may be the 
>> traceback is there.
>>
>> On Thu, Mar 15, 2012 at 12:19 AM, Udi Milo  wrote:
>>
>>> The thing is that locally, it works.
>>> only when I deploy to GAE it is missing...
>>>
>>> which files do you recommend I look into to try and find the reason for 
>>> this weird problem?
>>>
>>>
>>> On Tuesday, March 13, 2012 5:32:52 PM UTC-4, rochacbruno wrote:

 Maybe you have a syntax error or an error with imports inside the api 
 module, the web2py custom importer does not shows complete traceback for 
 that cases.

 On Tue, Mar 13, 2012 at 10:48 AM, Udi Milo  wrote:

> Hi all,
>
> I've added a new api.py file to the /modules directory.
> I've also added a call from my default.py "from api import Api"
>
> working locally, everything is fine.
> when deploying to GAE, I get 
>  No module named api
>
> can anyone suggest an answer to my problem?
>



 -- 

 Bruno Rocha
 [http://rochacbruno.com.br]


>>
>>
>> -- 
>>
>> Bruno Rocha
>> [http://rochacbruno.com.br]
>>
>>

Re: [web2py] Modules on Google App Engine

2012-03-15 Thread Bruno Rocha
requests module does not runs on python 2.5
https://github.com/kennethreitz/requests/issues/427

On Fri, Mar 16, 2012 at 1:52 AM, howesc  wrote:

> if the library is self-contained, is not written in C, and does not use
> un-permitted features, you can just put the library in site-packages inside
> web2py and it will upload with your app.
>
>
> On Thursday, March 15, 2012 5:56:49 AM UTC-7, Udi Milo wrote:
>>
>> I found the problem (which leads to a new problem).
>> my module was using "import requests"
>> requests is 
>> http://docs.python-**requests.org/en/v0.10.7/index.**htmlthat
>>  I have installed on my machine.
>> I guess I need to tell web2py to install it when it deploys.
>>
>> do you know how I do that? and if its not possible, how to overcome this
>> issue?
>>
>> On Wednesday, March 14, 2012 11:32:20 PM UTC-4, rochacbruno wrote:
>>>
>>> I guess your module is trying to do something denied in GAE, some python
>>> std modules are not available on GAE, and also you cannot access filesystem.
>>>
>>> Another common problem is incompatibility with Python2.5
>>>
>>> Take a look at LOG tab at your google app engine admin page, may be the
>>> traceback is there.
>>>
>>> On Thu, Mar 15, 2012 at 12:19 AM, Udi Milo  wrote:
>>>
 The thing is that locally, it works.
 only when I deploy to GAE it is missing...

 which files do you recommend I look into to try and find the reason for
 this weird problem?


 On Tuesday, March 13, 2012 5:32:52 PM UTC-4, rochacbruno wrote:
>
> Maybe you have a syntax error or an error with imports inside the api
> module, the web2py custom importer does not shows complete traceback for
> that cases.
>
> On Tue, Mar 13, 2012 at 10:48 AM, Udi Milo  wrote:
>
>> Hi all,
>>
>> I've added a new api.py file to the /modules directory.
>> I've also added a call from my default.py "from api import Api"
>>
>> working locally, everything is fine.
>> when deploying to GAE, I get
>>  No module named api
>>
>> can anyone suggest an answer to my problem?
>>
>
>
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>
>>>
>>>
>>> --
>>>
>>> Bruno Rocha
>>> [http://rochacbruno.com.br]
>>>
>>>


-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: How to check the extension of file from the controller

2012-03-15 Thread Ramkrishan Bhatt

Hello Sanjeet for file you dont have to identify the file extension, IN 
model itself you can validate the upload field . Please see the web2py 
cheatsheet and form or table validation its very easy to use. 
And still you want to know the file format please see the module function 
import sys.
On Thursday, 15 March 2012 15:48:10 UTC+5:30, Sanjeet Kumar wrote:
>
> I have the upload field in table i want to check the file extension from 
> the controller during the upload i am using :-
>
> SQLFORM.factory(db.emp_detail)
> if form.accepts(request.vars, session):
>  img = form.vars.image
> if file.extension == 'something':
>  update query
>


[web2py] Re: Generate the render the html file in to doc file

2012-03-15 Thread Ramkrishan Bhatt


On Thursday, 15 March 2012 16:45:53 UTC+5:30, Sanjeet Kumar wrote:
>
> How can i render the html file in to the doc file