Re: [web2py] Scaffolding app with Twitter OAuth1.0a auth

2010-08-30 Thread Michele Comitini
Actually if you look on developer.twitter.com, you will find some
library that maps the twitter REST api to
python methods.  But I did not relay on that as it would have added
more dependencies.
I think that is something that you can use depending the application
you are going to develop.

Things are simple even without external libraries, look for instance
at the get_user method in db.py, how it gets user info:
http://code.google.com/r/michelecomitini-facebookaccess/source/browse/applications/helloTwitter/models/db.py#81

def get_user(self):
if self.accessToken() is not None:
client = oauth.Client(self.consumer, self.accessToken())
resp, content =
client.request('http://api.twitter.com/1/account/verify_credentials.json')
if resp['status'] != '200':
# cannot get user info. should check status
return None
u = json.loads(content)
return dict(username=u['screen_name'], name=u['name'],
registration_id=u['id'])

so you build a client, make a request to a REST api url
(http://api.twitter.com/1/account/verify_credentials.json)

To post a tweet see: http://dev.twitter.com/doc/post/statuses/update

in your controller you should write something like this:

import oauth2 as oauth
.
.
.
@auth.requires_login()
def sendtweet():
  token = auth.settings.login_form.accessToken() # you can use this
also if you prefer: token=session.access_token
  consumer = oauth.Consumer(CLIENT_ID, CLIENT_SECRET) #<- CLIENT_ID,
CLIENT_SECRET are defined in db.py
  client = oauth.Client(self.consumer, token)
  # encode the message
  message = 'My web2py post!"
  data=urlencode(status=message)
  #make a post
  resp, content =
client.request('http://api.twitter.com/1/statuses/update.json',
"POST", body=data)
  if resp['status'] != '200':
#manage the error
return dict(message="Could not send tweet! :-( ")

  return dict(message="Succesfully sent! :-)")

if you call method returning some data I suggest tu use the .json
version of it and use
simplejson to decode it to a python dictionary (see the get_user() method above)

hope that helps...
mic

2010/8/30 Albert Abril :
> Just a question: what do you use for post a tweet, read statuses... ?
> Thanks in advance.
>
> On Sun, Aug 29, 2010 at 12:39 PM, Albert Abril 
> wrote:
>>
>> :) Thank you!
>>
>> On Sun, Aug 29, 2010 at 1:45 AM, Michele Comitini
>>  wrote:
>>>
>>> Hello all,
>>>
>>> I've uploaded a scaffolding app as example of authentication with
>>> twitter oauth.  You can find source code here:
>>>
>>>
>>> https://code.google.com/r/michelecomitini-facebookaccess/source/browse/#hg/applications/helloTwitter
>>>
>>> Or you can clone the repository locally:
>>> https://code.google.com/r/michelecomitini-facebookaccess/source/checkout
>>>
>>> as usual it is also on GAE for testing:
>>> http://grafbook.appspot.com/helloTwitter
>>>
>>> Please enjoy and send feedback.
>>>
>>> tnx
>>> michele
>>
>
>


[web2py] Re: web2py clone question - applications/welcome/ABOUT' is inside repo 'applications/welcome'

2010-08-30 Thread Christopher Steel
K,

I will just remove the nested repo.

Thanks

On 29 août, 18:52, mdipierro  wrote:
> I think hg does not support nested repos.
>
> Massimo
>
> On Aug 29, 5:18 pm, Chris Steel  wrote:
>
> > I created a clone of Web2py in order to make some contributions.
>
> > When I ran hg status after making some minor changes to default/user.html in
> > the Welcome application I got the following message:
>
> > hg status
>
> > abort: path 'applications/welcome/ABOUT' is inside repo
> > 'applications/welcome'
>
> > Do I need to use an hg addon or plugin for nesting repos?
>
> > Thanks,
>
> > Chris
>
> > --
> > Christopher Steel
>
> > Voice of Access


[web2py] Re: web2py clone question - applications/welcome/ABOUT' is inside repo 'applications/welcome'

2010-08-30 Thread Christopher Steel
The other Chris S is right.

It does, but it is a recent addition to hg and would add another layer
of complication. Eventually it could be helpful as a potential way to
distribute development tasks. For example, I feel comfortable working
on the Welcome app but not on Web2py itself I could just clone the
Welcome app repo. (Interestingly enough this is exactly how I feel at
the moment ;)).

Subrepos also has some other really interesting possibilities as well
regarding Web2py but when I checked it out I could not quite get it to
do what I wanted and the potential for unexpected side affects seemed
to be high... I am am sure this will be worked out in the future but I
am in no rush to complicate things for us.


Cheers,

Christopher Steel


On 30 août, 00:13, Chris S  wrote:
> You can use subrepos (http://mercurial.selenic.com/wiki/
> Subrepositories?action=show&redirect=subrepos) in mercurial.  Though I
> have only messed with it out of curiosity I can't say I've used it
> extensively.
>
> On Aug 29, 5:52 pm, mdipierro  wrote:
>
> > I think hg does not support nested repos.
>
> > Massimo
>
> > On Aug 29, 5:18 pm, Chris Steel  wrote:
>
> > > I created a clone of Web2py in order to make some contributions.
>
> > > When I ran hg status after making some minor changes to default/user.html 
> > > in
> > > the Welcome application I got the following message:
>
> > > hg status
>
> > > abort: path 'applications/welcome/ABOUT' is inside repo
> > > 'applications/welcome'
>
> > > Do I need to use an hg addon or plugin for nesting repos?
>
> > > Thanks,
>
> > > Chris
>
> > > --
> > > Christopher Steel
>
> > > Voice of Access


[web2py] successfully created tables can not be accessed

2010-08-30 Thread Benjamin Goll
Hi there,

first of all I would like to thank you for this great software! It's
just so much fun to create powerful applications with it!

Unfortunately I ran into a really strange problem which I'm not able
to solve.

In the file models/database.py I define the following:

db = DAL('sqlite://aubop.db')
db.define_table('track', Field('title'), Field('artist'),
Field('length'), Field('filepath'))
db.define_table('album', Field('title'), Field('artist'),
Field('tracks', 'list:reference track'), Field('currentTrack',
'reference track'), Field('currentPlaybackTime'), Field('rating',
'integer'))

When I then try to access one of the two defined tables in a
controller, I receive a KeyError, telling me, that e.g. db.album
cannot be found.
When I open the database "aubop.db" manually via the commandline-
interface of sqlite3, I can see that the two tables have been created
in the database:

sqlite3 aubop.db
sqlite> .tables
album  track

The sql.log also tells me that the tables ahve been created
successfully.

I then started web2py in the shell-mode ("python web2py.py -S aubop -
M"):

>>> db.tables
['auth_user', 'auth_group', 'auth_membership', 'auth_permission',
'auth_event']
>>> db = DAL('sqlite://aubop.db')
>>> db.tables
[]

That's strange, isn't it?

Is there anybody who could help me?

Btw. access to a different sqlite-database works like a charm in a
second application I've created earlier.

Thanks in advance!

Regards

Benjamin


[web2py] GAE: recipies to cope with long loading of pages?

2010-08-30 Thread Jurgis Pralgauskis
Hello,

I have my beta app
http://code.google.com/p/code-by-example/
on
http://web2py-gae-test.appspot.com/

which seems to load quite slowly
http://ftp.akl.lt/incoming/jurgio/gae-logs.png

I also tried logs,
http://ftp.akl.lt/incoming/jurgio/cbe.profile.txt
but don't see big problems (though i use profiling for the first
time..)


***
I recently made KEEP_CACHED = True

and for Session use Memcache
as I use session quite a bit

but still can't feel that its better


***
I also see info in logs:
This request caused a new process to be started for your application,
and thus caused your application code to be loaded for the first time.
This request may thus take longer and use more CPU than a typical
request for your application.


***
http://plugins.jquery.com/project/appear
might help me a bit,
as mostly used controller shows ~ 20% of what it loads

I tried web2py_component(action,target) {
 $('#'+target).appear(function() {
instead of
 jQuery(document).ready(function(){
but this did' t work :(


any suggestions ?


[web2py] Re: have you used web2py for teaching?

2010-08-30 Thread Jurgis Pralgauskis
I haven't, but I am going to do it this year.

one moment, which I remember from learning myself (PHP in earlier
days),
is that with web2py templates there is very low (not steep) curve to
start simple webdev -- as you can intermix code and html easy.

one could not now anything about controllers and use default for
beginning.

later compexity could be introduced step by step


On 30 Rugp, 03:54, mdipierro  wrote:
> If you use or have used web2py for teaching please let me know.
>
> The deadline for SIGCSE 2011 papers is next week. I am thinking of
> submitting a paper about the use of web2py as a teaching tool.
>
> If you have used web2py, you are welcome to be a coauthor of the paper
> but let me know before Sept 3. I can write a first draft but feel free
> to share any idea/content/suggestion about your experience.
>
> Massimo


[web2py] Re: successfully created tables can not be accessed

2010-08-30 Thread mdipierro
> >>> db = DAL('sqlite://aubop.db')
> >>> db.tables
> []
> That's strange, isn't it?

this is fine. In fact even if the tables are in db, web2py does not
discover them. You still need db.define_table(...) to inform web2py
about them.

I cannot say about the problem with the app, but could it be related
to this?

Massimo


On Aug 30, 7:56 am, Benjamin Goll  wrote:
> Hi there,
>
> first of all I would like to thank you for this great software! It's
> just so much fun to create powerful applications with it!
>
> Unfortunately I ran into a really strange problem which I'm not able
> to solve.
>
> In the file models/database.py I define the following:
>
> db = DAL('sqlite://aubop.db')
> db.define_table('track', Field('title'), Field('artist'),
> Field('length'), Field('filepath'))
> db.define_table('album', Field('title'), Field('artist'),
> Field('tracks', 'list:reference track'), Field('currentTrack',
> 'reference track'), Field('currentPlaybackTime'), Field('rating',
> 'integer'))
>
> When I then try to access one of the two defined tables in a
> controller, I receive a KeyError, telling me, that e.g. db.album
> cannot be found.
> When I open the database "aubop.db" manually via the commandline-
> interface of sqlite3, I can see that the two tables have been created
> in the database:
>
> sqlite3 aubop.db
> sqlite> .tables
> album  track
>
> The sql.log also tells me that the tables ahve been created
> successfully.
>
> I then started web2py in the shell-mode ("python web2py.py -S aubop -
> M"):
>
> >>> db.tables
>
> ['auth_user', 'auth_group', 'auth_membership', 'auth_permission',
> 'auth_event']>>> db = DAL('sqlite://aubop.db')
> >>> db.tables
>
> []
>
> That's strange, isn't it?
>
> Is there anybody who could help me?
>
> Btw. access to a different sqlite-database works like a charm in a
> second application I've created earlier.
>
> Thanks in advance!
>
> Regards
>
> Benjamin


[web2py] Re: GAE: recipies to cope with long loading of pages?

2010-08-30 Thread mdipierro
It is slow. does it contain a lot of code or a lot of DB IO? I cannot
say without looking at the code.

On Aug 30, 9:09 am, Jurgis Pralgauskis 
wrote:
> Hello,
>
> I have my beta apphttp://code.google.com/p/code-by-example/
> onhttp://web2py-gae-test.appspot.com/
>
> which seems to load quite slowlyhttp://ftp.akl.lt/incoming/jurgio/gae-logs.png
>
> I also tried logs,http://ftp.akl.lt/incoming/jurgio/cbe.profile.txt
> but don't see big problems (though i use profiling for the first
> time..)
>
> ***
> I recently made KEEP_CACHED = True
>
> and for Session use Memcache
> as I use session quite a bit
>
> but still can't feel that its better
>
> ***
> I also see info in logs:
> This request caused a new process to be started for your application,
> and thus caused your application code to be loaded for the first time.
> This request may thus take longer and use more CPU than a typical
> request for your application.
>
> ***http://plugins.jquery.com/project/appear
> might help me a bit,
> as mostly used controller shows ~ 20% of what it loads
>
> I tried web2py_component(action,target) {
>      $('#'+target).appear(function() {
> instead of
>      jQuery(document).ready(function(){
> but this did' t work :(
>
> any suggestions ?


[web2py] Re: successfully created tables can not be accessed

2010-08-30 Thread Benjamin Goll
Hello Massimo,

thank you for your fast reply!

Honestly I don't think that this is related to my problem since I only
tried to demonstrate my problem with this example.

If I define a table in a model, I should be able to access this table
without any further configuration, right? So when I do the two
db.define_table()-statements (as shown in my first post), I should be
able to access the tables in a controller via db.album or db.track
respectively.  Unfortunately this is not the case and results in a
KeyError. When I do db.tables in a controller, only the auth_*-tables
are listed.

Is there any possibility to see, if web2py fails while initializing
the db-object? Setting the debug-level to 0 seems not the help since
it does not list errors concerning the database.

Regards

Benjamin

On 30 Aug., 16:58, mdipierro  wrote:
> > >>> db = DAL('sqlite://aubop.db')
> > >>> db.tables
> > []
> > That's strange, isn't it?
>
> this is fine. In fact even if the tables are in db, web2py does not
> discover them. You still need db.define_table(...) to inform web2py
> about them.
>
> I cannot say about the problem with the app, but could it be related
> to this?
>
> Massimo
>
> On Aug 30, 7:56 am, Benjamin Goll  wrote:
>
> > Hi there,
>
> > first of all I would like to thank you for this great software! It's
> > just so much fun to create powerful applications with it!
>
> > Unfortunately I ran into a really strange problem which I'm not able
> > to solve.
>
> > In the file models/database.py I define the following:
>
> > db = DAL('sqlite://aubop.db')
> > db.define_table('track', Field('title'), Field('artist'),
> > Field('length'), Field('filepath'))
> > db.define_table('album', Field('title'), Field('artist'),
> > Field('tracks', 'list:reference track'), Field('currentTrack',
> > 'reference track'), Field('currentPlaybackTime'), Field('rating',
> > 'integer'))
>
> > When I then try to access one of the two defined tables in a
> > controller, I receive a KeyError, telling me, that e.g. db.album
> > cannot be found.
> > When I open the database "aubop.db" manually via the commandline-
> > interface of sqlite3, I can see that the two tables have been created
> > in the database:
>
> > sqlite3 aubop.db
> > sqlite> .tables
> > album  track
>
> > The sql.log also tells me that the tables ahve been created
> > successfully.
>
> > I then started web2py in the shell-mode ("python web2py.py -S aubop -
> > M"):
>
> > >>> db.tables
>
> > ['auth_user', 'auth_group', 'auth_membership', 'auth_permission',
> > 'auth_event']>>> db = DAL('sqlite://aubop.db')
> > >>> db.tables
>
> > []
>
> > That's strange, isn't it?
>
> > Is there anybody who could help me?
>
> > Btw. access to a different sqlite-database works like a charm in a
> > second application I've created earlier.
>
> > Thanks in advance!
>
> > Regards
>
> > Benjamin


[web2py] Re: dashes in controller names?

2010-08-30 Thread Cory Coager
I suppose I could pass in bogus arguments in the url with dashes that
never get used.  Still would be nice if the controllers would support
dashes.


[web2py] Re: Server fails every 3 hour

2010-08-30 Thread howesc
I've not done much heavy lifting with the taskqueue, but when i have
long running tasks i have broken them up into chunks that run in 30
seconds or less.  i call the task with something like:

for user in db(db.auth_user.id>0).select():
for question in db(db.question.id>0).select():
taskqueue.add(url=URL(r=request,
f='aggregate_user_by_month'),
  params={'user': user.id,
  'q': question.id})

and then the method processing some things.  if it fails because it
tried to process too many, i requeue with a param to process 1/2 as
many objects, otherwise i requeue with the next set to process:

try
  ...
except DeadlineExceededError:
#reprocess with 1/2 as many responses.
taskqueue.add(url=URL(r=request), params={'user':
request.vars.user,
  'q': request.vars.q,
  'limit':limit/2})
return

if responses and \
   responses[-1].updated_on != last_processed_timestamp:
#we had some responses, so schedule more processing until no
responses
# are found
taskqueue.add(url=URL(r=request), params={'user':
request.vars.user,
  'q':
request.vars.q})


this is all using the default queue on GAE.  let me know if you have
more specific questions about how i'm using it.

cfh

On Aug 28, 7:34 am, Michael Ellis  wrote:
> At the moment, I'm mostly interested in knowing how to use taskqueue to set
> up a background email notification system.  My web2py app is for group
> collaboration and there are situations where all members of a group needed
> to be notified of changes.
>
> The taskqueue API seems straightforward, but it would help to see a working
> example of its use and configuration in web2py.  Can it be really simple,
> e.g. enqueueing a controller URL that  accesses  a table in my app
> containing email addresses and messages to be sent?
>
> On Sat, Aug 28, 2010 at 10:19 AM, Kevin  wrote:
> > Yeah, the gae cron is a lot different than the web2py cron (which is
> > based on traditional crons), because web2py supports any process or
> > internal controller, while GAE only support calling relative URLs in
> > their cron.
>
> > In any case, it'd be nice to have a compatibility layer -- if you
> > don't need anything more than what GAE's method provides (calling some
> > internal controller's function), then perhaps we can make web2py
> > support cron.yaml in non-gae deployments, to where it essentially
> > loads the GAE cron jobs as though they were ** tasks?
>
> > On Aug 28, 7:21 am, mdipierro  wrote:
> > > No but cron does not work on gae either. On gae you can use taskque.
>
> > > On Aug 28, 7:25 am, Michael Ellis  wrote:
>
> > > > Massimo, can the technique described in the book be used on GAE?
> > > > Thx,
> > > > Mike
>
> > > > On Aug 27, 10:23 pm, Bruno Rocha  wrote:
>
> > > > > Thanks Massimo.
> > > > > ,
>
> > > > > 2010/8/27 mdipierro 
>
> > > > > > Run the web server with -N (no cron) and run a separate backrgound
> > > > > > process for cron. Anyway, there is no way to control how much
> > memory
> > > > > > cron consumes if a cron task takes longer than expected. It is
> > safer
> > > > > > not to use cron (-N) and use this instead:
>
> >http://www.web2py.com/book/default/chapter/04#Background-Processes-an...
>
> > > > > > Massimo
>
> > > > > > On Aug 27, 7:18 pm, Bruno Rocha  wrote:
> > > > > > > Hi,
>
> > > > > > > I am running a web2py application at my home server,
> > > > > > > that is published and I have some clients using for accurracy
> > tests.
>
> > > > > > > But , every 3 hours+- the server fails with the message
>
> > > > > > > Exception in thread Thread-20:
>
> > > > > > > Traceback (most recent call last):
>
> > > > > > >   File "/usr/lib/python2.6/threading.py", line 532, in
> > __bootstrap_inner
>
> > > > > > >     self.run()
>
> > > > > > >   File "/home/bruno/web2py/gluon/newcron.py", line 206, in run
>
> > > > > > >     shell=self.shell)
>
> > > > > > >   File "/usr/lib/python2.6/subprocess.py", line 633, in __init__
>
> > > > > > >     errread, errwrite)
>
> > > > > > >   File "/usr/lib/python2.6/subprocess.py", line 1049, in
> > _execute_child
>
> > > > > > >     self.pid = os.fork()
>
> > > > > > > OSError: [Errno 12] Do not possible to allocate memory
>
> > > > > > > I can see newcron.py is the problem there, but I need to use
> > cron,
> > > > > > > this could be a problem with my OS or machine, or it is a Rocket
> > problem?
>
> > > > > > > --
>
> > > > > > >http://rochacbruno.com.br
>
> > > > > --
>
> > > > >http://rochacbruno.com.br


[web2py] Online Python Debugger - see how the code is executed! Cool

2010-08-30 Thread Bruno Rocha
http://people.csail.mit.edu/pgbovine/python/


[web2py] Re: ANN: first pre-alfa release (v0.2) of Web2Py_CC

2010-08-30 Thread Pai
Stef,

did you get a chance to upload a new file?  I tried again and same
error.  sorry for being persistence.  I'm actually really excited
about this.  I having WingIDE but I'm actually a lot more excited
about using this!

Pai

On Aug 27, 5:15 pm, Stef Mientki  wrote:
>  On 27-08-2010 22:32, Pai wrote:> I ran it, got error
>
> > D:\Development\python\web2py_cc\Web2Py>python Web2py_CC.py
> > Traceback (most recent call last):
> >   File "Web2py_CC.py", line 15, in 
> >     """]
> > TypeError: list indices must be integers, not tuple
>
> sorry I uploaded the wrong file.
> cheers,
> Stef
>
> > Pai
>
> > On Aug 27, 3:13 pm, Stef Mientki  wrote:
> >>  hello,
>
> >> I'm proud to  present the first pre-alfa release of Web2Py_CC.
>
> >> *Windows*: as it's developed under windows, it runs without exceptions 
> >> (and of course a few bugs ;-)
> >> Sorry, I wasn't  able to produce an executable, because py2exe had 
> >> problems (probably with my
> >> recently upgraded wxPython, and I can't go back).
>
> >> *Fedora 13*: runs as expected
>
> >> *Ubuntu 10*: 2 days ago, it runned as expected, but after an adviced 
> >> upgrade of wxPython, my
> >> complete Ubuntu installation is ruined.
>
> >> *Mac*: sorry I've no access to Mac
>
> >> you can find some documentation here:
> >>  http://mientki.ruhosting.nl/web2py/web2py_cc.html
> >> a download link and installation instructions are at the bottom of the 
> >> above page.
>
> >> have fun,
> >> Stef


[web2py] Re: GAE: recipies to cope with long loading of pages?

2010-08-30 Thread Chris S
The version of web2py in trunk has already been patched to use app
stats.
http://googleappengine.blogspot.com/2010/03/easy-performance-profiling-with.html

It might help a little.  Most likely on GAE it's DBIO that slows it
down.

On Aug 30, 10:01 am, mdipierro  wrote:
> It is slow. does it contain a lot of code or a lot of DB IO? I cannot
> say without looking at the code.
>
> On Aug 30, 9:09 am, Jurgis Pralgauskis 
> wrote:
>
>
>
> > Hello,
>
> > I have my beta apphttp://code.google.com/p/code-by-example/
> > onhttp://web2py-gae-test.appspot.com/
>
> > which seems to load quite 
> > slowlyhttp://ftp.akl.lt/incoming/jurgio/gae-logs.png
>
> > I also tried logs,http://ftp.akl.lt/incoming/jurgio/cbe.profile.txt
> > but don't see big problems (though i use profiling for the first
> > time..)
>
> > ***
> > I recently made KEEP_CACHED = True
>
> > and for Session use Memcache
> > as I use session quite a bit
>
> > but still can't feel that its better
>
> > ***
> > I also see info in logs:
> > This request caused a new process to be started for your application,
> > and thus caused your application code to be loaded for the first time.
> > This request may thus take longer and use more CPU than a typical
> > request for your application.
>
> > ***http://plugins.jquery.com/project/appear
> > might help me a bit,
> > as mostly used controller shows ~ 20% of what it loads
>
> > I tried web2py_component(action,target) {
> >      $('#'+target).appear(function() {
> > instead of
> >      jQuery(document).ready(function(){
> > but this did' t work :(
>
> > any suggestions ?


Re: [web2py] Re: uWSGI examples page updated for web2py

2010-08-30 Thread Roberto De Ioris

> Hi Roberto,
>
> I can use this setting in version 0.9.5?
>
> José
>

Hi, yesterday the 0.9.6 version has been released

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



[web2py] Re: successfully created tables can not be accessed

2010-08-30 Thread mdipierro
which web2py version are you using?

what you get if you print db.tables immediately after
db.define_table()

On Aug 30, 10:33 am, Benjamin Goll  wrote:
> Hello Massimo,
>
> thank you for your fast reply!
>
> Honestly I don't think that this is related to my problem since I only
> tried to demonstrate my problem with this example.
>
> If I define a table in a model, I should be able to access this table
> without any further configuration, right? So when I do the two
> db.define_table()-statements (as shown in my first post), I should be
> able to access the tables in a controller via db.album or db.track
> respectively.  Unfortunately this is not the case and results in a
> KeyError. When I do db.tables in a controller, only the auth_*-tables
> are listed.
>
> Is there any possibility to see, if web2py fails while initializing
> the db-object? Setting the debug-level to 0 seems not the help since
> it does not list errors concerning the database.
>
> Regards
>
> Benjamin
>
> On 30 Aug., 16:58, mdipierro  wrote:
>
> > > >>> db = DAL('sqlite://aubop.db')
> > > >>> db.tables
> > > []
> > > That's strange, isn't it?
>
> > this is fine. In fact even if the tables are in db, web2py does not
> > discover them. You still need db.define_table(...) to inform web2py
> > about them.
>
> > I cannot say about the problem with the app, but could it be related
> > to this?
>
> > Massimo
>
> > On Aug 30, 7:56 am, Benjamin Goll  wrote:
>
> > > Hi there,
>
> > > first of all I would like to thank you for this great software! It's
> > > just so much fun to create powerful applications with it!
>
> > > Unfortunately I ran into a really strange problem which I'm not able
> > > to solve.
>
> > > In the file models/database.py I define the following:
>
> > > db = DAL('sqlite://aubop.db')
> > > db.define_table('track', Field('title'), Field('artist'),
> > > Field('length'), Field('filepath'))
> > > db.define_table('album', Field('title'), Field('artist'),
> > > Field('tracks', 'list:reference track'), Field('currentTrack',
> > > 'reference track'), Field('currentPlaybackTime'), Field('rating',
> > > 'integer'))
>
> > > When I then try to access one of the two defined tables in a
> > > controller, I receive a KeyError, telling me, that e.g. db.album
> > > cannot be found.
> > > When I open the database "aubop.db" manually via the commandline-
> > > interface of sqlite3, I can see that the two tables have been created
> > > in the database:
>
> > > sqlite3 aubop.db
> > > sqlite> .tables
> > > album  track
>
> > > The sql.log also tells me that the tables ahve been created
> > > successfully.
>
> > > I then started web2py in the shell-mode ("python web2py.py -S aubop -
> > > M"):
>
> > > >>> db.tables
>
> > > ['auth_user', 'auth_group', 'auth_membership', 'auth_permission',
> > > 'auth_event']>>> db = DAL('sqlite://aubop.db')
> > > >>> db.tables
>
> > > []
>
> > > That's strange, isn't it?
>
> > > Is there anybody who could help me?
>
> > > Btw. access to a different sqlite-database works like a charm in a
> > > second application I've created earlier.
>
> > > Thanks in advance!
>
> > > Regards
>
> > > Benjamin


[web2py] Re: successfully created tables can not be accessed

2010-08-30 Thread Benjamin Goll
Hello Massimo,

I'm using web2py version 1.83.2.

When I define the tables in shell-mode, everything looks fine:

python web2py.py -S aubop -M
>>> db = DAL('sqlite://aubop.db')
>>> db.define_table('track', Field('title'), Field('artist'), Field('length'), 
>>> Field('filepath'))
, [...]
>>> db.define_table('album', Field('title'), Field('artist'), Field('tracks', 
>>> 'list:reference track'), Field('currentTrack', 'reference track'), 
>>> Field('currentPlaybackTime'), Field('rating', 'integer'))
, [...]
>>> db.tables
['track', 'album']

I then tried to log the output of db.tables immediatelly after the two
db.define_table()s in the model-file "database.py":

db = DAL('sqlite://aubop.db')
db.define_table('track', Field('title'), Field('artist'),
Field('length'), Field('filepath'))
db.define_table('album', Field('title'), Field('artist'),
Field('tracks', 'list:reference track'), Field('currentTrack',
'reference track'), Field('currentPlaybackTime'), Field('rating',
'integer'))
f = open("test.log", "w")
for d in db.tables:
f.write(d)

Unfortunately the created file is empty. Do you have any idea why?

Regards

Benjamin


On 30 Aug., 20:38, mdipierro  wrote:
> which web2py version are you using?
>
> what you get if you print db.tables immediately after
> db.define_table()
>
> On Aug 30, 10:33 am, Benjamin Goll  wrote:
>
> > Hello Massimo,
>
> > thank you for your fast reply!
>
> > Honestly I don't think that this is related to my problem since I only
> > tried to demonstrate my problem with this example.
>
> > If I define a table in a model, I should be able to access this table
> > without any further configuration, right? So when I do the two
> > db.define_table()-statements (as shown in my first post), I should be
> > able to access the tables in a controller via db.album or db.track
> > respectively.  Unfortunately this is not the case and results in a
> > KeyError. When I do db.tables in a controller, only the auth_*-tables
> > are listed.
>
> > Is there any possibility to see, if web2py fails while initializing
> > the db-object? Setting the debug-level to 0 seems not the help since
> > it does not list errors concerning the database.
>
> > Regards
>
> > Benjamin
>
> > On 30 Aug., 16:58, mdipierro  wrote:
>
> > > > >>> db = DAL('sqlite://aubop.db')
> > > > >>> db.tables
> > > > []
> > > > That's strange, isn't it?
>
> > > this is fine. In fact even if the tables are in db, web2py does not
> > > discover them. You still need db.define_table(...) to inform web2py
> > > about them.
>
> > > I cannot say about the problem with the app, but could it be related
> > > to this?
>
> > > Massimo
>
> > > On Aug 30, 7:56 am, Benjamin Goll  wrote:
>
> > > > Hi there,
>
> > > > first of all I would like to thank you for this great software! It's
> > > > just so much fun to create powerful applications with it!
>
> > > > Unfortunately I ran into a really strange problem which I'm not able
> > > > to solve.
>
> > > > In the file models/database.py I define the following:
>
> > > > db = DAL('sqlite://aubop.db')
> > > > db.define_table('track', Field('title'), Field('artist'),
> > > > Field('length'), Field('filepath'))
> > > > db.define_table('album', Field('title'), Field('artist'),
> > > > Field('tracks', 'list:reference track'), Field('currentTrack',
> > > > 'reference track'), Field('currentPlaybackTime'), Field('rating',
> > > > 'integer'))
>
> > > > When I then try to access one of the two defined tables in a
> > > > controller, I receive a KeyError, telling me, that e.g. db.album
> > > > cannot be found.
> > > > When I open the database "aubop.db" manually via the commandline-
> > > > interface of sqlite3, I can see that the two tables have been created
> > > > in the database:
>
> > > > sqlite3 aubop.db
> > > > sqlite> .tables
> > > > album  track
>
> > > > The sql.log also tells me that the tables ahve been created
> > > > successfully.
>
> > > > I then started web2py in the shell-mode ("python web2py.py -S aubop -
> > > > M"):
>
> > > > >>> db.tables
>
> > > > ['auth_user', 'auth_group', 'auth_membership', 'auth_permission',
> > > > 'auth_event']>>> db = DAL('sqlite://aubop.db')
> > > > >>> db.tables
>
> > > > []
>
> > > > That's strange, isn't it?
>
> > > > Is there anybody who could help me?
>
> > > > Btw. access to a different sqlite-database works like a charm in a
> > > > second application I've created earlier.
>
> > > > Thanks in advance!
>
> > > > Regards
>
> > > > Benjamin


[web2py] Re: GAE: recipies to cope with long loading of pages?

2010-08-30 Thread Jurgis Pralgauskis
it seems quite slow on my eeepc as well

yes, dbio is probably the problem,

as generating those pages includes mostly getting values I'll try
http://web2py.com/book/default/chapter/06#Caching-Selects
by the way is there API to force select caching globally in all app,
or just per query?



On 30 Rugp, 20:09, Chris S  wrote:
> The version of web2py in trunk has already been patched to use app
> stats.http://googleappengine.blogspot.com/2010/03/easy-performance-profilin...
>
> It might help a little.  Most likely on GAE it's DBIO that slows it
> down.
>
> On Aug 30, 10:01 am, mdipierro  wrote:
>
>
>
> > It is slow. does it contain a lot of code or a lot of DB IO? I cannot
> > say without looking at the code.
>
> > On Aug 30, 9:09 am, Jurgis Pralgauskis 
> > wrote:
>
> > > Hello,
>
> > > I have my beta apphttp://code.google.com/p/code-by-example/
> > > onhttp://web2py-gae-test.appspot.com/
>
> > > which seems to load quite 
> > > slowlyhttp://ftp.akl.lt/incoming/jurgio/gae-logs.png
>
> > > I also tried logs,http://ftp.akl.lt/incoming/jurgio/cbe.profile.txt
> > > but don't see big problems (though i use profiling for the first
> > > time..)
>
> > > ***
> > > I recently made KEEP_CACHED = True
>
> > > and for Session use Memcache
> > > as I use session quite a bit
>
> > > but still can't feel that its better
>
> > > ***
> > > I also see info in logs:
> > > This request caused a new process to be started for your application,
> > > and thus caused your application code to be loaded for the first time.
> > > This request may thus take longer and use more CPU than a typical
> > > request for your application.
>
> > > ***http://plugins.jquery.com/project/appear
> > > might help me a bit,
> > > as mostly used controller shows ~ 20% of what it loads
>
> > > I tried web2py_component(action,target) {
> > >      $('#'+target).appear(function() {
> > > instead of
> > >      jQuery(document).ready(function(){
> > > but this did' t work :(
>
> > > any suggestions ?


[web2py] Re: GAE: recipies to cope with long loading of pages?

2010-08-30 Thread Jurgis Pralgauskis
I quite use reference fields -- maybe thats the problem...
 can this be cached the way select is?

sth like
db.define_table("Topics",
  Field("parent_id","reference Topics", label=T("Parent
Topic"),   ),
  Field("name", "string")
)

db.define_table("Examples",
  Field("topic_id", db.Topics, label="Topic",),
  Field("lang_id", db.Languages,label="Language", ),
 )

and I use
db.Language[example.lang_id]
or
db.Topics[ db.Topics[example.topic_id].parent_id ]



On 30 Rugp, 18:01, mdipierro  wrote:
> It is slow. does it contain a lot of code or a lot of DB IO? I cannot
> say without looking at the code.
>
> On Aug 30, 9:09 am, Jurgis Pralgauskis 
> wrote:
>
>
>
> > Hello,
>
> > I have my beta apphttp://code.google.com/p/code-by-example/
> > onhttp://web2py-gae-test.appspot.com/
>
> > which seems to load quite 
> > slowlyhttp://ftp.akl.lt/incoming/jurgio/gae-logs.png
>
> > I also tried logs,http://ftp.akl.lt/incoming/jurgio/cbe.profile.txt
> > but don't see big problems (though i use profiling for the first
> > time..)
>
> > ***
> > I recently made KEEP_CACHED = True
>
> > and for Session use Memcache
> > as I use session quite a bit
>
> > but still can't feel that its better
>
> > ***
> > I also see info in logs:
> > This request caused a new process to be started for your application,
> > and thus caused your application code to be loaded for the first time.
> > This request may thus take longer and use more CPU than a typical
> > request for your application.
>
> > ***http://plugins.jquery.com/project/appear
> > might help me a bit,
> > as mostly used controller shows ~ 20% of what it loads
>
> > I tried web2py_component(action,target) {
> >      $('#'+target).appear(function() {
> > instead of
> >      jQuery(document).ready(function(){
> > but this did' t work :(
>
> > any suggestions ?


[web2py] Re: dashes in controller names?

2010-08-30 Thread Kevin
That last point of yours is why I feel the way I do: the slug is
redundant.  Then again, I'm not the kind of programmer to put SEO
ahead of cleanliness.

For example, if the original URL were:

http://myblog.com/articles/5/net-neutrality-and-you

Then I'd expect the following URL to fail:

http://myblog.com/articles/5/nothing-here

(However, it would return a 200 status code with the same article).

As a user, I would find that surprising, and as a user, I never want
to be surprised.

On Aug 26, 10:19 am, villas  wrote:
> On Aug 26, 1:38 am, Kevin  wrote:
>
> > I personally consider hybridized URLs like  > net-neutrality-and-you> to be junk because there are two unique
> > identifiers in the URL).
>
> Hi Kevin,
>
> Your post was interesting and I was curious about your strong view in
> your comment above.
>
> I always thought this kind of URL was most useful for SEO. You can
> correct misspelt slugs, and even improve slugs, without any previously
> indexed URLs giving 404s.  That's a huge benefit, isn't it?  In any
> case, in your URL example, I would say there's one identifier, the id.
> The slug is redundant.
>
> Just wondering if I missed something...
> Thanks, David


[web2py] Re: list:string not working [solved]

2010-08-30 Thread yamandu
I wrote a slice for my solution on this purpose.
http://web2pyslices.com/main/slices/take_slice/94

It uses jQuery for a better interaction altough it needs a bit of
styling.

On Aug 27, 2:06 pm, yamandu  wrote:
> Massimo, that gave me a ticket with this:
> Traceback (most recent call last):
>   File "C:\repo\anima\gluon\restricted.py", line 186, in restricted
>     exec ccode in environment
>   File "C:/repo/anima/applications/welcome/controllers/default.py",
> line 754, in 
>   File "C:\repo\anima\gluon\globals.py", line 96, in 
>     self._caller = lambda f: f()
>   File "C:/repo/anima/applications/welcome/controllers/default.py",
> line 553, in editar_diag_beta
>     form =
> crud.update(db.diagnostico_beta,request.args(0),deletable=False)
>   File "C:\repo\anima\gluon\tools.py", line 2756, in update
>     hideerror=self.settings.hideerror):
>   File "C:\repo\anima\gluon\sqlhtml.py", line 906, in accepts
>     hideerror=hideerror,
>   File "C:\repo\anima\gluon\html.py", line 1512, in accepts
>     status = self._traverse(status,hideerror)
>   File "C:\repo\anima\gluon\html.py", line 522, in _traverse
>     newstatus = c._traverse(status,hideerror) and newstatus
>   File "C:\repo\anima\gluon\html.py", line 522, in _traverse
>     newstatus = c._traverse(status,hideerror) and newstatus
>   File "C:\repo\anima\gluon\html.py", line 522, in _traverse
>     newstatus = c._traverse(status,hideerror) and newstatus
>   File "C:\repo\anima\gluon\html.py", line 522, in _traverse
>     newstatus = c._traverse(status,hideerror) and newstatus
>   File "C:\repo\anima\gluon\html.py", line 529, in _traverse
>     newstatus = self._validate()
>   File "C:\repo\anima\gluon\html.py", line 1300, in _validate
>     (value, errors) = validator(value)
> ValueError: too many values to unpack
>
> But I had already succeed with this:
> class TAGS_LIST:
>     def __init__(self, separator=',', error_message='This is not a
> valid list!'):
>         self.separator = separator
>         self.e = error_message
>
>     def __call__(self,value):
>         try:
>             list = value.split(self.separator)
>             return (list, None)
>         except:
>             return (value, self.e)
>
>     def formatter(self, value):
>         tags = ''
>         for tag in value:
>             tags += '%(tag)s%(sep)s ' %
> {'tag':tag,'sep':self.separator}
>         return tags
>
> I have two question:
> Could this be general relating different DBs?
> Is there a way to define a default widget for a custom validator?
>
> On Aug 26, 7:28 pm, mdipierro  wrote:
>
> > try define
>
> > class IS_LIST_OF_STRINGS:
> >     def __call__(self,value):
> >          return [str(x) for x in value.split(',')]
> >     def formatter(self,value):
> >          return ', '.join(value)
>
> > and use
>
> >     Field(...,'list:string',requires=IS_LIST_OF_STRINGS())
>
> > On Aug 26, 4:27 pm,yamandu wrote:
>
> > > Yes, I wish I could let the user input strings that don´t belong to
> > > predetermined set.
> > > A type of list that can add new itens does not make much sense for me.
> > > This is just a multi select, not properly a list in its most
> > > meaningful sense.
>
> > > On Aug 26, 5:36 pm, mdipierro  wrote:
>
> > > > This is not wrong.
>
> > > > The problem is that your field has type='list:string' but you did not
> > > > set requires=IS_IN_SET(('aaa','bbb','ccc')) or requires=IS_IN_DB(...)
> > > > Without the validator web2py does not know which options are valid and
> > > > which ones are not and does not know how to make a dropbox.
>
> > > > You have a valid point though. There should be a default validator
> > > > that allows to write strings separated by a comma or something like
> > > > plugin tagging. Such validator has not yet been created.
>
> > > > On Aug 26, 3:27 pm,yamandu wrote:> I possibly 
> > > > found a problem with list:string field.
> > > > > I´ve searched for a widget and I could found one for it.
> > > > > So I starte to make my own based on 
> > > > > thishttp://blog.crazybeavers.se/wp-content/demos/jquery.tag.editor/
> > > > > I could be like that tag editor in plugin_wiki too but I found it
> > > > > harder to base on it.
>
> > > > > The problem is when you update a field of type list:string using the
> > > > > item1|item2|... syntax it parses correctly and saves like array
> > > > > ['item1','item2']
> > > > > But if you update the record it shows like ['item1','item2'] and if
> > > > > you simply save it without editing it saves as ['['item1','item2']']
>
> > > > > I think the correct would it to reverse parse it to the | syntax, via
> > > > > widget maybe.
> > > > > If it was like this it would be simpler to adpat the above mentioned
> > > > > jQuery plugin.
> > > > > But the way it is it´s need to do two types of parses.
>
> > > > > Is this really wrong or not?
>
>


[web2py] Re: dashes in controller names?

2010-08-30 Thread Cory Coager
You're 100% correct.  However, since the functionality is lacking I
would use this as a workaround for SEO.

On Aug 30, 3:37 pm, Kevin  wrote:
> That last point of yours is why I feel the way I do: the slug is
> redundant.  Then again, I'm not the kind of programmer to put SEO
> ahead of cleanliness.
>
> For example, if the original URL were:
>
> http://myblog.com/articles/5/net-neutrality-and-you
>
> Then I'd expect the following URL to fail:
>
> http://myblog.com/articles/5/nothing-here
>
> (However, it would return a 200 status code with the same article).
>
> As a user, I would find that surprising, and as a user, I never want
> to be surprised.


Re: [web2py] Re: ANN: first pre-alfa release (v0.2) of Web2Py_CC

2010-08-30 Thread Stef Mientki
 On 30-08-2010 18:41, Pai wrote:
> Stef,
>
> did you get a chance to upload a new file?  I tried again and same
> error.
probably I made another mistake,
I uploaded again,
and renamed the file (my Mozilla cached the download)
Notes:
http://mientki.ruhosting.nl/web2py/web2py_cc.html

This should be the file to download
http://mientki.ruhosting.nl/web2py/web2py_cc_0_2.zip
>   sorry for being persistence.
No trouble, it's good to point onto problems !
>   I'm actually really excited
> about this.  I having WingIDE but I'm actually a lot more excited
> about using this!
Great.
cheers,
Stef
> Pai



Re: [web2py] Re: ANN: first pre-alfa release (v0.2) of Web2Py_CC

2010-08-30 Thread Stef Mientki
 On 29-08-2010 23:23, qqsaqq wrote:
> firstly, thank you very much for your work!
>
> I'm trying to get web2py_cc running (on Win7 64bit with Python 2.6.6
> 32bit), but I'm not quite there.
>
> Two short notes on the dependencies:
>
> -  scince one dependency you mention on your site is psutil, you need
> a 32bit version of Python. Apparently, you can't install psutil with
> the 64bit version, at least I was not able to do so, I had to swtich
> my Python installation to the 32bit version.
>
> - There is an additional depency, you might want to mention on your
> website: the module configobj (http://pypi.python.org/pypi/configobj/
> 4.6.0) must be on sys.path. Otherwise you get an error like
thanks,
I've made a note about these on my page.

cheers,
Stef
>
> C:\Users\me\Desktop\web2py_win..1.83.1\Web2py_CC
> \Web2Py>run_web2py_cc.py
> Traceback (most recent call last):
>   File "C:\Users\me\Desktop\web2py_win..1.83.1\Web2py_CC\Web2Py
> \run_web2py_cc.py
> ", line 3, in 
> import Web2py_CC
>   File "C:\Users\me\Desktop\web2py_win..1.83.1\Web2py_CC\Web2Py
> \Web2py_CC.py", l
> ine 19, in 
> from   gui_support  import *
>   File "C:\Users\me\Desktop\web2py_win..1.83.1\Web2py_CC\support
> \gui_support.py"
> , line 10, in 
> from language_support import  Language_Current, Set_Language,
> Flag_Object
>   File "C:\Users\me\Desktop\web2py_win..1.83.1\Web2py_CC\support
> \language_suppor
> t.py", line 254, in 
> from General_Globals import *
>   File "C:\Users\me\Desktop\web2py_win..1.83.1\Web2py_CC\support
> \General_Globals
> .py", line 674, in 
> from inifile_support import inifile
>   File "C:\Users\me\Desktop\web2py_win..1.83.1\Web2py_CC\support
> \inifile_support
> .py", line 130, in 
> from configobj import ConfigObj
> ImportError: No module named configobj
>
> On Aug 28, 12:15 am, Stef Mientki  wrote:
>>  On 27-08-2010 22:32, Pai wrote:> I ran it, got error
>>
>>> D:\Development\python\web2py_cc\Web2Py>python Web2py_CC.py
>>> Traceback (most recent call last):
>>>   File "Web2py_CC.py", line 15, in 
>>> """]
>>> TypeError: list indices must be integers, not tuple
>> sorry I uploaded the wrong file.
>> cheers,
>> Stef
>>
>>> Pai
>>> On Aug 27, 3:13 pm, Stef Mientki  wrote:
  hello,
 I'm proud to  present the first pre-alfa release of Web2Py_CC.
 *Windows*: as it's developed under windows, it runs without exceptions 
 (and of course a few bugs ;-)
 Sorry, I wasn't  able to produce an executable, because py2exe had 
 problems (probably with my
 recently upgraded wxPython, and I can't go back).
 *Fedora 13*: runs as expected
 *Ubuntu 10*: 2 days ago, it runned as expected, but after an adviced 
 upgrade of wxPython, my
 complete Ubuntu installation is ruined.
 *Mac*: sorry I've no access to Mac
 you can find some documentation here:
  http://mientki.ruhosting.nl/web2py/web2py_cc.html
 a download link and installation instructions are at the bottom of the 
 above page.
 have fun,
 Stef



Re: [web2py] Re: ANN: first pre-alfa release (v0.2) of Web2Py_CC

2010-08-30 Thread Stef Mientki
 hi Massimo,

On 30-08-2010 00:54, mdipierro wrote:
> BTW I hope you'll forgive me for this:
>
>http://www.reddit.com/r/Python/comments/d6ks8/web2py_cc_console_ide/
great action, I didn't know about that sit, thanks !
> But you have been on the top of the python page for the entire day
>
>http://www.reddit.com/r/Python/
>
> If you had any doubt, this means there is lots of interest in your
> project.
>
> massimo
cheers,
Stef


Re: [web2py] Re: Some questions about embedding debugging ...

2010-08-30 Thread Stef Mientki
 hi Mike,

thanks, for your reaction.
In the meanwhile I've tried,
pdp, could not get it to work with web2py (is it possible at all ??)
winpdb, as you describe works perfect with web2py.
Re-sync of changed source files seems essential to me,
but isn't that done by just restarting the debugger
(and of course it would be nice if it stepped to the point where you restarted).

cheers,
Stef


On 29-08-2010 14:44, Michael Ellis wrote:
> I do all my development in a web2py instance running under winpdb on
> OS X 10.6.  It's been a huge help to always have instant access to
> debugging and so far, I haven't seen any significant slowdown in
> performance.
>
> Winpdb can be a bit of a pain to install because of the WxPython
> dependencies, but that only affects the GUI side.   As you're probably
> aware,  winpdb is actually two programs.   The guts of the debugger is
> rpdb2.  That's what get's wrapped around the program you're
> debugging.  AFAIK, it doesn't have any special dependencies.  The
> winpdb gui is a client that attaches to it.
>
> Since you're developing an IDE, you might want to consider modifying
> or re-implementing the  winpdb interface within your application so it
> can spawn and attach to rpdb2.  Perhaps you can solve the problem of
> re-syncing to changed source files which, to my mind, is the only real
> annoyance with the winpdb gui.
>
> Cheers,
> Mike
>
> On Aug 27, 4:18 pm, Stef Mientki  wrote:
>>  hello,
>>
>> I'm looking if I can embed debugging in Web2Py_CC,
>> but I've a few questions before I start my attempts.
>>
>> 1. What is the allowed / preferred debugger, pdb or winpdb ?
>>
>> 2. A run some tests in a debugger (winpdb) and saw that exceptions are 
>> caught always in web2py
>> (which might be a very logical choice).
>> Is it possible to let the exceptions be handled by an external debugger ?
>>
>> 3. Is it possible to redirect the output so print statements can be seen ?
>> (btw where are print statements going now ?)
>>
>> thanks,
>> Stef Mientki



Re: [web2py] Re: successfully created tables can not be accessed

2010-08-30 Thread Adrian Klaver

On 08/30/2010 12:00 PM, Benjamin Goll wrote:

Hello Massimo,

I'm using web2py version 1.83.2.

When I define the tables in shell-mode, everything looks fine:

python web2py.py -S aubop -M

db = DAL('sqlite://aubop.db')
db.define_table('track', Field('title'), Field('artist'), Field('length'), 
Field('filepath'))

, [...]

db.define_table('album', Field('title'), Field('artist'), Field('tracks', 
'list:reference track'), Field('currentTrack', 'reference track'), 
Field('currentPlaybackTime'), Field('rating', 'integer'))

, [...]

db.tables

['track', 'album']

I then tried to log the output of db.tables immediatelly after the two
db.define_table()s in the model-file "database.py":

db = DAL('sqlite://aubop.db')
db.define_table('track', Field('title'), Field('artist'),
Field('length'), Field('filepath'))
db.define_table('album', Field('title'), Field('artist'),
Field('tracks', 'list:reference track'), Field('currentTrack',
'reference track'), Field('currentPlaybackTime'), Field('rating',
'integer'))
f = open("test.log", "w")
for d in db.tables:
f.write(d)

Unfortunately the created file is empty. Do you have any idea why?

Regards

Benjamin



If your db.py is like mine then you have the below at the top of the 
file. If  doing this:

db = DAL('sqlite://aubop.db')
in addition to the already defined db then your tables are probably not 
being created where you think they are. I would suggest a different 
variable i.e. db2 = DAL('sqlite://aubop.db').




if request.env.web2py_runtime_gae:# if running on Google App 
Engine

db = DAL('gae')   # connect to Google BigTable
session.connect(request, response, db = db) # and store sessions 
and tickets there

### or use the following lines to store sessions in Memcache
# from gluon.contrib.memdb import MEMDB
# from google.appengine.api.memcache import Client
# session.connect(request, response, db = MEMDB(Client()))
else: # else use a normal 
relational database

db = DAL('sqlite://storage.sqlite')   # if




--
Adrian Klaver
adrian.kla...@gmail.com


[web2py] CRM Applicance missing "pass" in view

2010-08-30 Thread Bruno Rocha
Hi,

A friend in Brazil is using Massimo's CRM Appliance, He had 1.81 Version(
http://www.casacivil.pb.gov.br/w2p/Atos)
but when updated to 1.83 got this error:

error ticket for "Atos"
Ticket 127.0.0.1.2010-08-30.20-21-11.ac099e4c-41e1-4a2d-be7e-0da5a59a397f
*missing "pass" in view*


Error traceback
Traceback (most recent call last):
  File "c:\Sistemas\web2py\gluon\rocket.py", line 871, in run
self.run_app(conn)
  File "c:\Sistemas\web2py\gluon\rocket.py", line 1281, in run_app
self.environ = environ = self.build_environ(sock_file, conn)
  File "c:\Sistemas\web2py\gluon\rocket.py", line 1114, in build_environ
request = self.read_request_line(sock_file)
  File "c:\Sistemas\web2py\gluon\rocket.py", line 927, in read_request_line
d = sock_file.readline()
  File "C:\Python26\lib\socket.py", line 406, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 10053] An established connection was aborted by the software
in your host machine


[web2py] execute sql statement at create only

2010-08-30 Thread Manu
Hi ,
  I would like to execute a statement only the first time the database
is create by inserting a fake record and never anymore then . Where
should i put that code ?

Thx
E.


[web2py] Re: dashes in controller names?

2010-08-30 Thread villas
On Aug 30, 8:37 pm, Kevin  wrote:
> That last point of yours is why I feel the way I do: the slug is
> redundant.  Then again, I'm not the kind of programmer to put SEO
> ahead of cleanliness.

Hi Kevin
Hmm, many others would put SEO ahead of anything if it was paying
their wages :-)  but I see your point.
Regards,
David


[web2py] Re: GAE: recipies to cope with long loading of pages?

2010-08-30 Thread Chris S
Um... of course that example should also end with "return data".

On Aug 30, 2:23 pm, Jurgis Pralgauskis 
wrote:
> I quite use reference fields -- maybe thats the problem...
>  can this be cached the way select is?
>
> sth like
> db.define_table("Topics",
>           Field("parent_id","reference Topics", label=T("Parent
> Topic"),   ),
>           Field("name", "string")
> )
>
> db.define_table("Examples",
>       Field("topic_id", db.Topics, label="Topic",        ),
>       Field("lang_id", db.Languages,label="Language", ),
>  )
>
> and I use
> db.Language[example.lang_id]
> or
> db.Topics[ db.Topics[example.topic_id].parent_id ]
>
> On 30 Rugp, 18:01, mdipierro  wrote:
>
>
>
> > It is slow. does it contain a lot of code or a lot of DB IO? I cannot
> > say without looking at the code.
>
> > On Aug 30, 9:09 am, Jurgis Pralgauskis 
> > wrote:
>
> > > Hello,
>
> > > I have my beta apphttp://code.google.com/p/code-by-example/
> > > onhttp://web2py-gae-test.appspot.com/
>
> > > which seems to load quite 
> > > slowlyhttp://ftp.akl.lt/incoming/jurgio/gae-logs.png
>
> > > I also tried logs,http://ftp.akl.lt/incoming/jurgio/cbe.profile.txt
> > > but don't see big problems (though i use profiling for the first
> > > time..)
>
> > > ***
> > > I recently made KEEP_CACHED = True
>
> > > and for Session use Memcache
> > > as I use session quite a bit
>
> > > but still can't feel that its better
>
> > > ***
> > > I also see info in logs:
> > > This request caused a new process to be started for your application,
> > > and thus caused your application code to be loaded for the first time.
> > > This request may thus take longer and use more CPU than a typical
> > > request for your application.
>
> > > ***http://plugins.jquery.com/project/appear
> > > might help me a bit,
> > > as mostly used controller shows ~ 20% of what it loads
>
> > > I tried web2py_component(action,target) {
> > >      $('#'+target).appear(function() {
> > > instead of
> > >      jQuery(document).ready(function(){
> > > but this did' t work :(
>
> > > any suggestions ?


[web2py] Re: GAE: recipies to cope with long loading of pages?

2010-08-30 Thread Chris S
Alight I'm going to try this one more time and hope it doesn't double
post.
What I've done that I know works for cache of selects on GAE is the
following:

-
def gaecache(table,row,criteria):
  """
  Returns requested item from memcache or inserts it into memcache for
next call
  """
  key = table+str(criteria)
  data = memcache.get(key)
  if data is None:
selection = db(db[table][row]==criteria).select()
data = selection.as_list(datetime_to_str=False)
memcache.add(key,data,3600)
  return data
-

With that in one of your models you can just call the function only on
highly accessed queries.  You could even make the cache time (3600
seconds above) as an input if you wanted to make the function very
generic.


On Aug 30, 9:20 pm, Chris S  wrote:
> Um... of course that example should also end with "return data".
>
> On Aug 30, 2:23 pm, Jurgis Pralgauskis 
> wrote:
>
>
>
> > I quite use reference fields -- maybe thats the problem...
> >  can this be cached the way select is?
>
> > sth like
> > db.define_table("Topics",
> >           Field("parent_id","reference Topics", label=T("Parent
> > Topic"),   ),
> >           Field("name", "string")
> > )
>
> > db.define_table("Examples",
> >       Field("topic_id", db.Topics, label="Topic",        ),
> >       Field("lang_id", db.Languages,label="Language", ),
> >  )
>
> > and I use
> > db.Language[example.lang_id]
> > or
> > db.Topics[ db.Topics[example.topic_id].parent_id ]
>
> > On 30 Rugp, 18:01, mdipierro  wrote:
>
> > > It is slow. does it contain a lot of code or a lot of DB IO? I cannot
> > > say without looking at the code.
>
> > > On Aug 30, 9:09 am, Jurgis Pralgauskis 
> > > wrote:
>
> > > > Hello,
>
> > > > I have my beta apphttp://code.google.com/p/code-by-example/
> > > > onhttp://web2py-gae-test.appspot.com/
>
> > > > which seems to load quite 
> > > > slowlyhttp://ftp.akl.lt/incoming/jurgio/gae-logs.png
>
> > > > I also tried logs,http://ftp.akl.lt/incoming/jurgio/cbe.profile.txt
> > > > but don't see big problems (though i use profiling for the first
> > > > time..)
>
> > > > ***
> > > > I recently made KEEP_CACHED = True
>
> > > > and for Session use Memcache
> > > > as I use session quite a bit
>
> > > > but still can't feel that its better
>
> > > > ***
> > > > I also see info in logs:
> > > > This request caused a new process to be started for your application,
> > > > and thus caused your application code to be loaded for the first time.
> > > > This request may thus take longer and use more CPU than a typical
> > > > request for your application.
>
> > > > ***http://plugins.jquery.com/project/appear
> > > > might help me a bit,
> > > > as mostly used controller shows ~ 20% of what it loads
>
> > > > I tried web2py_component(action,target) {
> > > >      $('#'+target).appear(function() {
> > > > instead of
> > > >      jQuery(document).ready(function(){
> > > > but this did' t work :(
>
> > > > any suggestions ?


[web2py] Re: GAE: recipies to cope with long loading of pages?

2010-08-30 Thread Chris S
It's been a few months since I attempted to cache as you're asking.
When I tried it did not work on GAE though I'm not clear if that was a
memcache+GAE bug or just my implementation.  What I know you can do is
cache things like this.


def gaecache(table,row,criteria):
  """
  Search database, with cache to memcache
  """
  from google.appengine.api import memcache
  data = memcache.get(key)
  if data is None:
selection = db(db[table][row]==criteria).select()
data = selection.as_list(datetime_to_str=False)
memcache.add(key,data,3600)


All this does is check for an item in memecache and if it doesn't
exist perform the normal web2py select.  The results of the select are
returned as a list and inserted into memcache for 3600 seconds (set
whatever value you want).  The only catch to this is a .select()
statement doesn't return a list normally so be aware that this will
return a list and not a Rows object.  I have defined something similar
to this in one of my model files.  That makes it easy to use normal
DAL on some items and call this function for items you would like
cached.




On Aug 30, 2:23 pm, Jurgis Pralgauskis 
wrote:
> I quite use reference fields -- maybe thats the problem...
>  can this be cached the way select is?
>
> sth like
> db.define_table("Topics",
>           Field("parent_id","reference Topics", label=T("Parent
> Topic"),   ),
>           Field("name", "string")
> )
>
> db.define_table("Examples",
>       Field("topic_id", db.Topics, label="Topic",        ),
>       Field("lang_id", db.Languages,label="Language", ),
>  )
>
> and I use
> db.Language[example.lang_id]
> or
> db.Topics[ db.Topics[example.topic_id].parent_id ]
>
> On 30 Rugp, 18:01, mdipierro  wrote:
>
>
>
> > It is slow. does it contain a lot of code or a lot of DB IO? I cannot
> > say without looking at the code.
>
> > On Aug 30, 9:09 am, Jurgis Pralgauskis 
> > wrote:
>
> > > Hello,
>
> > > I have my beta apphttp://code.google.com/p/code-by-example/
> > > onhttp://web2py-gae-test.appspot.com/
>
> > > which seems to load quite 
> > > slowlyhttp://ftp.akl.lt/incoming/jurgio/gae-logs.png
>
> > > I also tried logs,http://ftp.akl.lt/incoming/jurgio/cbe.profile.txt
> > > but don't see big problems (though i use profiling for the first
> > > time..)
>
> > > ***
> > > I recently made KEEP_CACHED = True
>
> > > and for Session use Memcache
> > > as I use session quite a bit
>
> > > but still can't feel that its better
>
> > > ***
> > > I also see info in logs:
> > > This request caused a new process to be started for your application,
> > > and thus caused your application code to be loaded for the first time.
> > > This request may thus take longer and use more CPU than a typical
> > > request for your application.
>
> > > ***http://plugins.jquery.com/project/appear
> > > might help me a bit,
> > > as mostly used controller shows ~ 20% of what it loads
>
> > > I tried web2py_component(action,target) {
> > >      $('#'+target).appear(function() {
> > > instead of
> > >      jQuery(document).ready(function(){
> > > but this did' t work :(
>
> > > any suggestions ?


[web2py] Re: execute sql statement at create only

2010-08-30 Thread mdipierro
you have to options:

1) check for the record and the create it (in model)
2) create a script in private and run it manually once.

On Aug 30, 6:47 pm, Manu  wrote:
> Hi ,
>   I would like to execute a statement only the first time the database
> is create by inserting a fake record and never anymore then . Where
> should i put that code ?
>
> Thx
> E.


[web2py] Re: successfully created tables can not be accessed

2010-08-30 Thread mdipierro
when you use the shell to create tables or do anything else you have
to be db.commit()

the db.define_table() anyway has to be in the model. web2py
controllers only see tables defined in the models.

On Aug 30, 2:00 pm, Benjamin Goll  wrote:
> Hello Massimo,
>
> I'm using web2py version 1.83.2.
>
> When I define the tables in shell-mode, everything looks fine:
>
> python web2py.py -S aubop -M>>> db = DAL('sqlite://aubop.db')
> >>> db.define_table('track', Field('title'), Field('artist'), 
> >>> Field('length'), Field('filepath'))
>
> , [...]>>> 
> db.define_table('album', Field('title'), Field('artist'), Field('tracks', 
> 'list:reference track'), Field('currentTrack', 'reference track'), 
> Field('currentPlaybackTime'), Field('rating', 'integer'))
>
> , [...]>>> db.tables
>
> ['track', 'album']
>
> I then tried to log the output of db.tables immediatelly after the two
> db.define_table()s in the model-file "database.py":
>
> db = DAL('sqlite://aubop.db')
> db.define_table('track', Field('title'), Field('artist'),
> Field('length'), Field('filepath'))
> db.define_table('album', Field('title'), Field('artist'),
> Field('tracks', 'list:reference track'), Field('currentTrack',
> 'reference track'), Field('currentPlaybackTime'), Field('rating',
> 'integer'))
> f = open("test.log", "w")
> for d in db.tables:
>         f.write(d)
>
> Unfortunately the created file is empty. Do you have any idea why?
>
> Regards
>
> Benjamin
>
> On 30 Aug., 20:38, mdipierro  wrote:
>
> > which web2py version are you using?
>
> > what you get if you print db.tables immediately after
> > db.define_table()
>
> > On Aug 30, 10:33 am, Benjamin Goll  wrote:
>
> > > Hello Massimo,
>
> > > thank you for your fast reply!
>
> > > Honestly I don't think that this is related to my problem since I only
> > > tried to demonstrate my problem with this example.
>
> > > If I define a table in a model, I should be able to access this table
> > > without any further configuration, right? So when I do the two
> > > db.define_table()-statements (as shown in my first post), I should be
> > > able to access the tables in a controller via db.album or db.track
> > > respectively.  Unfortunately this is not the case and results in a
> > > KeyError. When I do db.tables in a controller, only the auth_*-tables
> > > are listed.
>
> > > Is there any possibility to see, if web2py fails while initializing
> > > the db-object? Setting the debug-level to 0 seems not the help since
> > > it does not list errors concerning the database.
>
> > > Regards
>
> > > Benjamin
>
> > > On 30 Aug., 16:58, mdipierro  wrote:
>
> > > > > >>> db = DAL('sqlite://aubop.db')
> > > > > >>> db.tables
> > > > > []
> > > > > That's strange, isn't it?
>
> > > > this is fine. In fact even if the tables are in db, web2py does not
> > > > discover them. You still need db.define_table(...) to inform web2py
> > > > about them.
>
> > > > I cannot say about the problem with the app, but could it be related
> > > > to this?
>
> > > > Massimo
>
> > > > On Aug 30, 7:56 am, Benjamin Goll  wrote:
>
> > > > > Hi there,
>
> > > > > first of all I would like to thank you for this great software! It's
> > > > > just so much fun to create powerful applications with it!
>
> > > > > Unfortunately I ran into a really strange problem which I'm not able
> > > > > to solve.
>
> > > > > In the file models/database.py I define the following:
>
> > > > > db = DAL('sqlite://aubop.db')
> > > > > db.define_table('track', Field('title'), Field('artist'),
> > > > > Field('length'), Field('filepath'))
> > > > > db.define_table('album', Field('title'), Field('artist'),
> > > > > Field('tracks', 'list:reference track'), Field('currentTrack',
> > > > > 'reference track'), Field('currentPlaybackTime'), Field('rating',
> > > > > 'integer'))
>
> > > > > When I then try to access one of the two defined tables in a
> > > > > controller, I receive a KeyError, telling me, that e.g. db.album
> > > > > cannot be found.
> > > > > When I open the database "aubop.db" manually via the commandline-
> > > > > interface of sqlite3, I can see that the two tables have been created
> > > > > in the database:
>
> > > > > sqlite3 aubop.db
> > > > > sqlite> .tables
> > > > > album  track
>
> > > > > The sql.log also tells me that the tables ahve been created
> > > > > successfully.
>
> > > > > I then started web2py in the shell-mode ("python web2py.py -S aubop -
> > > > > M"):
>
> > > > > >>> db.tables
>
> > > > > ['auth_user', 'auth_group', 'auth_membership', 'auth_permission',
> > > > > 'auth_event']>>> db = DAL('sqlite://aubop.db')
> > > > > >>> db.tables
>
> > > > > []
>
> > > > > That's strange, isn't it?
>
> > > > > Is there anybody who could help me?
>
> > > > > Btw. access to a different sqlite-database works like a charm in a
> > > > > second application I've created earlier.
>
> > > > > Thanks in advance!
>
> > > > > Regards
>
> > > > > Benjamin


[web2py] Re: CRM Applicance missing "pass" in view

2010-08-30 Thread mdipierro
oops. Will update it.

On Aug 30, 6:30 pm, Bruno Rocha  wrote:
> Hi,
>
> A friend in Brazil is using Massimo's CRM Appliance, He had 1.81 
> Version(http://www.casacivil.pb.gov.br/w2p/Atos)
> but when updated to 1.83 got this error:
>
> error ticket for "Atos"
> Ticket 127.0.0.1.2010-08-30.20-21-11.ac099e4c-41e1-4a2d-be7e-0da5a59a397f
> *missing "pass" in view*
>
> Error traceback
> Traceback (most recent call last):
>   File "c:\Sistemas\web2py\gluon\rocket.py", line 871, in run
>     self.run_app(conn)
>   File "c:\Sistemas\web2py\gluon\rocket.py", line 1281, in run_app
>     self.environ = environ = self.build_environ(sock_file, conn)
>   File "c:\Sistemas\web2py\gluon\rocket.py", line 1114, in build_environ
>     request = self.read_request_line(sock_file)
>   File "c:\Sistemas\web2py\gluon\rocket.py", line 927, in read_request_line
>     d = sock_file.readline()
>   File "C:\Python26\lib\socket.py", line 406, in readline
>     data = self._sock.recv(self._rbufsize)
> error: [Errno 10053] An established connection was aborted by the software
> in your host machine


Re: [web2py] Re: CRM Applicance missing "pass" in view

2010-08-30 Thread rochacbruno
Something we can do in the views
What have changed in template system to raise this error?

I downloaded the updated version of CRM and works well. 



Sent from my iPhone

On 30/08/2010, at 23:35, mdipierro  wrote:

> oops. Will update it.
> 
> On Aug 30, 6:30 pm, Bruno Rocha  wrote:
>> Hi,
>> 
>> A friend in Brazil is using Massimo's CRM Appliance, He had 1.81 
>> Version(http://www.casacivil.pb.gov.br/w2p/Atos)
>> but when updated to 1.83 got this error:
>> 
>> error ticket for "Atos"
>> Ticket 127.0.0.1.2010-08-30.20-21-11.ac099e4c-41e1-4a2d-be7e-0da5a59a397f
>> *missing "pass" in view*
>> 
>> Error traceback
>> Traceback (most recent call last):
>>   File "c:\Sistemas\web2py\gluon\rocket.py", line 871, in run
>> self.run_app(conn)
>>   File "c:\Sistemas\web2py\gluon\rocket.py", line 1281, in run_app
>> self.environ = environ = self.build_environ(sock_file, conn)
>>   File "c:\Sistemas\web2py\gluon\rocket.py", line 1114, in build_environ
>> request = self.read_request_line(sock_file)
>>   File "c:\Sistemas\web2py\gluon\rocket.py", line 927, in read_request_line
>> d = sock_file.readline()
>>   File "C:\Python26\lib\socket.py", line 406, in readline
>> data = self._sock.recv(self._rbufsize)
>> error: [Errno 10053] An established connection was aborted by the software
>> in your host machine


[web2py] Problems getting my web2py app working on GAE

2010-08-30 Thread hswolff
Hello everyone-

I've been working on my first web2py app for the past week and a half
and finally came to an alpha version that is ready to be pushed to
Google's App Engine to share.

However I'm not having any success getting my app to run locally on
the GAE SDK.  Additionally the default scaffolding app 'welcome' isn't
running but the built in 'test' application is.

I am using web2py source Version 1.83.2 (2010-08-15 08:16:30).

I don't even know how to begin to debug what may be wrong, so any
advice is welcome.  Thank you!


Here's some info I got from GoogleAppEngineLauncher and from the
Development Console:

Log view when trying to run default scaffolding app 'welcome':

WARNING  2010-08-31 04:12:40,491 portalocker.py:91] no file locking
WARNING  2010-08-31 04:12:40,829 main.py:49] unable to import Rocket
INFO 2010-08-31 04:12:40,849 gaehandler.py:65]  Request:
0.87ms/0.87ms (real time/cpu time)
INFO 2010-08-31 04:12:40,851 recording.py:327] Saved; key:
__appstats__:060800, part: 17 bytes, full: 1206 bytes, overhead: 0.000
+ 0.002; link: http://localhost:8081/stats/details?time=1283227960848
INFO 2010-08-31 04:12:40,866 dev_appserver.py:3275] "GET / HTTP/
1.1" 303 -
INFO 2010-08-31 04:12:40,877 dev_appserver_index.py:212] Updating /
Users/hswolff/Downloads/web2py/index.yaml


And this is the ticket created from the GAE SDK Console:

(dp0
S'output'
p1
S''
p2
sS'layer'
p3
S'/Users/hswolff/Downloads/web2py/applications/bestandworst/models/
db.py'
p4
sS'code'
p5
S' at 0x102526b70, file "/Users/hswolff/Downloads/
web2py/applications/bestandworst/models/db.py", line 7>'
p6
sS'snapshot'
p7
(dp8
sS'traceback'
p9
S'Traceback (most recent call last):\n  File "/Users/hswolff/Downloads/
web2py/gluon/restricted.py", line 186, in restricted\nexec ccode
in environment\n  File "/Users/hswolff/Downloads/web2py/applications/
bestandworst/models/db.py", line 29, in \nfrom gluon.tools
import *\n  File "/Applications/GoogleAppEngineLauncher.app/Contents/
Resources/GoogleAppEngine-default.bundle/Contents/Resources/
google_appengine/google/appengine/tools/dev_appserver.py", line 1287,
in Decorate\nreturn func(self, *args, **kwargs)\n  File "/
Applications/GoogleAppEngineLauncher.app/Contents/Resources/
GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
google/appengine/tools/dev_appserver.py", line 1937, in load_module
\nreturn self.FindAndLoadModule(submodule, fullname, search_path)
\n  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/
GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
google/appengine/tools/dev_appserver.py", line 1287, in Decorate\n
return func(self, *args, **kwargs)\n  File "/Applications/
GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-
default.bundle/Contents/Resources/google_appengine/google/appengine/
tools/dev_appserver.py", line 1839, in FindAndLoadModule\n
description)\n  File "/Applications/GoogleAppEngineLauncher.app/
Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/
google_appengine/google/appengine/tools/dev_appserver.py", line 1287,
in Decorate\nreturn func(self, *args, **kwargs)\n  File "/
Applications/GoogleAppEngineLauncher.app/Contents/Resources/
GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
google/appengine/tools/dev_appserver.py", line 1790, in
LoadModuleRestricted\ndescription)\n  File "/Users/hswolff/
Downloads/web2py/gluon/tools.py", line 3023, in \n
urllib2.install_opener(urllib2.build_opener(urllib2.HTTPCookieProcessor()))
\n  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/urllib2.py", line 464, in build_opener\n\x00|
\x04\x00\x83\x01\x00}\x04\x00t\n  File "/System/Library/Frameworks/
Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 684, in
__init__\n  File "/System/Library/Frameworks/Python.framework/Versions/
2.6/lib/python2.6/urllib.py", line 1558, in getproxies\n  File "/
System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
urllib.py", line 1448, in getproxies_macosx_sysconf\n  File "/
Applications/GoogleAppEngineLauncher.app/Contents/Resources/
GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
google/appengine/tools/dev_appserver.py", line 1287, in Decorate\n
return func(self, *args, **kwargs)\n  File "/Applications/
GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-
default.bundle/Contents/Resources/google_appengine/google/appengine/
tools/dev_appserver.py", line 1937, in load_module\nreturn
self.FindAndLoadModule(submodule, fullname, search_path)\n  File "/
Applications/GoogleAppEngineLauncher.app/Contents/Resources/
GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
google/appengine/tools/dev_appserver.py", line 1287, in Decorate\n
return func(self, *args, **kwargs)\n  File "/Applications/
GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-
default.bundle/Contents/Resources/google_appengine/go

[web2py] Re: dashes in controller names?

2010-08-30 Thread Kevin
Yes indeed, I'm keen to make sure their needs (and yours) are met as
well as mine ;)  I'm certainly not mandating that anyone follow any
particular preference.

On Aug 30, 6:14 pm, villas  wrote:
> On Aug 30, 8:37 pm, Kevin  wrote:
>
> > That last point of yours is why I feel the way I do: the slug is
> > redundant.  Then again, I'm not the kind of programmer to put SEO
> > ahead of cleanliness.
>
> Hi Kevin
> Hmm, many others would put SEO ahead of anything if it was paying
> their wages :-)  but I see your point.
> Regards,
> David


[web2py] Re: Problems getting my web2py app working on GAE

2010-08-30 Thread mdipierro
GAE supports only python 2.5 you seem to be using 2.6. I am not sure
this is the only problem but this is for sure a problem

On Aug 30, 11:18 pm, hswolff  wrote:
> Hello everyone-
>
> I've been working on my first web2py app for the past week and a half
> and finally came to an alpha version that is ready to be pushed to
> Google's App Engine to share.
>
> However I'm not having any success getting my app to run locally on
> the GAE SDK.  Additionally the default scaffolding app 'welcome' isn't
> running but the built in 'test' application is.
>
> I am using web2py source Version 1.83.2 (2010-08-15 08:16:30).
>
> I don't even know how to begin to debug what may be wrong, so any
> advice is welcome.  Thank you!
>
> Here's some info I got from GoogleAppEngineLauncher and from the
> Development Console:
>
> Log view when trying to run default scaffolding app 'welcome':
>
> WARNING  2010-08-31 04:12:40,491 portalocker.py:91] no file locking
> WARNING  2010-08-31 04:12:40,829 main.py:49] unable to import Rocket
> INFO     2010-08-31 04:12:40,849 gaehandler.py:65]  Request:
> 0.87ms/0.87ms (real time/cpu time)
> INFO     2010-08-31 04:12:40,851 recording.py:327] Saved; key:
> __appstats__:060800, part: 17 bytes, full: 1206 bytes, overhead: 0.000
> + 0.002; link:http://localhost:8081/stats/details?time=1283227960848
> INFO     2010-08-31 04:12:40,866 dev_appserver.py:3275] "GET / HTTP/
> 1.1" 303 -
> INFO     2010-08-31 04:12:40,877 dev_appserver_index.py:212] Updating /
> Users/hswolff/Downloads/web2py/index.yaml
>
> And this is the ticket created from the GAE SDK Console:
>
> (dp0
> S'output'
> p1
> S''
> p2
> sS'layer'
> p3
> S'/Users/hswolff/Downloads/web2py/applications/bestandworst/models/
> db.py'
> p4
> sS'code'
> p5
> S' at 0x102526b70, file "/Users/hswolff/Downloads/
> web2py/applications/bestandworst/models/db.py", line 7>'
> p6
> sS'snapshot'
> p7
> (dp8
> sS'traceback'
> p9
> S'Traceback (most recent call last):\n  File "/Users/hswolff/Downloads/
> web2py/gluon/restricted.py", line 186, in restricted\n    exec ccode
> in environment\n  File "/Users/hswolff/Downloads/web2py/applications/
> bestandworst/models/db.py", line 29, in \n    from gluon.tools
> import *\n  File "/Applications/GoogleAppEngineLauncher.app/Contents/
> Resources/GoogleAppEngine-default.bundle/Contents/Resources/
> google_appengine/google/appengine/tools/dev_appserver.py", line 1287,
> in Decorate\n    return func(self, *args, **kwargs)\n  File "/
> Applications/GoogleAppEngineLauncher.app/Contents/Resources/
> GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
> google/appengine/tools/dev_appserver.py", line 1937, in load_module
> \n    return self.FindAndLoadModule(submodule, fullname, search_path)
> \n  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/
> GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
> google/appengine/tools/dev_appserver.py", line 1287, in Decorate\n
> return func(self, *args, **kwargs)\n  File "/Applications/
> GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-
> default.bundle/Contents/Resources/google_appengine/google/appengine/
> tools/dev_appserver.py", line 1839, in FindAndLoadModule\n
> description)\n  File "/Applications/GoogleAppEngineLauncher.app/
> Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/
> google_appengine/google/appengine/tools/dev_appserver.py", line 1287,
> in Decorate\n    return func(self, *args, **kwargs)\n  File "/
> Applications/GoogleAppEngineLauncher.app/Contents/Resources/
> GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
> google/appengine/tools/dev_appserver.py", line 1790, in
> LoadModuleRestricted\n    description)\n  File "/Users/hswolff/
> Downloads/web2py/gluon/tools.py", line 3023, in \n
> urllib2.install_opener(urllib2.build_opener(urllib2.HTTPCookieProcessor()))
> \n  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/urllib2.py", line 464, in build_opener\n    \x00|
> \x04\x00\x83\x01\x00}\x04\x00t\n  File "/System/Library/Frameworks/
> Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 684, in
> __init__\n  File "/System/Library/Frameworks/Python.framework/Versions/
> 2.6/lib/python2.6/urllib.py", line 1558, in getproxies\n  File "/
> System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> urllib.py", line 1448, in getproxies_macosx_sysconf\n  File "/
> Applications/GoogleAppEngineLauncher.app/Contents/Resources/
> GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
> google/appengine/tools/dev_appserver.py", line 1287, in Decorate\n
> return func(self, *args, **kwargs)\n  File "/Applications/
> GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-
> default.bundle/Contents/Resources/google_appengine/google/appengine/
> tools/dev_appserver.py", line 1937, in load_module\n    return
> self.FindAndLoadModule(submodule, fullname, search_path)\n  File "/
> Applications/GoogleAp

[web2py] Re: GAE: recipies to cope with long loading of pages?

2010-08-30 Thread Jurgis Pralgauskis
I looked around once more
http://www.web2py.com/book/default/chapter/04
and found that I could "cache view"

* on rockets this seems to have some efect (but profiler won't show
them, as it counts just the time it is executed - am I rigth?).


* on dev_server this seems quite slower (probably because dev_server
mimics memcache)

* and on gae for one of controller caches I get
http://web2py-gae-test.appspot.com/CodeByExample/default/example_view_4url/99004

PicklingError: Can't pickle : it's not
found as gluon.html.__tag__

which comes from somewhere
  File "/google/appengine/api/memcache/__init__.py", line 194, in
_validate_encode_value
stored_value = do_pickle(value)
  File "/google/appengine/api/memcache/__init__.py", line 299, in
DoPickle
self._pickler_instance.dump(value)

called from
@cache(request.env.path_info, time_expire=caching_time,
cache_model=cache.ram) # cache.ram = cache.memcache
def example_view_4url():
id = int(request.args(0))
return example_view(id) # returns DIV(...)

*
if I remake
return request.render( example_view(id) )
or
return request.render( dict(view = example_view(id) ) )

I get another error - probably, because there is no view
example_view_4url.html :
 File "/gluon/cache.py", line 410, in 
return lambda: cache_model(key, func, time_expire)
  File "/gluon/cache.py", line 182, in __call__
value = f()
  File "/applications/CodeByExample/controllers/default.py", line 790,
in example_view_4url
return request.render( example_view(id) )
TypeError: 'NoneType' object is not callable


I now use :
---
VERSION 1.83.1 (2010-08-11 23:52:55)
--

ps.:
   could @cache generate keys  depending  on  function's argument
values?

pps: thanks a lot for clues and answers -- i guess I am starting to be
annoying :]

>
>
>
> > Hello,
>
> > I have my beta apphttp://code.google.com/p/code-by-example/
> > onhttp://web2py-gae-test.appspot.com/
>
> > which seems to load quite 
> > slowlyhttp://ftp.akl.lt/incoming/jurgio/gae-logs.png
>
> > I also tried logs,http://ftp.akl.lt/incoming/jurgio/cbe.profile.txt
> > but don't see big problems (though i use profiling for the first
> > time..)
>
> > ***
> > I recently made KEEP_CACHED = True
>
> > and for Session use Memcache
> > as I use session quite a bit
>
> > but still can't feel that its better
>
> > ***
> > I also see info in logs:
> > This request caused a new process to be started for your application,
> > and thus caused your application code to be loaded for the first time.
> > This request may thus take longer and use more CPU than a typical
> > request for your application.
>
> > ***http://plugins.jquery.com/project/appear
> > might help me a bit,
> > as mostly used controller shows ~ 20% of what it loads
>
> > I tried web2py_component(action,target) {
> >      $('#'+target).appear(function() {
> > instead of
> >      jQuery(document).ready(function(){
> > but this did' t work :(
>
> > any suggestions ?