Re: [web2py] web2py unavailable during file upload cherokee+ssl+uWSGI+web2py

2011-01-04 Thread Roberto De Ioris

Il giorno 04/gen/2011, alle ore 00.49, PhE ha scritto:

 Following Massimo's advice on my previous post on file upload with
 rocket/ssl, I decided to give another try to cherokee/web2py.
 
 Now I've got reliable ssl file uploads : 4 successful uploads of a 5
 MB file (3 to 4 minutes transfer each).
 This is a great forward step ;-)
 
 But I still have a big issue : during the transfer the web2py service
 is unavailable.
 An attempt to access the index page of web2py makes Cherokee to
 respond :
 503 Service Unavailable
 Cherokee web server 1.0.15 (Ubuntu), Port 443


It looks to me that you have no concurrency in your setup.
Cherokee is a streamed-upload server so the uploads is entirely managed by your 
app.

If you spawn only one uwsgi process this will be be busy during uploads and 
cannot accept new requests.

Simply add -p n to your command line or processesn/processes to your xml 
config file.

Where n is the number of processes you want to spawn.


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



Re: [web2py] Re: Memory leak - followup

2011-01-04 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi :)

Yes, I am really sure. This is exact code of my controller.

def load_pers():

class Blah():
def __init__(self):
pass

def blah2():
return Blah()

p = cache.ram('blahblah',blah2,time_expire=30)

return dict(p=BEAUTIFY(p))

and this has the same effect:

def load_pers():

class Blah():
def __init__(self):
pass

p = cache.ram('blahblah',Blah,time_expire=30)

return dict(p=BEAUTIFY(p))

Simply, if I store an object declared in controller or model in cache
(regardless of db involvement), whole db model is being duplicated in
RAM, which is really unwanted behaviour.

As I mentioned in one of previous messages, I have strong suspiction
that the issue is related to another one discussed here:

http://www.mail-archive.com/web2py@googlegroups.com/msg34333.html

D.

mdipierro wrote:
 Sorry. I got confused too. You say this leads to the leak:
 
 class Blah():
 def __init__(self):
 pass
 def blah2():
 return Blah()
 p = cache.ram('blahblah',blah2,time_expire=30)
 
 so there is o db involved? Are you sure 'blahblah' is a constant in
 your code and not a variable? Is this the exact code you are running?
 
 
 On Jan 3, 5:42 pm, David Zejda d...@atlas.cz wrote:
 Hello Massimo,
 
 sorry, but I really do not understand. :-|
 
 How do I store whole record if the only thing I'm trying to store is
 instance of a dummy class? In the last example with empty __init__ there
 is no record involved at all!
 
 If I do exactly what Michele suggested:
 
 class Blah():
 def __init__(self):
 self.nick = db.person[1].nick
 
 def blah_f():
 return Blah()
 
 p = cache.ram('blahblah', blah_f,time_expire=30)
 
 result is the same, of course.
 
 David

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0i3rUACgkQ3oCkkciamVEz2wCdGXIgszz1wjDCR6/gHMOSqpda
T+QAnjbShkt47zF8D1NLzrjm0zrXEyTL
=88aY
-END PGP SIGNATURE-


[web2py] How to get field values before form.accepts(...)

2011-01-04 Thread annet
I am working on a form which inserts data into five different tables.
To prevent the user from filling in the entire form and after form
submission finding that the object already exists, I would like to
check the existence of an object before hand based on two form fields.
These are the relevant bits of the form:


def create_form():
form=SQLFORM.factory(
Field(...),
Field(...))
...
form[0][2][2].insert(0,A('already in
database?',_onmouseover=this.style.cursor='pointer';,\
 
_onclick=javascript:details('%s')%URL(r=request,f='retrieve',args=[document.getElementById(kvk_number).value,
\
document.getElementById(subdossiernumber).value])))
   ...
if form.accepts(request.vars,session):
...
elif form.errors:
...
return dict(form=form)


... args=...

should get the values entered in the fields named kvk_number and
subdossiernumber, the code above doesn't work, what is the correct
syntax to get these values and pass them as arguments to the retrieve
function?


Kind regards,

Annet.


Re: [web2py] Re: Memory leak - followup

2011-01-04 Thread Michele Comitini
Try to put the Blah class in the global scope of the controller.  Do
you get same result?

2011/1/4 David Zejda d...@atlas.cz:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hi :)

 Yes, I am really sure. This is exact code of my controller.

 def load_pers():

    class Blah():
        def __init__(self):
            pass

    def blah2():
        return Blah()

    p = cache.ram('blahblah',blah2,time_expire=30)

    return dict(p=BEAUTIFY(p))

 and this has the same effect:

 def load_pers():

    class Blah():
        def __init__(self):
            pass

    p = cache.ram('blahblah',Blah,time_expire=30)

    return dict(p=BEAUTIFY(p))

 Simply, if I store an object declared in controller or model in cache
 (regardless of db involvement), whole db model is being duplicated in
 RAM, which is really unwanted behaviour.

 As I mentioned in one of previous messages, I have strong suspiction
 that the issue is related to another one discussed here:

 http://www.mail-archive.com/web2py@googlegroups.com/msg34333.html

 D.

 mdipierro wrote:
 Sorry. I got confused too. You say this leads to the leak:

     class Blah():
         def __init__(self):
             pass
     def blah2():
         return Blah()
     p = cache.ram('blahblah',blah2,time_expire=30)

 so there is o db involved? Are you sure 'blahblah' is a constant in
 your code and not a variable? Is this the exact code you are running?


 On Jan 3, 5:42 pm, David Zejda d...@atlas.cz wrote:
 Hello Massimo,

 sorry, but I really do not understand. :-|

 How do I store whole record if the only thing I'm trying to store is
 instance of a dummy class? In the last example with empty __init__ there
 is no record involved at all!

 If I do exactly what Michele suggested:

 class Blah():
     def __init__(self):
         self.nick = db.person[1].nick

 def blah_f():
     return Blah()

 p = cache.ram('blahblah', blah_f,time_expire=30)

 result is the same, of course.

 David

 - --
 David Zejda, Open-IT cz
 web development  services
 http://www.o-it.info
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.9 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iEYEARECAAYFAk0i3rUACgkQ3oCkkciamVEz2wCdGXIgszz1wjDCR6/gHMOSqpda
 T+QAnjbShkt47zF8D1NLzrjm0zrXEyTL
 =88aY
 -END PGP SIGNATURE-



[web2py] Re: IS_IN_DB() argument

2011-01-04 Thread mdipierro
ok, in trunk.

On Jan 3, 8:34 pm, Fabiano fabianoeng...@gmail.com wrote:
 Ok. By the way, If I may suggest, it would be a nice feature, and backward
 compatible. As the id is an implied column and you must specify it explicit
 when making references, I think it it would be even more consistent to
 specify a table, the id would be implicit in both cases.

 Regards,

 On Monday, January 3, 2011 11:23:46 PM UTC-2, mdipierro wrote:

  The error is in the example. IS_IN_DB *never* accepted a table as
  second argument.
  Sorry for the confusion. Will fix the example.

  Massimo

  On Jan 3, 6:25 pm, Fabiano - deStilaDo fabian...@gmail.com
  wrote:
   Hi,

   from validators.py:

    342 class IS_IN_DB(Validator):
    343     
    344     example::
    345
    346         INPUT(_type='text', _name='name',
    347               requires=IS_IN_DB(db, db.table, zero=''))
    348
    349     used for reference fields, rendered as a dropbox
    350     

   But I can't use the documented syntax: IS_IN_DB(db, db.table). I had
   to use explicit db.table.id as argument.

   It looks like the current code (1.91.6) does not accept a table as
   argument. Apparently, it cannot figure out that when you specify a
   table instead of a field it should use the table's id field. It relies
   on the field representation as string to extract the field name,
   splitting it by dots, as shows line 371 from the class' constructor:

    370         self.field = field
    371         (ktable, kfield) = str(self.field).split('.')

   Wouldn't be better to test the argument with something like isinstance()
  first?

   Sorry if I misunderstood something, but I think that if this is not a
   bug, then the documentation should be updated.

   I also didn't check the code for IS_NOT_IN_DB(), but I guess this
   class may have the same issue.

   Regards,

   Fabiano.




[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread mdipierro
Why

+elif url.lower().startswith('url:'):
+   url=URL(*[part.strip('\'') for part in
url[4:].split(',')])


and not

+elif url.lower().startswith('url:'):
+   url=URL(*[part for part in
url[4:].split(',')])

Why the quotes?


On Jan 3, 9:07 pm, blackthorne francisco@gmail.com wrote:
 Because it may not be obvious that the previous message includes a
 patch, here is from another 
 source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

 thank you

 On Jan 4, 2:51 am, Francisco Gama blacktho...@ironik.org wrote:

  this patch allows you to define custom links using the URL() helper in the 
  meta-menu of plugin_wiki, so you should apply it to:
  models/plugin_wiki.py

  the syntax used is Title url:URL_args

  example:
  home url:'homepage','plugin_wiki','index'
  Articles page:articles
  Links url:'homepage','default','links'

  notice that after url: you shall not leave white spaces. This is a must 
  not to touch in the regex currently being used to match that

  Other idea, would be to bring this power to markmin links...

  Leave comments,
  Best regards

  Francisco Gama Tabanez Ribeiro

  E-mail: blacktho...@ironik.org
  Twitter: blackthorne




[web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread mdipierro
This can be done but it would not prevent one use to write code (an
app) that reads or deletes another user app. As long as this is clear,
I coud modify admin for this purpose (or create another admin).

On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
 I think it'll be convenient for multiple users to work on one web2py
 installation, if there's a layer on top of the admin app, providing
 the following features:

 1. The admin app allows user registration.
 2. Each user can view/edit only apps that he/she creates.

 This is strictly at the (admin) app level.  Everything is the same as
 before at the filesystem level.

 (This is particularly useful for teaching (I think): one web2py app,
 many students).


[web2py] Re: Built-in editor quirk

2011-01-04 Thread mdipierro
Which browser? The browser is the issue.

On Jan 4, 1:49 am, dederocks dediro...@gmail.com wrote:
 Hello,
 There's been a weird bug in the built-in editor for some time now:
 when you highlight a line, the highlight actually shows up two lines
 above the selection. Any way to fix this?

 Python 2.7, Windows 7, trunk version.

 Thanks  BR, Andre


[web2py] Re: How to get field values before form.accepts(...)

2011-01-04 Thread mdipierro
You problem is here:

_onclick=javascript:details('%s')%URL(r=request,f='retrieve',args=[document.getElementById(kvk_number).value,document.getElementById(subdossiernumber).value])))

because you have JS mixed with web2py code. Try this:

_onclick=javascript:details('%s/'+$('#kvk_number').val()+'/'+$
('#subdossiernumber').val())%URL('retrieve')


On Jan 4, 3:28 am, annet annet.verm...@gmail.com wrote:
 I am working on a form which inserts data into five different tables.
 To prevent the user from filling in the entire form and after form
 submission finding that the object already exists, I would like to
 check the existence of an object before hand based on two form fields.
 These are the relevant bits of the form:

 def create_form():
     form=SQLFORM.factory(
         Field(...),
         Field(...))
     ...
     form[0][2][2].insert(0,A('already in
 database?',_onmouseover=this.style.cursor='pointer';,\

 _onclick=javascript:details('%s')%URL(r=request,f='retrieve',args=[document.getElementById(kvk_number).value,
 \
     document.getElementById(subdossiernumber).value])))
    ...
     if form.accepts(request.vars,session):
     ...
     elif form.errors:
     ...
     return dict(form=form)

 ... args=...

 should get the values entered in the fields named kvk_number and
 subdossiernumber, the code above doesn't work, what is the correct
 syntax to get these values and pass them as arguments to the retrieve
 function?

 Kind regards,

 Annet.


[web2py] Re: Memory leak - followup

2011-01-04 Thread mdipierro
I am puzzled. Let me think about this.

Massimo

On Jan 4, 2:47 am, David Zejda d...@atlas.cz wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hi :)

 Yes, I am really sure. This is exact code of my controller.

 def load_pers():

     class Blah():
         def __init__(self):
             pass

     def blah2():
         return Blah()

     p = cache.ram('blahblah',blah2,time_expire=30)

     return dict(p=BEAUTIFY(p))

 and this has the same effect:

 def load_pers():

     class Blah():
         def __init__(self):
             pass

     p = cache.ram('blahblah',Blah,time_expire=30)

     return dict(p=BEAUTIFY(p))

 Simply, if I store an object declared in controller or model in cache
 (regardless of db involvement), whole db model is being duplicated in
 RAM, which is really unwanted behaviour.

 As I mentioned in one of previous messages, I have strong suspiction
 that the issue is related to another one discussed here:

 http://www.mail-archive.com/web2py@googlegroups.com/msg34333.html

 D.



 mdipierro wrote:
  Sorry. I got confused too. You say this leads to the leak:

      class Blah():
          def __init__(self):
              pass
      def blah2():
          return Blah()
      p = cache.ram('blahblah',blah2,time_expire=30)

  so there is o db involved? Are you sure 'blahblah' is a constant in
  your code and not a variable? Is this the exact code you are running?

  On Jan 3, 5:42 pm, David Zejda d...@atlas.cz wrote:
  Hello Massimo,

  sorry, but I really do not understand. :-|

  How do I store whole record if the only thing I'm trying to store is
  instance of a dummy class? In the last example with empty __init__ there
  is no record involved at all!

  If I do exactly what Michele suggested:

  class Blah():
      def __init__(self):
          self.nick = db.person[1].nick

  def blah_f():
      return Blah()

  p = cache.ram('blahblah', blah_f,time_expire=30)

  result is the same, of course.

  David

 - --
 David Zejda, Open-IT cz
 web development  serviceshttp://www.o-it.info
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.9 (GNU/Linux)
 Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org

 iEYEARECAAYFAk0i3rUACgkQ3oCkkciamVEz2wCdGXIgszz1wjDCR6/gHMOSqpda
 T+QAnjbShkt47zF8D1NLzrjm0zrXEyTL
 =88aY
 -END PGP SIGNATURE-


[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread blackthorne
instead of having common strings ready to be passed as arguments, you
would get strings that contain quotes in it. I guess...

Consider my example:
home url:'homepage','plugin_wiki','index'

you will get:
In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

In [10]: [part.strip('\'') for part in url[4:].split(',')]
Out[10]: ['homepage', 'plugin_wiki', 'index']

In [11]: [part for part in url[4:].split(',')]
Out[11]: ['homepage', 'plugin_wiki', 'index']

Best regards

On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu wrote:
 Why

 +                elif url.lower().startswith('url:'):
 +                       url=URL(*[part.strip('\'') for part in
 url[4:].split(',')])

 and not

 +                elif url.lower().startswith('url:'):
 +                       url=URL(*[part for part in
 url[4:].split(',')])

 Why the quotes?

 On Jan 3, 9:07 pm, blackthorne francisco@gmail.com wrote:



  Because it may not be obvious that the previous message includes a
  patch, here is from another 
  source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

  thank you

  On Jan 4, 2:51 am, Francisco Gama blacktho...@ironik.org wrote:

   this patch allows you to define custom links using the URL() helper in 
   the meta-menu of plugin_wiki, so you should apply it to:
   models/plugin_wiki.py

   the syntax used is Title url:URL_args

   example:
   home url:'homepage','plugin_wiki','index'
   Articles page:articles
   Links url:'homepage','default','links'

   notice that after url: you shall not leave white spaces. This is a must 
   not to touch in the regex currently being used to match that

   Other idea, would be to bring this power to markmin links...

   Leave comments,
   Best regards

   Francisco Gama Tabanez Ribeiro

   E-mail: blacktho...@ironik.org
   Twitter: blackthorne


[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread blackthorne
maybe this would even be a better option:
[part.strip('\'').strip('\') for part in url[4:].split(',')]

On Jan 4, 12:00 pm, blackthorne francisco@gmail.com wrote:
 instead of having common strings ready to be passed as arguments, you
 would get strings that contain quotes in it. I guess...

 Consider my example:
 home url:'homepage','plugin_wiki','index'

 you will get:
 In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

 In [10]: [part.strip('\'') for part in url[4:].split(',')]
 Out[10]: ['homepage', 'plugin_wiki', 'index']

 In [11]: [part for part in url[4:].split(',')]
 Out[11]: ['homepage', 'plugin_wiki', 'index']

 Best regards

 On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu wrote:



  Why

  +                elif url.lower().startswith('url:'):
  +                       url=URL(*[part.strip('\'') for part in
  url[4:].split(',')])

  and not

  +                elif url.lower().startswith('url:'):
  +                       url=URL(*[part for part in
  url[4:].split(',')])

  Why the quotes?

  On Jan 3, 9:07 pm, blackthorne francisco@gmail.com wrote:

   Because it may not be obvious that the previous message includes a
   patch, here is from another 
   source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

   thank you

   On Jan 4, 2:51 am, Francisco Gama blacktho...@ironik.org wrote:

this patch allows you to define custom links using the URL() helper in 
the meta-menu of plugin_wiki, so you should apply it to:
models/plugin_wiki.py

the syntax used is Title url:URL_args

example:
home url:'homepage','plugin_wiki','index'
Articles page:articles
Links url:'homepage','default','links'

notice that after url: you shall not leave white spaces. This is a 
must not to touch in the regex currently being used to match that

Other idea, would be to bring this power to markmin links...

Leave comments,
Best regards

Francisco Gama Tabanez Ribeiro

E-mail: blacktho...@ironik.org
Twitter: blackthorne


[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread mdipierro
but why not simply

url:homepage/plugin_wiki/index

or

localurl:homepage/plugin_wiki/index

and no quotes?

On Jan 4, 6:00 am, blackthorne francisco@gmail.com wrote:
 instead of having common strings ready to be passed as arguments, you
 would get strings that contain quotes in it. I guess...

 Consider my example:
 home url:'homepage','plugin_wiki','index'

 you will get:
 In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

 In [10]: [part.strip('\'') for part in url[4:].split(',')]
 Out[10]: ['homepage', 'plugin_wiki', 'index']

 In [11]: [part for part in url[4:].split(',')]
 Out[11]: ['homepage', 'plugin_wiki', 'index']

 Best regards

 On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu wrote:

  Why

  +                elif url.lower().startswith('url:'):
  +                       url=URL(*[part.strip('\'') for part in
  url[4:].split(',')])

  and not

  +                elif url.lower().startswith('url:'):
  +                       url=URL(*[part for part in
  url[4:].split(',')])

  Why the quotes?

  On Jan 3, 9:07 pm, blackthorne francisco@gmail.com wrote:

   Because it may not be obvious that the previous message includes a
   patch, here is from another 
   source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

   thank you

   On Jan 4, 2:51 am, Francisco Gama blacktho...@ironik.org wrote:

this patch allows you to define custom links using the URL() helper in 
the meta-menu of plugin_wiki, so you should apply it to:
models/plugin_wiki.py

the syntax used is Title url:URL_args

example:
home url:'homepage','plugin_wiki','index'
Articles page:articles
Links url:'homepage','default','links'

notice that after url: you shall not leave white spaces. This is a 
must not to touch in the regex currently being used to match that

Other idea, would be to bring this power to markmin links...

Leave comments,
Best regards

Francisco Gama Tabanez Ribeiro

E-mail: blacktho...@ironik.org
Twitter: blackthorne




Re: [web2py] Re: web2py unavailable during file upload cherokee+ssl+uWSGI+web2py

2011-01-04 Thread Philippe ENTZMANN
Yes I use sqlite as the default web2py database backend.
The record is created at the end of the transfer, why should have been
a lock during the transfer ?
This lock does not occur without Cherokee/uWSGI, why ?

To check this, what is the simplest controller code to achieve an
upload (without database) ?

2011/1/4 mdipierro mdipie...@cs.depaul.edu:
 Do you use sqlite? That may be locking.


 On Jan 3, 5:49 pm, PhE philippe.entzm...@gmail.com wrote:
 Following Massimo's advice on my previous post on file upload with
 rocket/ssl, I decided to give another try to cherokee/web2py.

 Now I've got reliable ssl file uploads : 4 successful uploads of a 5
 MB file (3 to 4 minutes transfer each).
 This is a great forward step ;-)

 But I still have a big issue : during the transfer the web2py service
 is unavailable.
 An attempt to access the index page of web2py makes Cherokee to
 respond :
 503 Service Unavailable
 Cherokee web server 1.0.15 (Ubuntu), Port 443

 I tried to access the page from a different browser to avoid session
 locking with same error.

 Note that I use a dummy application with only one table, one upload
 field and no code at all ! (I use the really fresh 1.91.6)
 Upload is done by admin pagehttps://mysite/myapp/appadmin/insert/db/mytable

 I used uWSGI following this recipe 
 :http://web2pyslices.com/main/slices/take_slice/110



[web2py] Web Patterns in web2py

2011-01-04 Thread contatogilson...@gmail.com
Hello,

Below I am forwarding the email I sent to Di Pierro, speaking of a
suggestion I made in the module's CRUD web2py. As he asked to pass these
tips to the group, I thought it best to pass the same for everyone.

 Hello,

 I wanted to give more of an idea, because I realized one thing in the CRUD
  tool
 web2py. In forms, it generates the layout from tables, and in the
 web standards we currently use is not recommended. If you want this tip is
 for the next versions. I do not guarantee, but when I have more time
 do with Bruno Rocha of Brazil here, to see if you have the possibility to
 this. With that, who makes the first best:)

 Thank you for your attention.



 You can do

 form = SQLFORM(...,formstyle='divs')


 There are a few more formstyle options


'table3cols' (default)

'table2cols'

'divs'

'ul'


or you can pass your own function (undocumented) and to be revised in the
specs.

If you have advice for improvement please bring this up on the google group.
Hope this helps.

_
*Gilson Filho*
*Web Developer
Blog:* gilson-filho.blogspot.com
*Twitter:* twitter.com/gilsonfilho


[web2py] Re: web2py unavailable during file upload cherokee+ssl+uWSGI+web2py

2011-01-04 Thread mdipierro
There are two possibilities.

One was suggested by Roberto.

Another possibility is SQLite. It may block during the transfer if the
upload is done in DB and/or if there is an un-committed transaction.

massimo

On Jan 4, 2:09 am, Philippe ENTZMANN philippe.entzm...@gmail.com
wrote:
 Yes I use sqlite as the default web2py database backend.
 The record is created at the end of the transfer, why should have been
 a lock during the transfer ?
 This lock does not occur without Cherokee/uWSGI, why ?

 To check this, what is the simplest controller code to achieve an
 upload (without database) ?

 2011/1/4 mdipierro mdipie...@cs.depaul.edu:

  Do you use sqlite? That may be locking.

  On Jan 3, 5:49 pm, PhE philippe.entzm...@gmail.com wrote:
  Following Massimo's advice on my previous post on file upload with
  rocket/ssl, I decided to give another try to cherokee/web2py.

  Now I've got reliable ssl file uploads : 4 successful uploads of a 5
  MB file (3 to 4 minutes transfer each).
  This is a great forward step ;-)

  But I still have a big issue : during the transfer the web2py service
  is unavailable.
  An attempt to access the index page of web2py makes Cherokee to
  respond :
  503 Service Unavailable
  Cherokee web server 1.0.15 (Ubuntu), Port 443

  I tried to access the page from a different browser to avoid session
  locking with same error.

  Note that I use a dummy application with only one table, one upload
  field and no code at all ! (I use the really fresh 1.91.6)
  Upload is done by admin pagehttps://mysite/myapp/appadmin/insert/db/mytable

  I used uWSGI following this recipe 
  :http://web2pyslices.com/main/slices/take_slice/110




[web2py] Re: Built-in editor quirk

2011-01-04 Thread dederocks
Thanks for the cue -- indeed, no problem with Chrome for example. I
use FF 3.6.13 on Win7.

On 4 jan, 12:51, mdipierro mdipie...@cs.depaul.edu wrote:
 Which browser? The browser is the issue.

 On Jan 4, 1:49 am, dederocks dediro...@gmail.com wrote:

  Hello,
  There's been a weird bug in the built-in editor for some time now:
  when you highlight a line, the highlight actually shows up two lines
  above the selection. Any way to fix this?

  Python 2.7, Windows 7, trunk version.

  Thanks  BR, Andre




Re: [web2py] Re: IS_IN_DB() argument

2011-01-04 Thread Fabiano - deStilaDo
On Tue, Jan 4, 2011 at 9:45 AM, mdipierro mdipie...@cs.depaul.edu wrote:
 ok, in trunk.

Wow, don't you sleep? =)


As I am using and learning web2py, I've been reading its source-code
to understand the magic under the hood and to make a better use of
it. I am not confident yet to write my own patches, but I hope I can
start to contribute with something soon.


Fabiano.



On Tue, Jan 4, 2011 at 9:45 AM, mdipierro mdipie...@cs.depaul.edu wrote:
 ok, in trunk.

 On Jan 3, 8:34 pm, Fabiano fabianoeng...@gmail.com wrote:
 Ok. By the way, If I may suggest, it would be a nice feature, and backward
 compatible. As the id is an implied column and you must specify it explicit
 when making references, I think it it would be even more consistent to
 specify a table, the id would be implicit in both cases.

 Regards,

 On Monday, January 3, 2011 11:23:46 PM UTC-2, mdipierro wrote:

  The error is in the example. IS_IN_DB *never* accepted a table as
  second argument.
  Sorry for the confusion. Will fix the example.

  Massimo

  On Jan 3, 6:25 pm, Fabiano - deStilaDo fabian...@gmail.com
  wrote:
   Hi,

   from validators.py:

    342 class IS_IN_DB(Validator):
    343     
    344     example::
    345
    346         INPUT(_type='text', _name='name',
    347               requires=IS_IN_DB(db, db.table, zero=''))
    348
    349     used for reference fields, rendered as a dropbox
    350     

   But I can't use the documented syntax: IS_IN_DB(db, db.table). I had
   to use explicit db.table.id as argument.

   It looks like the current code (1.91.6) does not accept a table as
   argument. Apparently, it cannot figure out that when you specify a
   table instead of a field it should use the table's id field. It relies
   on the field representation as string to extract the field name,
   splitting it by dots, as shows line 371 from the class' constructor:

    370         self.field = field
    371         (ktable, kfield) = str(self.field).split('.')

   Wouldn't be better to test the argument with something like isinstance()
  first?

   Sorry if I misunderstood something, but I think that if this is not a
   bug, then the documentation should be updated.

   I also didn't check the code for IS_NOT_IN_DB(), but I guess this
   class may have the same issue.

   Regards,

   Fabiano.




[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread blackthorne
That way, you can use URL() to pass args [] and vars {} under the
web2py way. Have to test it though...

On Jan 4, 12:24 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 but why not simply

 url:homepage/plugin_wiki/index

 or

 localurl:homepage/plugin_wiki/index

 and no quotes?

 On Jan 4, 6:00 am, blackthorne francisco@gmail.com wrote:



  instead of having common strings ready to be passed as arguments, you
  would get strings that contain quotes in it. I guess...

  Consider my example:
  home url:'homepage','plugin_wiki','index'

  you will get:
  In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

  In [10]: [part.strip('\'') for part in url[4:].split(',')]
  Out[10]: ['homepage', 'plugin_wiki', 'index']

  In [11]: [part for part in url[4:].split(',')]
  Out[11]: ['homepage', 'plugin_wiki', 'index']

  Best regards

  On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu wrote:

   Why

   +                elif url.lower().startswith('url:'):
   +                       url=URL(*[part.strip('\'') for part in
   url[4:].split(',')])

   and not

   +                elif url.lower().startswith('url:'):
   +                       url=URL(*[part for part in
   url[4:].split(',')])

   Why the quotes?

   On Jan 3, 9:07 pm, blackthorne francisco@gmail.com wrote:

Because it may not be obvious that the previous message includes a
patch, here is from another 
source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

thank you

On Jan 4, 2:51 am, Francisco Gama blacktho...@ironik.org wrote:

 this patch allows you to define custom links using the URL() helper 
 in the meta-menu of plugin_wiki, so you should apply it to:
 models/plugin_wiki.py

 the syntax used is Title url:URL_args

 example:
 home url:'homepage','plugin_wiki','index'
 Articles page:articles
 Links url:'homepage','default','links'

 notice that after url: you shall not leave white spaces. This is a 
 must not to touch in the regex currently being used to match that

 Other idea, would be to bring this power to markmin links...

 Leave comments,
 Best regards

 Francisco Gama Tabanez Ribeiro

 E-mail: blacktho...@ironik.org
 Twitter: blackthorne


[web2py] web2py+FastCGI

2011-01-04 Thread walter
I have used the http://web2pyslices.com/main/slices/take_slice/76 as
an example. But when I try to call the http://w2p.edu/welcome/default/
index I get a page with the next text: Internal error
Ticket issued: unknown.


[web2py] Google Summer of Code

2011-01-04 Thread James Hancock
I get back to the states in March and I was wondering what kind of
opportunities there are for a GoSC project with web2py?

I was thinking specifically in the writing tests area, the admin, and
documentation ( on the website specifically). I have been doing
research about it and it looks like these places could use a little
love. I forward to getting into web2py when I get back and there isn't
any better way than writing tests for it or documentation.

Any thoughts?

Cheers,
James Hancock


[web2py] Re: web2py unavailable during file upload cherokee+ssl+uWSGI+web2py

2011-01-04 Thread mdipierro
Cherokee does not uses thread? 4 processed with 1thread/process seems
limited.

On Jan 4, 7:34 am, PhE philippe.entzm...@gmail.com wrote:
 Thank you !
 Fixed ! Now, I can browse while an upload is in progress.

 I just added the processes value to my uWSGI conf file :
 uwsgi
    pythonpath/var/web2py//pythonpath
    processes4/processes
    app mountpoint=/
            scriptwsgihandler/script
    /app
 /uwsgi

 On 4 jan, 09:21, Roberto De Ioris robe...@unbit.it wrote:

  Il giorno 04/gen/2011, alle ore 00.49, PhE ha scritto:

   Following Massimo's advice on my previous post on file upload with
   rocket/ssl, I decided to give another try to cherokee/web2py.

   Now I've got reliable ssl file uploads : 4 successful uploads of a 5
   MB file (3 to 4 minutes transfer each).
   This is a great forward step ;-)

   But I still have a big issue : during the transfer the web2py service
   is unavailable.
   An attempt to access the index page of web2py makes Cherokee to
   respond :
   503 Service Unavailable
   Cherokee web server 1.0.15 (Ubuntu), Port 443

  It looks to me that you have no concurrency in your setup.
  Cherokee is a streamed-upload server so the uploads is entirely managed by 
  your app.

  If you spawn only one uwsgi process this will be be busy during uploads and 
  cannot accept new requests.

  Simply add -p n to your command line or processesn/processes to your 
  xml config file.

  Where n is the number of processes you want to spawn.

  --
  Roberto De Iorishttp://unbit.it




[web2py] Re: web2py+FastCGI

2011-01-04 Thread mdipierro
This may be a permission issue as web2py cannot access the file system
(either looking the wrong folder or unable to read/write).

On Jan 4, 7:21 am, walter wdv...@gmail.com wrote:
 I have used thehttp://web2pyslices.com/main/slices/take_slice/76as
 an example. But when I try to call the http://w2p.edu/welcome/default/
 index I get a page with the next text: Internal error
 Ticket issued: unknown.


[web2py] Re: Built-in editor quirk

2011-01-04 Thread Anthony
It happens in IE on Win7 too.
 

On Tuesday, January 4, 2011 7:32:24 AM UTC-5, dederocks wrote:

 Thanks for the cue -- indeed, no problem with Chrome for example. I 
 use FF 3.6.13 on Win7. 

 On 4 jan, 12:51, mdipierro mdip...@cs.depaul.edu wrote: 
  Which browser? The browser is the issue. 
  
  On Jan 4, 1:49 am, dederocks dedi...@gmail.com wrote: 
  
   Hello, 
   There's been a weird bug in the built-in editor for some time now: 
   when you highlight a line, the highlight actually shows up two lines 
   above the selection. Any way to fix this? 
  
   Python 2.7, Windows 7, trunk version. 
  
   Thanks  BR, Andre 
  
 



Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
I like the modified admin approach, it would be simpler, for teaching
purposes it would work, it would need to be modified for production style
scenarios as it would not be an acceptable risk.

On Tue, Jan 4, 2011 at 6:50 AM, mdipierro mdipie...@cs.depaul.edu wrote:

 This can be done but it would not prevent one use to write code (an
 app) that reads or deletes another user app. As long as this is clear,
 I coud modify admin for this purpose (or create another admin).

 On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
  I think it'll be convenient for multiple users to work on one web2py
  installation, if there's a layer on top of the admin app, providing
  the following features:
 
  1. The admin app allows user registration.
  2. Each user can view/edit only apps that he/she creates.
 
  This is strictly at the (admin) app level.  Everything is the same as
  before at the filesystem level.
 
  (This is particularly useful for teaching (I think): one web2py app,
  many students).



[web2py] Re: onlinestatus

2011-01-04 Thread pk
can nobody help me???

On 3 Jan., 23:13, pk peter.kirch...@youngdesigners.de wrote:
 hi together,

 i have a function for the onlineuser:

 usersall=db(db.online.last_visittime.time()-dt)
 (db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)
 return TABLE(*[TD(user.user_name) for user in usersall])

 but i will to get all the onlineuser which are friends of mine.
 here is my friendsdatabasetable:

 #
 ## Tabelle Freunde
 #
 db.define_table('friends',
                 SQLField('userid',
                          default=auth.user.id if auth.user else 0,
                          writable=False, readable=False),
                 SQLField('hauptperson',
                          default=auth.user.user_name if auth.user else
 0,
                          writable=False, readable=False,
 label='Hauptperson'),
                 SQLField('freund', label='Freund'),
                 SQLField('freundseit', 'datetime',
 default=request.now, label='Freund seit'),
                 SQLField('bestaetigt','boolean', default=False))

 db.friends.userid.requires=IS_IN_DB(db,'auth_user.id')
 db.friends.hauptperson.requires=IS_IN_DB(db,'auth_user.user_name')
 db.friends.freund.requires=IS_IN_DB(db,'auth_user.user_name')

 how can i get this list and how can i do the name clickable???

 thanks for your help

 peter


Re: [web2py] Re: Built-in editor quirk

2011-01-04 Thread Bruno Rocha
In the future there will be only one browser engine: webkit

-- 

Bruno Rocha
http://about.me/rochacbruno/bio


[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread blackthorne
Broken here:
In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

In [22]: [part.strip('\'').strip('\') for part in url[4:].split(',')]
Out[22]: [args=['x, y'], vars=dict(z='t')]

Just use:
elif url.lower().startswith('url:'):
url=eval(URL( + url[4:] + ))

This was my first solution, it works well with args and vars.
This case works, tested against:
Home url:'homepage','plugin_wiki','index'
Articles page:articles
Links url:'homepage','default','links'
Test url:'f',args=['x','y'],vars=dict(z='t')
Projects url:'f',args=['x','y']

Generated:
http://127.0.0.1:8000/homepage/plugin_wiki/index
http://127.0.0.1:8000/homepage/plugin_wiki/page/articles
http://127.0.0.1:8000/homepage/default/links
http://127.0.0.1:8000/homepage/plugin_wiki/f/x/y?z=t
http://127.0.0.1:8000/homepage/plugin_wiki/f/x/y


The only small gotcha is white space absence being required because of
the regular expression being used to parse the meta-menu lines...

On Jan 4, 1:13 pm, blackthorne francisco@gmail.com wrote:
 That way, you can use URL() to pass args [] and vars {} under the
 web2py way. Have to test it though...

 On Jan 4, 12:24 pm, mdipierro mdipie...@cs.depaul.edu wrote:



  but why not simply

  url:homepage/plugin_wiki/index

  or

  localurl:homepage/plugin_wiki/index

  and no quotes?

  On Jan 4, 6:00 am, blackthorne francisco@gmail.com wrote:

   instead of having common strings ready to be passed as arguments, you
   would get strings that contain quotes in it. I guess...

   Consider my example:
   home url:'homepage','plugin_wiki','index'

   you will get:
   In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

   In [10]: [part.strip('\'') for part in url[4:].split(',')]
   Out[10]: ['homepage', 'plugin_wiki', 'index']

   In [11]: [part for part in url[4:].split(',')]
   Out[11]: ['homepage', 'plugin_wiki', 'index']

   Best regards

   On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu wrote:

Why

+                elif url.lower().startswith('url:'):
+                       url=URL(*[part.strip('\'') for part in
url[4:].split(',')])

and not

+                elif url.lower().startswith('url:'):
+                       url=URL(*[part for part in
url[4:].split(',')])

Why the quotes?

On Jan 3, 9:07 pm, blackthorne francisco@gmail.com wrote:

 Because it may not be obvious that the previous message includes a
 patch, here is from another 
 source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

 thank you

 On Jan 4, 2:51 am, Francisco Gama blacktho...@ironik.org wrote:

  this patch allows you to define custom links using the URL() helper 
  in the meta-menu of plugin_wiki, so you should apply it to:
  models/plugin_wiki.py

  the syntax used is Title url:URL_args

  example:
  home url:'homepage','plugin_wiki','index'
  Articles page:articles
  Links url:'homepage','default','links'

  notice that after url: you shall not leave white spaces. This is 
  a must not to touch in the regex currently being used to match that

  Other idea, would be to bring this power to markmin links...

  Leave comments,
  Best regards

  Francisco Gama Tabanez Ribeiro

  E-mail: blacktho...@ironik.org
  Twitter: blackthorne


Re: [web2py] SOAP service - repeating elements/sets of elements

2011-01-04 Thread Mariano Reingart
On Mon, Jan 3, 2011 at 8:49 PM, Dragonfyre13 dragonfyr...@gmail.com wrote:
 Thought this might be interesting to someone, as it took me digging
 through the  pysimplesoap code to figure out. So I'll record it here
 for posterity.

 In web2py, I needed a soap service that can have one to many sets of a
 a particular element. This caused some issues, as there's not really a
 convention documented for supporting multiple elements posted in,
 without explicitly defining all of them.

See:
http://code.google.com/p/pysimplesoap/wiki/ComplexTypes
http://code.google.com/p/pysimplesoap/issues/detail?id=4

But you are right, that is not documented in deep, I'll make a recipe
with further explanations.

 what I found, was putting a dict in a list, you could get this (taken
 from the unmarshall section of the simplexml code, since the
 pysimplesoap does this:
 args = method.children().unmarshall(args_types)

 # types is a dict of {tag name: convertion function}
 # example: types={'p': {'a': int,'b': int}, 'c': [{'d':str}]}
 #   expected xml: pa1/ab2/b/pcdhola/ddchau/d
 #   returned value: {'p': {'a':1,'b':2}, `'c':[{'d':'hola'},
 {'d':'chau'}]}

 Notice in there, that by putting the {'d':str} object in a list, even
 a single element list, it makes it able to be repeated, over and over
 again. No idea how to set a limit on repetitions, or how this would
 react to simply not including a value (is a zero to many, or one to
 many?) but I'm trying it out now. Here's the completed decorator and
 func definition:

 @service.soap('methodName',returns={'result':bool},
              args={'data':[{'elemName':str, 'elemValue':str}]})
 def mymethod(data):
    
    Does nothing right now.
    
    # the var data is filled with a list of dicts. Each dict has two
 elements,
    # elemName and elemValue, both strings. Can iterate over this,
 and pull
    # out any data required.
    return True

 So it currently doesn't do anything yet, and the design is bad since I
 was handed a wsdl and told make that work, but here's outstanding
 questions I have on pysimplesoap/web2py soap stuff:

The code seems fine, why you say that it is a bad design?
It does what you need?

 1) It doesn't look like there's currently any way to say int between
 x and y, just that it's an int. Since it's auto generating the wsdl,
 that seems important...

This cannot be done now, it would require changing the simple type
declaration, using custom types instead of python types (int, float,
etc.).
See reply 4

 2) Same as above goes for data from a particular set. I can validate
 this in the code of the service, but I really have no clue how to get
 that into the wsdl.

What do you want to do?
See reply 4

 3) How do I get this to throw a specific soap fault, when there's an
 error?

I think you can raise any python exception and the library will
convert it to a SoapFault.
If you want to raise an specific SoapFault, you will have to modify the code.

 4) Can I make a particular value optional (0-1 repetitions) or a range
 of repetitions? (5-100, 1-4, etc) or is this also something that needs
 to go in the python code, and it just can't make it into the wsdl
 right now?

This would be relatively easy to implement but it would require a more
complex type definition (using custom list classes and so on)
You can't make it into the wsdl right now, but you can write the wsdl
by hand and do the checks in the code.

I would recommend you to always do the checks at python level, don't
rely on the wsdl (there are tools that even don't use wsdl at all to
check the call parameters)

 5) What are my options with complex types or custom types?
 Supported, unsupported? (http://oreilly.com/catalog/javasoap/chapter/
 ch05.html)

I don't understand your question, both complex and custom types are
supported (up to a limited extent).

 6) Still playing around with how to change my soap response up.

Again, what do you want to do?
If standard response (or request) is not enough, you can use raw xml
for input/output full control (it will merge a simple-xml dom tree if
no type declaration is used).

With this method, you can handle all cases unsupported by this library.

 Dealing much more with the simplexml.py code than I would have
 thought, as the soapdispatcher.py code is very simple (good thing!)

Yes, the idea of this library is to get a simple and functional soap
implementation.

Sadly, SOAP is a very complex specification, so if you want to use all
of its features, you end up in a complicated implementation.
The good news are (IMHO) that most of the real world applications need
a simple and standard way to interoperate, using a subset of the
specification, so the exotic features are rarely needed.

YMMV

PS: if you want to contribute to the PySimpleSoap project, fell free
to contact me or fill an issue at the project site ;-) BTW, there is a
s...@python.org mailing list dedicated to this topics.

Best regards

Mariano Reingart
http://www.sistemasagiles.com.ar

[web2py] Re: db.commit() fails?

2011-01-04 Thread Lucas R. Martins

Just worked for me! Thanks.

PS.: This documentation page confused me:
http://web2py.com/book/default/chapter/06#count,-delete,-update


On 3 jan, 15:16, mdipierro mdipie...@cs.depaul.edu wrote:
 It is not

 user.update(pass = request.vars.new_pass)

 it is

 user.update_record(pass = request.vars.new_pass)

 because

 user.update(pass = request.vars.new_pass) just updates the user row in
 ram, not the db.

 On Jan 3, 11:04 am, Lucas R. Martins lukas...@gmail.com wrote:

  Hi folks,

  i'm try to run the following code:

  form=FORM('Nova senha:',
              INPUT(_name='new_pass',_type='password',
  requires=IS_NOT_EMPTY()),
              BR(),'Confirmação:',
              INPUT(_name='confirmation',_type='password', requires=
  IS_EQUAL_TO(request.vars.new_pass, error_message=T('As senhas não
  coincidem'))),BR(),BR(),
              INPUT(_type='submit'))

      if form.accepts(request.vars, session):
              user = db(db.users.name==request.args[0]).select().first()
              user.update(pass = request.vars.new_pass)
              db.commit()
              session.flash = 'Password changed'
              redirect(URL('default','index'))

  This code runs with no errors, but my database is not being updated. I
  put the line db.commit(), but the problem keep happing.

  Anyone can help me?

  Lucas R. Martins




[web2py] Re: two alternatives for running background processes

2011-01-04 Thread apple
I would like the job to terminate on leaving the page. I can easily
achieve this via an unload event that notifies the server via ajax
that the job needs cancelling. This would also prevent multiple jobs
running if the page is refreshed.

Using XML-RPC certainly looks better than using the database if I am
running my background job via a separate web2py process. Thanks for
that as I had not come across this before and it will be very useful.

However re my original post it still seems simpler code to run the
background job in threads within my web2py controller. Is there some
architectural reason why this is a bad idea?




On Jan 3, 6:29 pm, PhE philippe.entzm...@gmail.com wrote:
 With your second alternative your browser needs to keep the Ajax
 connexion open.
 If the connection is closed what will happen to your thread ? I don't
 master web2py internals but if the client it not there anymore, I
 think the server could kill the server part of the connexion (so kill
 your thread).
 If the page is reloaded twice or more, you will have 2 or more thread
 running ?

 What about a separate process (think about a daemon) that will
 listen for job to be executed ?
 The communication should not be by direct SQLite queries but with XML-
 RPC calls.
 Those calls could also handle session communication.

 On 3 jan, 17:59, apple simo...@gmail.com wrote:







  I want an execute button. This starts a multi-threaded background
  process that scrapes data from 100 web pages. While it is scraping I
  want an execute web page that shows a running total of the number of
  pages scraped; and confirms when the process has completed.

  If one uses threads in the execute controller it does not work. If you
  join the threads then this blocks the controller until execution is
  complete, and the execute view page only gets shown at the end of
  execution. If you don't join the threads then web2py kills them all
  when it reaches the return at the end of the controller.

  The manual and a previous forum discussion suggest running a separate
  web2py instance i.e. subprocess.Popen(c:/python27/python %s/web2py.py
  -S scraper -M -R %s %(os.getcwd(), os.getcwd()+/applications/scraper/
  modules/execute.py -A   str(session.scraperid))+ +str(processid),
  shell=True). However this requires a separate web2py process. Also the
  subprocess has no access to session variables so you need to use the
  database to communicate between the two. This means database reads
  every time the web page polls for latest status.

  An alternative would be an ajax call from execute view to a controller
  that starts the threads and joins them. This would keep it all within
  the same web2py instance and retain access to session variables. It
  requires less code and is simpler.

  Are there any downsides to the second alternative?


Re: [web2py] Re: Memory leak - followup

2011-01-04 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Whenever in controller/model is the class declared, the same result.

Michele Comitini wrote:
 Try to put the Blah class in the global scope of the controller.  Do
 you get same result?

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0jOaoACgkQ3oCkkciamVH++gCgpR/w98HwRVUgTqOpCbj+/ITE
LrwAn3b34zURtjOXDb3rXIsX3bwDXc4v
=2l85
-END PGP SIGNATURE-


[web2py] Re: How to get field values before form.accepts(...)

2011-01-04 Thread annet
Massimo,

Thanks for your reply. I tried:

form[0][2][2].insert(0,A('already in
database?',_onmouseover=this.style.cursor='pointer';,_onclick=javascript:details('%s/'+
$('#kvk_number').val()+'/'+$
('#subdossiernumber').val())%URL(r=request,f='retrieve')))


In the view this is rendered as follows:

a onclick=javascript:details('/mock/crud_company/retrieve/'+$
('#kvk_number').val()+'/'+$('#subdossiernumber').val())
onmouseover=this.style.cursor='pointer'; style=cursor: pointer;
already in database?/a


When I click the 'already in database? link it produces the following
URL: http://127.0.0.1:8000/mock/crud_company/retrieve/undefined/undefined


I hope I provided you with enough information to help me solve the
problem.


Kind regards,

Annet.


Re: [web2py] onlinestatus

2011-01-04 Thread Richard Vézina
The model are missing for db.online

Richard

On Mon, Jan 3, 2011 at 5:13 PM, pk peter.kirch...@youngdesigners.de wrote:

 hi together,

 i have a function for the onlineuser:

 usersall=db(db.online.last_visittime.time()-dt)
 (db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)
 return TABLE(*[TD(user.user_name) for user in usersall])

 but i will to get all the onlineuser which are friends of mine.
 here is my friendsdatabasetable:

 #
 ## Tabelle Freunde
 #
 db.define_table('friends',
SQLField('userid',
 default=auth.user.id if auth.user else 0,
 writable=False, readable=False),
SQLField('hauptperson',
 default=auth.user.user_name if auth.user else
 0,
 writable=False, readable=False,
 label='Hauptperson'),
SQLField('freund', label='Freund'),
SQLField('freundseit', 'datetime',
 default=request.now, label='Freund seit'),
SQLField('bestaetigt','boolean', default=False))

 db.friends.userid.requires=IS_IN_DB(db,'auth_user.id')
 db.friends.hauptperson.requires=IS_IN_DB(db,'auth_user.user_name')
 db.friends.freund.requires=IS_IN_DB(db,'auth_user.user_name')

 how can i get this list and how can i do the name clickable???

 thanks for your help

 peter


[web2py] Fwd: [python.pt] [Fwd: Python Developer Role - contract]

2011-01-04 Thread António Ramos
 Hi Marco, I’m currently looking for a Python Developer with knowledge of
C++ for leading financial institution.  They need developers with excellent
Python and strong knowledge of C++ development.  The role will involve
working on a complex trading system and will require candidates to create
and maintain Python-extensions for various API's, using model-driven code
generation (Python/C interface and pure Python).  The role will be a 6 month
extendable contract based in Frankfurt, Germany.  This is an excellent
opportunity to join a leading financial institution based in Frankfurt.



If interested, please either drop me and email or call me on 02072563546.
Alternatively, please feel free to pass on my contact details to anyone you
feel might be suitable.  We pay a referral fee of £300 for every candidate
successfully placed.



Thanks





* *

*Mark Rees *| *I.T. Skillfinder*

*Consultant***

* *

20 St Dunstan’s Hill | London | EC3R 8HY

DDI +44(0) 20 7256 3546 | Fax +44(0) 20 7256 3551

www.it-skillfinder.co.uk



P Please consider the environment before printing

The information in this email is confidential and may be legally privileged
for use by the addressee only. If you are not the intended recipient, you
must not use, disclose, distribute, copy, print or rely on this message.
Please notify the sender by return email and then delete the message from
your computer. I.T. Skillfinder accepts no responsibility for changes made
to this message after it was sent Although this email and any attachments
are believed to be free of any virus, or any other defect which might affect
any computer or IT system into which they are received and opened, it is the
responsibility of the recipient to ensure that they are virus free and no
responsibility is accepted by I.T. Skillfinder for any loss or damage
arising in any way from receipt or use thereof. Any opinions or advice
contained in this email are not necessarily those of I.T.Skillfinder Ltd.



__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
__

 --
Recebeu esta mensagem porque está inscrito em Grupo Python Portugal
do Grupos Google.
Para enviar mensagens para este grupo, envie um email para
python...@googlegroups.com
Para anular a inscrição neste grupo, envie um email para
python-pt+unsubscr...@googlegroups.compython-pt%2bunsubscr...@googlegroups.com
Para mais opções, visite este grupo em
http://groups.google.com/group/python-pt?hl=pt-PT


[web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread mdipierro
In trunk.

- Deploy the latest admin
- edit file applications/admin/models/0.py and set
  MULTI_USER_MODE = True
- Try access admin and it will require registration/login
- The first user to register is teacher (can see all apps)
- All other users are students (can only see/edit/create their own
apps)

This does not prevent one user from writing dangerous code. The code,
whoever creates it, always runs under the same privileged and has
access to the entire web2py folder.

At the moment students get access to each other appdmin controllers.

Please help with testing!

On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
 I like the modified admin approach, it would be simpler, for teaching
 purposes it would work, it would need to be modified for production style
 scenarios as it would not be an acceptable risk.

 On Tue, Jan 4, 2011 at 6:50 AM, mdipierro mdipie...@cs.depaul.edu wrote:
  This can be done but it would not prevent one use to write code (an
  app) that reads or deletes another user app. As long as this is clear,
  I coud modify admin for this purpose (or create another admin).

  On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
   I think it'll be convenient for multiple users to work on one web2py
   installation, if there's a layer on top of the admin app, providing
   the following features:

   1. The admin app allows user registration.
   2. Each user can view/edit only apps that he/she creates.

   This is strictly at the (admin) app level.  Everything is the same as
   before at the filesystem level.

   (This is particularly useful for teaching (I think): one web2py app,
   many students).




[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread mdipierro
There cannot be eval in there. The plugin may be in level=1 (secure
mode).

On Jan 4, 8:38 am, blackthorne francisco@gmail.com wrote:
 Broken here:
 In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

 In [22]: [part.strip('\'').strip('\') for part in url[4:].split(',')]
 Out[22]: [args=['x, y'], vars=dict(z='t')]

 Just use:
                 elif url.lower().startswith('url:'):
                         url=eval(URL( + url[4:] + ))

 This was my first solution, it works well with args and vars.
 This case works, tested against:
 Home url:'homepage','plugin_wiki','index'
 Articles page:articles
 Links url:'homepage','default','links'
 Test url:'f',args=['x','y'],vars=dict(z='t')
 Projects url:'f',args=['x','y']

 Generated:http://127.0.0.1:8000/homepage/plugin_wiki/indexhttp://127.0.0.1:8000/homepage/plugin_wiki/page/articleshttp://127.0.0.1:8000/homepage/default/linkshttp://127.0.0.1:8000/homepage/plugin_wiki/f/x/y?z=thttp://127.0.0.1:8000/homepage/plugin_wiki/f/x/y

 The only small gotcha is white space absence being required because of
 the regular expression being used to parse the meta-menu lines...

 On Jan 4, 1:13 pm, blackthorne francisco@gmail.com wrote:

  That way, you can use URL() to pass args [] and vars {} under the
  web2py way. Have to test it though...

  On Jan 4, 12:24 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   but why not simply

   url:homepage/plugin_wiki/index

   or

   localurl:homepage/plugin_wiki/index

   and no quotes?

   On Jan 4, 6:00 am, blackthorne francisco@gmail.com wrote:

instead of having common strings ready to be passed as arguments, you
would get strings that contain quotes in it. I guess...

Consider my example:
home url:'homepage','plugin_wiki','index'

you will get:
In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

In [10]: [part.strip('\'') for part in url[4:].split(',')]
Out[10]: ['homepage', 'plugin_wiki', 'index']

In [11]: [part for part in url[4:].split(',')]
Out[11]: ['homepage', 'plugin_wiki', 'index']

Best regards

On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu wrote:

 Why

 +                elif url.lower().startswith('url:'):
 +                       url=URL(*[part.strip('\'') for part in
 url[4:].split(',')])

 and not

 +                elif url.lower().startswith('url:'):
 +                       url=URL(*[part for part in
 url[4:].split(',')])

 Why the quotes?

 On Jan 3, 9:07 pm, blackthorne francisco@gmail.com wrote:

  Because it may not be obvious that the previous message includes a
  patch, here is from another 
  source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

  thank you

  On Jan 4, 2:51 am, Francisco Gama blacktho...@ironik.org wrote:

   this patch allows you to define custom links using the URL() 
   helper in the meta-menu of plugin_wiki, so you should apply it to:
   models/plugin_wiki.py

   the syntax used is Title url:URL_args

   example:
   home url:'homepage','plugin_wiki','index'
   Articles page:articles
   Links url:'homepage','default','links'

   notice that after url: you shall not leave white spaces. This 
   is a must not to touch in the regex currently being used to match 
   that

   Other idea, would be to bring this power to markmin links...

   Leave comments,
   Best regards

   Francisco Gama Tabanez Ribeiro

   E-mail: blacktho...@ironik.org
   Twitter: blackthorne




[web2py] User Login

2011-01-04 Thread contatogilson...@gmail.com
How can I capture the name of the user logged in and put in the view,
without
links to Login, and Register Lose Password?
_
*Gilson Filho*
*Desenvolvedor Web
Blog:* gilson-filho.blogspot.com
*Twitter:* twitter.com/gilsonfilho


Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
Thanks Massimo,
Checking out  trunk now.

On Tue, Jan 4, 2011 at 10:49 AM, mdipierro mdipie...@cs.depaul.edu wrote:

 In trunk.

 - Deploy the latest admin
 - edit file applications/admin/models/0.py and set
  MULTI_USER_MODE = True
 - Try access admin and it will require registration/login
 - The first user to register is teacher (can see all apps)
 - All other users are students (can only see/edit/create their own
 apps)

 This does not prevent one user from writing dangerous code. The code,
 whoever creates it, always runs under the same privileged and has
 access to the entire web2py folder.

 At the moment students get access to each other appdmin controllers.

 Please help with testing!

 On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
  I like the modified admin approach, it would be simpler, for teaching
  purposes it would work, it would need to be modified for production style
  scenarios as it would not be an acceptable risk.
 
  On Tue, Jan 4, 2011 at 6:50 AM, mdipierro mdipie...@cs.depaul.edu
 wrote:
   This can be done but it would not prevent one use to write code (an
   app) that reads or deletes another user app. As long as this is clear,
   I coud modify admin for this purpose (or create another admin).
 
   On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
I think it'll be convenient for multiple users to work on one web2py
installation, if there's a layer on top of the admin app, providing
the following features:
 
1. The admin app allows user registration.
2. Each user can view/edit only apps that he/she creates.
 
This is strictly at the (admin) app level.  Everything is the same as
before at the filesystem level.
 
(This is particularly useful for teaching (I think): one web2py app,
many students).
 
 



[web2py] Re: Memory leak - followup

2011-01-04 Thread mdipierro
can you show us the guppy stats before and after caching? without
caching any db object?
can you also email me the entire app code?

On Jan 4, 9:15 am, David Zejda d...@atlas.cz wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Whenever in controller/model is the class declared, the same result.

 Michele Comitini wrote:
  Try to put the Blah class in the global scope of the controller.  Do
  you get same result?

 - --
 David Zejda, Open-IT cz
 web development  serviceshttp://www.o-it.info
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.9 (GNU/Linux)
 Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org

 iEYEARECAAYFAk0jOaoACgkQ3oCkkciamVH++gCgpR/w98HwRVUgTqOpCbj+/ITE
 LrwAn3b34zURtjOXDb3rXIsX3bwDXc4v
 =2l85
 -END PGP SIGNATURE-


Re: [web2py] User Login

2011-01-04 Thread Bruno Rocha
{{=session.auth.user.first_name}}
{{=session.auth.user.last_name}}

session
auth:
expiration:
3600
last_visit:
datetime.datetime(2011, 1, 4, 14, 0, 42, 458812)
user:
email:
rochacbr...@gmail.com
first_name:
bruno
id:
1
last_name:
rocha
password:
xxx
registration_key:
reset_password_key




2011/1/4 contatogilson...@gmail.com contatogilson...@gmail.com

 How can I capture the name of the user logged in and put in the view,
 without
 links to Login, and Register Lose Password?
 _
 *Gilson Filho*
 *Desenvolvedor Web
 Blog:* gilson-filho.blogspot.com
 *Twitter:* twitter.com/gilsonfilho




-- 

Bruno Rocha
http://about.me/rochacbruno/bio


Re: [web2py] User Login

2011-01-04 Thread contatogilson...@gmail.com
Thank you.
_
*Gilson Filho*
*Desenvolvedor Web
Blog:* gilson-filho.blogspot.com
*Twitter:* twitter.com/gilsonfilho



2011/1/4 Bruno Rocha rochacbr...@gmail.com

 {{=session.auth.user.first_name}}
 {{=session.auth.user.last_name}}

 session
   auth :
   expiration :
 3600
  last_visit :
 datetime.datetime(2011, 1, 4, 14, 0, 42, 458812)
  user :
   email :
 rochacbr...@gmail.com
  first_name :
 bruno
  id :
 1
  last_name :
 rocha
  password :
 xxx
  registration_key :
  reset_password_key




 2011/1/4 contatogilson...@gmail.com contatogilson...@gmail.com

 How can I capture the name of the user logged in and put in the view,
 without
 links to Login, and Register Lose Password?
 _
 *Gilson Filho*
 *Desenvolvedor Web
 Blog:* gilson-filho.blogspot.com
 *Twitter:* twitter.com/gilsonfilho




 --

 Bruno Rocha
 http://about.me/rochacbruno/bio



[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread blackthorne
no local urls for secure mode... yes/no?

On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 There cannot be eval in there. The plugin may be in level=1 (secure
 mode).

 On Jan 4, 8:38 am, blackthorne francisco@gmail.com wrote:



  Broken here:
  In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

  In [22]: [part.strip('\'').strip('\') for part in url[4:].split(',')]
  Out[22]: [args=['x, y'], vars=dict(z='t')]

  Just use:
                  elif url.lower().startswith('url:'):
                          url=eval(URL( + url[4:] + ))

  This was my first solution, it works well with args and vars.
  This case works, tested against:
  Home url:'homepage','plugin_wiki','index'
  Articles page:articles
  Links url:'homepage','default','links'
  Test url:'f',args=['x','y'],vars=dict(z='t')
  Projects url:'f',args=['x','y']

  Generated:http://127.0.0.1:8000/homepage/plugin_wiki/indexhttp://127.0.0.1:8000...

  The only small gotcha is white space absence being required because of
  the regular expression being used to parse the meta-menu lines...

  On Jan 4, 1:13 pm, blackthorne francisco@gmail.com wrote:

   That way, you can use URL() to pass args [] and vars {} under the
   web2py way. Have to test it though...

   On Jan 4, 12:24 pm, mdipierro mdipie...@cs.depaul.edu wrote:

but why not simply

url:homepage/plugin_wiki/index

or

localurl:homepage/plugin_wiki/index

and no quotes?

On Jan 4, 6:00 am, blackthorne francisco@gmail.com wrote:

 instead of having common strings ready to be passed as arguments, you
 would get strings that contain quotes in it. I guess...

 Consider my example:
 home url:'homepage','plugin_wiki','index'

 you will get:
 In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

 In [10]: [part.strip('\'') for part in url[4:].split(',')]
 Out[10]: ['homepage', 'plugin_wiki', 'index']

 In [11]: [part for part in url[4:].split(',')]
 Out[11]: ['homepage', 'plugin_wiki', 'index']

 Best regards

 On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu wrote:

  Why

  +                elif url.lower().startswith('url:'):
  +                       url=URL(*[part.strip('\'') for part in
  url[4:].split(',')])

  and not

  +                elif url.lower().startswith('url:'):
  +                       url=URL(*[part for part in
  url[4:].split(',')])

  Why the quotes?

  On Jan 3, 9:07 pm, blackthorne francisco@gmail.com wrote:

   Because it may not be obvious that the previous message includes a
   patch, here is from another 
   source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

   thank you

   On Jan 4, 2:51 am, Francisco Gama blacktho...@ironik.org wrote:

this patch allows you to define custom links using the URL() 
helper in the meta-menu of plugin_wiki, so you should apply it 
to:
models/plugin_wiki.py

the syntax used is Title url:URL_args

example:
home url:'homepage','plugin_wiki','index'
Articles page:articles
Links url:'homepage','default','links'

notice that after url: you shall not leave white spaces. This 
is a must not to touch in the regex currently being used to 
match that

Other idea, would be to bring this power to markmin links...

Leave comments,
Best regards

Francisco Gama Tabanez Ribeiro

E-mail: blacktho...@ironik.org
Twitter: blackthorne


Re: [web2py] Re: How to get field values before form.accepts(...) [digression]

2011-01-04 Thread Jonathan Lundell
On Jan 4, 2011, at 7:19 AM, annet wrote:
 
 Thanks for your reply. I tried:
 
 form[0][2][2].insert(0,A('already in
 database?',_onmouseover=this.style.cursor='pointer';,_onclick=javascript:details('%s/'+
 $('#kvk_number').val()+'/'+$
 ('#subdossiernumber').val())%URL(r=request,f='retrieve')))

Wouldn't it be cool to have a systematic way of working with forms? A kind of 
DOM, with jQuery-like syntax for talking about specific components? 
Constructions like form[0][2][2].insert(0,… are impossibly opaque.




[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread mdipierro
I have no objection to local URL.  but the author of the menu may not
be the administrator therefore we cannot eval(...) text in the meta-
menu. This poses restrictions on what we can put in there. I suggest
we just allow

page_name /controller/action/arg1/arg2?a=b

and if this starts with / this is interpreted as a local URL. No need
to specify app name.



On Jan 4, 10:09 am, blackthorne francisco@gmail.com wrote:
 no local urls for secure mode... yes/no?

 On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  There cannot be eval in there. The plugin may be in level=1 (secure
  mode).

  On Jan 4, 8:38 am, blackthorne francisco@gmail.com wrote:

   Broken here:
   In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

   In [22]: [part.strip('\'').strip('\') for part in url[4:].split(',')]
   Out[22]: [args=['x, y'], vars=dict(z='t')]

   Just use:
                   elif url.lower().startswith('url:'):
                           url=eval(URL( + url[4:] + ))

   This was my first solution, it works well with args and vars.
   This case works, tested against:
   Home url:'homepage','plugin_wiki','index'
   Articles page:articles
   Links url:'homepage','default','links'
   Test url:'f',args=['x','y'],vars=dict(z='t')
   Projects url:'f',args=['x','y']

   Generated:http://127.0.0.1:8000/homepage/plugin_wiki/indexhttp://127.0.0.1:8000...

   The only small gotcha is white space absence being required because of
   the regular expression being used to parse the meta-menu lines...

   On Jan 4, 1:13 pm, blackthorne francisco@gmail.com wrote:

That way, you can use URL() to pass args [] and vars {} under the
web2py way. Have to test it though...

On Jan 4, 12:24 pm, mdipierro mdipie...@cs.depaul.edu wrote:

 but why not simply

 url:homepage/plugin_wiki/index

 or

 localurl:homepage/plugin_wiki/index

 and no quotes?

 On Jan 4, 6:00 am, blackthorne francisco@gmail.com wrote:

  instead of having common strings ready to be passed as arguments, 
  you
  would get strings that contain quotes in it. I guess...

  Consider my example:
  home url:'homepage','plugin_wiki','index'

  you will get:
  In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

  In [10]: [part.strip('\'') for part in url[4:].split(',')]
  Out[10]: ['homepage', 'plugin_wiki', 'index']

  In [11]: [part for part in url[4:].split(',')]
  Out[11]: ['homepage', 'plugin_wiki', 'index']

  Best regards

  On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu wrote:

   Why

   +                elif url.lower().startswith('url:'):
   +                       url=URL(*[part.strip('\'') for part in
   url[4:].split(',')])

   and not

   +                elif url.lower().startswith('url:'):
   +                       url=URL(*[part for part in
   url[4:].split(',')])

   Why the quotes?

   On Jan 3, 9:07 pm, blackthorne francisco@gmail.com wrote:

Because it may not be obvious that the previous message 
includes a
patch, here is from another 
source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

thank you

On Jan 4, 2:51 am, Francisco Gama blacktho...@ironik.org 
wrote:

 this patch allows you to define custom links using the URL() 
 helper in the meta-menu of plugin_wiki, so you should apply 
 it to:
 models/plugin_wiki.py

 the syntax used is Title url:URL_args

 example:
 home url:'homepage','plugin_wiki','index'
 Articles page:articles
 Links url:'homepage','default','links'

 notice that after url: you shall not leave white spaces. 
 This is a must not to touch in the regex currently being used 
 to match that

 Other idea, would be to bring this power to markmin links...

 Leave comments,
 Best regards

 Francisco Gama Tabanez Ribeiro

 E-mail: blacktho...@ironik.org
 Twitter: blackthorne




[web2py] Re: How to get field values before form.accepts(...) [digression]

2011-01-04 Thread mdipierro
We have that

form.element(...)
form.elements(...)

both take jQuery syntax.

Massimo

On Jan 4, 10:13 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Jan 4, 2011, at 7:19 AM, annet wrote:



  Thanks for your reply. I tried:

  form[0][2][2].insert(0,A('already in
  database?',_onmouseover=this.style.cursor='pointer';,_onclick=javascript:details('%s/'+
  $('#kvk_number').val()+'/'+$
  ('#subdossiernumber').val())%URL(r=request,f='retrieve')))

 Wouldn't it be cool to have a systematic way of working with forms? A kind of 
 DOM, with jQuery-like syntax for talking about specific components? 
 Constructions like form[0][2][2].insert(0,… are impossibly opaque.


[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread blackthorne
fine with me

any solution for POST method?


On Jan 4, 4:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I have no objection to local URL.  but the author of the menu may not
 be the administrator therefore we cannot eval(...) text in the meta-
 menu. This poses restrictions on what we can put in there. I suggest
 we just allow

 page_name /controller/action/arg1/arg2?a=b

 and if this starts with / this is interpreted as a local URL. No need
 to specify app name.

 On Jan 4, 10:09 am, blackthorne francisco@gmail.com wrote:



  no local urls for secure mode... yes/no?

  On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   There cannot be eval in there. The plugin may be in level=1 (secure
   mode).

   On Jan 4, 8:38 am, blackthorne francisco@gmail.com wrote:

Broken here:
In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

In [22]: [part.strip('\'').strip('\') for part in url[4:].split(',')]
Out[22]: [args=['x, y'], vars=dict(z='t')]

Just use:
                elif url.lower().startswith('url:'):
                        url=eval(URL( + url[4:] + ))

This was my first solution, it works well with args and vars.
This case works, tested against:
Home url:'homepage','plugin_wiki','index'
Articles page:articles
Links url:'homepage','default','links'
Test url:'f',args=['x','y'],vars=dict(z='t')
Projects url:'f',args=['x','y']

Generated:http://127.0.0.1:8000/homepage/plugin_wiki/indexhttp://127.0.0.1:8000...

The only small gotcha is white space absence being required because of
the regular expression being used to parse the meta-menu lines...

On Jan 4, 1:13 pm, blackthorne francisco@gmail.com wrote:

 That way, you can use URL() to pass args [] and vars {} under the
 web2py way. Have to test it though...

 On Jan 4, 12:24 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  but why not simply

  url:homepage/plugin_wiki/index

  or

  localurl:homepage/plugin_wiki/index

  and no quotes?

  On Jan 4, 6:00 am, blackthorne francisco@gmail.com wrote:

   instead of having common strings ready to be passed as arguments, 
   you
   would get strings that contain quotes in it. I guess...

   Consider my example:
   home url:'homepage','plugin_wiki','index'

   you will get:
   In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

   In [10]: [part.strip('\'') for part in url[4:].split(',')]
   Out[10]: ['homepage', 'plugin_wiki', 'index']

   In [11]: [part for part in url[4:].split(',')]
   Out[11]: ['homepage', 'plugin_wiki', 'index']

   Best regards

   On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu wrote:

Why

+                elif url.lower().startswith('url:'):
+                       url=URL(*[part.strip('\'') for part in
url[4:].split(',')])

and not

+                elif url.lower().startswith('url:'):
+                       url=URL(*[part for part in
url[4:].split(',')])

Why the quotes?

On Jan 3, 9:07 pm, blackthorne francisco@gmail.com wrote:

 Because it may not be obvious that the previous message 
 includes a
 patch, here is from another 
 source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

 thank you

 On Jan 4, 2:51 am, Francisco Gama blacktho...@ironik.org 
 wrote:

  this patch allows you to define custom links using the 
  URL() helper in the meta-menu of plugin_wiki, so you should 
  apply it to:
  models/plugin_wiki.py

  the syntax used is Title url:URL_args

  example:
  home url:'homepage','plugin_wiki','index'
  Articles page:articles
  Links url:'homepage','default','links'

  notice that after url: you shall not leave white spaces. 
  This is a must not to touch in the regex currently being 
  used to match that

  Other idea, would be to bring this power to markmin links...

  Leave comments,
  Best regards

  Francisco Gama Tabanez Ribeiro

  E-mail: blacktho...@ironik.org
  Twitter: blackthorne


[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread mdipierro
Are we still talking about menu links? Why should a menu item perform
a post?

On Jan 4, 10:31 am, blackthorne francisco@gmail.com wrote:
 fine with me

 any solution for POST method?

 On Jan 4, 4:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  I have no objection to local URL.  but the author of the menu may not
  be the administrator therefore we cannot eval(...) text in the meta-
  menu. This poses restrictions on what we can put in there. I suggest
  we just allow

  page_name /controller/action/arg1/arg2?a=b

  and if this starts with / this is interpreted as a local URL. No need
  to specify app name.

  On Jan 4, 10:09 am, blackthorne francisco@gmail.com wrote:

   no local urls for secure mode... yes/no?

   On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu wrote:

There cannot be eval in there. The plugin may be in level=1 (secure
mode).

On Jan 4, 8:38 am, blackthorne francisco@gmail.com wrote:

 Broken here:
 In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

 In [22]: [part.strip('\'').strip('\') for part in url[4:].split(',')]
 Out[22]: [args=['x, y'], vars=dict(z='t')]

 Just use:
                 elif url.lower().startswith('url:'):
                         url=eval(URL( + url[4:] + ))

 This was my first solution, it works well with args and vars.
 This case works, tested against:
 Home url:'homepage','plugin_wiki','index'
 Articles page:articles
 Links url:'homepage','default','links'
 Test url:'f',args=['x','y'],vars=dict(z='t')
 Projects url:'f',args=['x','y']

 Generated:http://127.0.0.1:8000/homepage/plugin_wiki/indexhttp://127.0.0.1:8000...

 The only small gotcha is white space absence being required because of
 the regular expression being used to parse the meta-menu lines...

 On Jan 4, 1:13 pm, blackthorne francisco@gmail.com wrote:

  That way, you can use URL() to pass args [] and vars {} under the
  web2py way. Have to test it though...

  On Jan 4, 12:24 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   but why not simply

   url:homepage/plugin_wiki/index

   or

   localurl:homepage/plugin_wiki/index

   and no quotes?

   On Jan 4, 6:00 am, blackthorne francisco@gmail.com wrote:

instead of having common strings ready to be passed as 
arguments, you
would get strings that contain quotes in it. I guess...

Consider my example:
home url:'homepage','plugin_wiki','index'

you will get:
In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

In [10]: [part.strip('\'') for part in url[4:].split(',')]
Out[10]: ['homepage', 'plugin_wiki', 'index']

In [11]: [part for part in url[4:].split(',')]
Out[11]: ['homepage', 'plugin_wiki', 'index']

Best regards

On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu wrote:

 Why

 +                elif url.lower().startswith('url:'):
 +                       url=URL(*[part.strip('\'') for part in
 url[4:].split(',')])

 and not

 +                elif url.lower().startswith('url:'):
 +                       url=URL(*[part for part in
 url[4:].split(',')])

 Why the quotes?

 On Jan 3, 9:07 pm, blackthorne francisco@gmail.com 
 wrote:

  Because it may not be obvious that the previous message 
  includes a
  patch, here is from another 
  source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

  thank you

  On Jan 4, 2:51 am, Francisco Gama blacktho...@ironik.org 
  wrote:

   this patch allows you to define custom links using the 
   URL() helper in the meta-menu of plugin_wiki, so you 
   should apply it to:
   models/plugin_wiki.py

   the syntax used is Title url:URL_args

   example:
   home url:'homepage','plugin_wiki','index'
   Articles page:articles
   Links url:'homepage','default','links'

   notice that after url: you shall not leave white 
   spaces. This is a must not to touch in the regex 
   currently being used to match that

   Other idea, would be to bring this power to markmin 
   links...

   Leave comments,
   Best regards

   Francisco Gama Tabanez Ribeiro

   E-mail: blacktho...@ironik.org
   Twitter: blackthorne




Re: [web2py] Google Summer of Code

2011-01-04 Thread Jason (spot) Brower
Building a testing platform would be spectacular!  We really need something
to test all the features of web2py.
I would also love to see a system that can monitor visits and other things
like apache does.
Best Regards,
Jason

On Tue, Jan 4, 2011 at 3:56 PM, James Hancock jlhanc...@gmail.com wrote:

 I get back to the states in March and I was wondering what kind of
 opportunities there are for a GoSC project with web2py?

 I was thinking specifically in the writing tests area, the admin, and
 documentation ( on the website specifically). I have been doing
 research about it and it looks like these places could use a little
 love. I forward to getting into web2py when I get back and there isn't
 any better way than writing tests for it or documentation.

 Any thoughts?

 Cheers,
 James Hancock


[web2py] why not PHP?

2011-01-04 Thread mdipierro
among other reasons because you can bring down the server just by
typing

   2.2250738585072011e-308

in a web form integer value. (exploit requires 32bits machine).

Source:
http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/


Re: [web2py] why not PHP?

2011-01-04 Thread Jason (spot) Brower
Wow, I like that one. :P

On Tue, Jan 4, 2011 at 6:35 PM, mdipierro mdipie...@cs.depaul.edu wrote:

 among other reasons because you can bring down the server just by
 typing

   2.2250738585072011e-308

 in a web form integer value. (exploit requires 32bits machine).

 Source:

 http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/


[web2py] change to parameter name in latest version?

2011-01-04 Thread apple
Latest upgrade to web2py appears to have changed the name for
parameters in a background process.

Yesterday I was running a background process using
subprocess.Popen(c:/python27/python %s/web2py.py -S scraper -M -N -R
%s \
%(os.getcwd(),
  os.getcwd()+/applications/scraper/modules/
execute.py -A +
  str(session.scraperid))+ +str(processid),
Shell=True)

I referred to the arguments using SYS.ARGS as it says in the manual.
Today my program fails as SYS.ARGS does not exist. Further
investigation shows I can use SYS.ARGV instead.





[web2py] TAKE 2: Web2py + (jython / modjy) + Tomcat 6

2011-01-04 Thread Andrew
Hi All,

I picked this effort up again and wanted to see if anyone else has had
success with a scenario like this. I had tried a while back but Jython
and modjy was still maturing and ran into some platform issues.

First off, here are the components I'm using:

* Windows XP SP3
* Tomcat 6.0.29
* Sun JDK 1.6.0_21
* Jython 2.5.2 rc2

Everything seems to be configured correctly from a modjy standpoint.
When I hit the defined uri localhost:8080/web2py  it automatically
redirects me to localhost:8080/welcome/default/index controller. I
believe this is due to the default route setup for web2py. However
since the controller actually exists in localhost:8080/web2py/welcome
I get a 404 naturally.

When I specifically define the welcome controller @ localhost:8080/
web2py/welcome/default/index I get invalid request. I've looked at
the gluon.main code to see which of the conditions I might be meeting
to trigger the invalid request error and am not able to pin it down.
I'm not sure how to debug this from the servlet container. I've also
tried putting the welcome directory within the WEB-INF structure but
still get the same error.

My tomcat log only gives this riddle:

Jan 4, 2011 10:33:33 AM org.apache.catalina.core.ApplicationContext
log
INFO: debug:Attempting to import application callable
'gluon.main.wsgibase'
Jan 4, 2011 10:33:33 AM org.apache.catalina.core.ApplicationContext
log
INFO: debug:Application is function wsgibase at 0x3
Jan 4, 2011 10:33:33 AM org.apache.catalina.core.ApplicationContext
log
INFO: debug:Processing app return type: type 'list'

Any direction or ideas on what I might be doing wrong is greatly
appreciated. The pursuit for this on jython is due to wanting to use
web2py as a utility framework in a Java only environment. Getting
python installed in this environment is not an option unfortunately.

My Tomcat directory structure is laid out like so:

Tomcat_HOME
   |__webapps
|__web2py
|
|__WEB-INF
| |__web.xml
| |___lib
| |  |__jython.jar
| |___lib-python(contents of Lib from jython
install and gluon module)
|
|__welcome
||__(web2py welcome example app)
|
|__application.py

My web2py web.xml / modjy servlet config looks like this:

?xml version=1.0 encoding=ISO-8859-1?
!DOCTYPE web-app
 PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
http://java.sun.com/dtd/web-app_2_3.dtd;
web-app

  display-namemodjy demo application/display-name
  description
 modjy WSGI demo application
  /description

  servlet
servlet-namemodjy/servlet-name
servlet-classcom.xhaus.modjy.ModjyJServlet/servlet-class

init-param
  param-namepython.home/param-name
  param-valueE:/jython2.5.2/param-value
/init-param

init-param
  param-nameapp_import_name/param-name
  param-valuegluon.main.wsgibase/param-value
/init-param

init-param
  param-namecache_callables/param-name
  param-value1/param-value
/init-param

init-param
  param-namereload_on_mod/param-name
  param-value1/param-value
/init-param

init-param
  param-nameload_site_packages/param-name
  param-value1/param-value
/init-param

init-param
  param-namelog_level/param-name
  param-valuedebug/param-value
/init-param

load-on-startup1/load-on-startup
  /servlet

  servlet-mapping
servlet-namemodjy/servlet-name
url-pattern/*/url-pattern
  /servlet-mapping

/web-app


TIA,

Andrew


Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
Massimo,
Nice! It works... so as long as I register first I'm the teacher :).
I'm just looking at web2py again in the last few weeks. I'm very happy to
help with documentation of this feature. Just point me in the right
direction.

see: Screenshot below:
[image: user login.jpg]

On Tue, Jan 4, 2011 at 10:54 AM, David Bain pigeonfli...@gmail.com wrote:

 Thanks Massimo,
 Checking out  trunk now.


 On Tue, Jan 4, 2011 at 10:49 AM, mdipierro mdipie...@cs.depaul.eduwrote:

 In trunk.

 - Deploy the latest admin
 - edit file applications/admin/models/0.py and set
  MULTI_USER_MODE = True
 - Try access admin and it will require registration/login
 - The first user to register is teacher (can see all apps)
 - All other users are students (can only see/edit/create their own
 apps)

 This does not prevent one user from writing dangerous code. The code,
 whoever creates it, always runs under the same privileged and has
 access to the entire web2py folder.

 At the moment students get access to each other appdmin controllers.

 Please help with testing!

 On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
  I like the modified admin approach, it would be simpler, for teaching
  purposes it would work, it would need to be modified for production
 style
  scenarios as it would not be an acceptable risk.
 
  On Tue, Jan 4, 2011 at 6:50 AM, mdipierro mdipie...@cs.depaul.edu
 wrote:
   This can be done but it would not prevent one use to write code (an
   app) that reads or deletes another user app. As long as this is clear,
   I coud modify admin for this purpose (or create another admin).
 
   On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
I think it'll be convenient for multiple users to work on one web2py
installation, if there's a layer on top of the admin app, providing
the following features:
 
1. The admin app allows user registration.
2. Each user can view/edit only apps that he/she creates.
 
This is strictly at the (admin) app level.  Everything is the same
 as
before at the filesystem level.
 
(This is particularly useful for teaching (I think): one web2py app,
many students).
 
 



user login.jpg

[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread blackthorne
sorry, I was considering on using the same code to the wiki pages in
the markmin syntax so that you could also make this kind of links in
wiki pages.
[[name http://example.com, args=[], vars={}]]

Other thing, you might want to consider...
check your example
page_name /controller/action/arg1/arg2?a=b

instead of b if you have a string such as 'welcome page', it won't
work because of the white space.
page_name /controller/action/arg1/arg2?a='Welcome page'

idea:
changing the meta-menu separator character to '|' or '||'

example:
page_name|/controller/action/arg1/arg2?a='Welcome page'


On Jan 4, 4:33 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 Are we still talking about menu links? Why should a menu item perform
 a post?

 On Jan 4, 10:31 am, blackthorne francisco@gmail.com wrote:



  fine with me

  any solution for POST method?

  On Jan 4, 4:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   I have no objection to local URL.  but the author of the menu may not
   be the administrator therefore we cannot eval(...) text in the meta-
   menu. This poses restrictions on what we can put in there. I suggest
   we just allow

   page_name /controller/action/arg1/arg2?a=b

   and if this starts with / this is interpreted as a local URL. No need
   to specify app name.

   On Jan 4, 10:09 am, blackthorne francisco@gmail.com wrote:

no local urls for secure mode... yes/no?

On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu wrote:

 There cannot be eval in there. The plugin may be in level=1 (secure
 mode).

 On Jan 4, 8:38 am, blackthorne francisco@gmail.com wrote:

  Broken here:
  In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

  In [22]: [part.strip('\'').strip('\') for part in 
  url[4:].split(',')]
  Out[22]: [args=['x, y'], vars=dict(z='t')]

  Just use:
                  elif url.lower().startswith('url:'):
                          url=eval(URL( + url[4:] + ))

  This was my first solution, it works well with args and vars.
  This case works, tested against:
  Home url:'homepage','plugin_wiki','index'
  Articles page:articles
  Links url:'homepage','default','links'
  Test url:'f',args=['x','y'],vars=dict(z='t')
  Projects url:'f',args=['x','y']

  Generated:http://127.0.0.1:8000/homepage/plugin_wiki/indexhttp://127.0.0.1:8000...

  The only small gotcha is white space absence being required because 
  of
  the regular expression being used to parse the meta-menu lines...

  On Jan 4, 1:13 pm, blackthorne francisco@gmail.com wrote:

   That way, you can use URL() to pass args [] and vars {} under the
   web2py way. Have to test it though...

   On Jan 4, 12:24 pm, mdipierro mdipie...@cs.depaul.edu wrote:

but why not simply

url:homepage/plugin_wiki/index

or

localurl:homepage/plugin_wiki/index

and no quotes?

On Jan 4, 6:00 am, blackthorne francisco@gmail.com wrote:

 instead of having common strings ready to be passed as 
 arguments, you
 would get strings that contain quotes in it. I guess...

 Consider my example:
 home url:'homepage','plugin_wiki','index'

 you will get:
 In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

 In [10]: [part.strip('\'') for part in url[4:].split(',')]
 Out[10]: ['homepage', 'plugin_wiki', 'index']

 In [11]: [part for part in url[4:].split(',')]
 Out[11]: ['homepage', 'plugin_wiki', 'index']

 Best regards

 On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu wrote:

  Why

  +                elif url.lower().startswith('url:'):
  +                       url=URL(*[part.strip('\'') for part 
  in
  url[4:].split(',')])

  and not

  +                elif url.lower().startswith('url:'):
  +                       url=URL(*[part for part in
  url[4:].split(',')])

  Why the quotes?

  On Jan 3, 9:07 pm, blackthorne francisco@gmail.com 
  wrote:

   Because it may not be obvious that the previous message 
   includes a
   patch, here is from another 
   source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

   thank you

   On Jan 4, 2:51 am, Francisco Gama 
   blacktho...@ironik.org wrote:

this patch allows you to define custom links using the 
URL() helper in the meta-menu of plugin_wiki, so you 
should apply it to:
models/plugin_wiki.py

the syntax used is Title url:URL_args

example:
home url:'homepage','plugin_wiki','index'
Articles page:articles
Links url:'homepage','default','links'

notice that after url: you shall not leave white 
spaces. This is a must 

Re: [web2py] why not PHP?

2011-01-04 Thread Martín Mulone
Nice bug

2011/1/4 Jason (spot) Brower encomp...@gmail.com

 Wow, I like that one. :P


 On Tue, Jan 4, 2011 at 6:35 PM, mdipierro mdipie...@cs.depaul.edu wrote:

 among other reasons because you can bring down the server just by
 typing

   2.2250738585072011e-308

 in a web form integer value. (exploit requires 32bits machine).

 Source:

 http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/





-- 
My blog: http://martin.tecnodoc.com.ar
My portfolio *spanish*: http://www.tecnodoc.com.ar
Checkout my last proyect instant-press: http://www.instant2press.com
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6


Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread Bruno Rocha
Thanks! this will ne very usefull for me too.

2011/1/4 mdipierro mdipie...@cs.depaul.edu

 In trunk.

 - Deploy the latest admin
 - edit file applications/admin/models/0.py and set
  MULTI_USER_MODE = True


-- 

Bruno Rocha
http://about.me/rochacbruno/bio


Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
Just a note. There was no option to register.
I had to visit localhost:8000/admin/default/user/register


On Tue, Jan 4, 2011 at 11:44 AM, David Bain pigeonfli...@gmail.com wrote:

 Massimo,
 Nice! It works... so as long as I register first I'm the teacher :).
 I'm just looking at web2py again in the last few weeks. I'm very happy to
 help with documentation of this feature. Just point me in the right
 direction.

 see: Screenshot below:
 [image: user login.jpg]

 On Tue, Jan 4, 2011 at 10:54 AM, David Bain pigeonfli...@gmail.comwrote:

 Thanks Massimo,
 Checking out  trunk now.


 On Tue, Jan 4, 2011 at 10:49 AM, mdipierro mdipie...@cs.depaul.eduwrote:

 In trunk.

 - Deploy the latest admin
 - edit file applications/admin/models/0.py and set
  MULTI_USER_MODE = True
 - Try access admin and it will require registration/login
 - The first user to register is teacher (can see all apps)
 - All other users are students (can only see/edit/create their own
 apps)

 This does not prevent one user from writing dangerous code. The code,
 whoever creates it, always runs under the same privileged and has
 access to the entire web2py folder.

 At the moment students get access to each other appdmin controllers.

 Please help with testing!

 On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
  I like the modified admin approach, it would be simpler, for teaching
  purposes it would work, it would need to be modified for production
 style
  scenarios as it would not be an acceptable risk.
 
  On Tue, Jan 4, 2011 at 6:50 AM, mdipierro mdipie...@cs.depaul.edu
 wrote:
   This can be done but it would not prevent one use to write code (an
   app) that reads or deletes another user app. As long as this is
 clear,
   I coud modify admin for this purpose (or create another admin).
 
   On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
I think it'll be convenient for multiple users to work on one
 web2py
installation, if there's a layer on top of the admin app, providing
the following features:
 
1. The admin app allows user registration.
2. Each user can view/edit only apps that he/she creates.
 
This is strictly at the (admin) app level.  Everything is the same
 as
before at the filesystem level.
 
(This is particularly useful for teaching (I think): one web2py
 app,
many students).
 
 






[web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread mdipierro
Oops. I missed a file in the commit. adding it now.

One more caveat. For security, the first user is the teacher and
registration is enabled by default.
For all other users of admin (students) registration requires
verification. That means the teacher must login, user /admin/appadmin
and clear the content of the registration_key field for approved
students.

This is for preventing non-students from getting their hands on the
system.

Massimo

On Jan 4, 10:44 am, David Bain pigeonfli...@gmail.com wrote:
 Massimo,
 Nice! It works... so as long as I register first I'm the teacher :).
 I'm just looking at web2py again in the last few weeks. I'm very happy to
 help with documentation of this feature. Just point me in the right
 direction.

 see: Screenshot below:
 [image: user login.jpg]

 On Tue, Jan 4, 2011 at 10:54 AM, David Bain pigeonfli...@gmail.com wrote:
  Thanks Massimo,
  Checking out  trunk now.

  On Tue, Jan 4, 2011 at 10:49 AM, mdipierro mdipie...@cs.depaul.eduwrote:

  In trunk.

  - Deploy the latest admin
  - edit file applications/admin/models/0.py and set
   MULTI_USER_MODE = True
  - Try access admin and it will require registration/login
  - The first user to register is teacher (can see all apps)
  - All other users are students (can only see/edit/create their own
  apps)

  This does not prevent one user from writing dangerous code. The code,
  whoever creates it, always runs under the same privileged and has
  access to the entire web2py folder.

  At the moment students get access to each other appdmin controllers.

  Please help with testing!

  On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
   I like the modified admin approach, it would be simpler, for teaching
   purposes it would work, it would need to be modified for production
  style
   scenarios as it would not be an acceptable risk.

   On Tue, Jan 4, 2011 at 6:50 AM, mdipierro mdipie...@cs.depaul.edu
  wrote:
This can be done but it would not prevent one use to write code (an
app) that reads or deletes another user app. As long as this is clear,
I coud modify admin for this purpose (or create another admin).

On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
 I think it'll be convenient for multiple users to work on one web2py
 installation, if there's a layer on top of the admin app, providing
 the following features:

 1. The admin app allows user registration.
 2. Each user can view/edit only apps that he/she creates.

 This is strictly at the (admin) app level.  Everything is the same
  as
 before at the filesystem level.

 (This is particularly useful for teaching (I think): one web2py app,
 many students).



  user login.jpg
 41KViewDownload


Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
Okay... I've started hacking the Teaching version of web2py. Hardcoded my
own twitter feed.
I think it would be nice to offer custom feeds on the admin page:
see screenshot below:
[image: site.jpg]

On Tue, Jan 4, 2011 at 11:47 AM, Bruno Rocha rochacbr...@gmail.com wrote:

 Thanks! this will ne very usefull for me too.

 2011/1/4 mdipierro mdipie...@cs.depaul.edu

 In trunk.

 - Deploy the latest admin
 - edit file applications/admin/models/0.py and set
  MULTI_USER_MODE = True


 --

 Bruno Rocha
 http://about.me/rochacbruno/bio

site.jpg

[web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread mdipierro
It would be nice to have some documentation. For now even a simple
blog post that explains purpose, how to, and shows some screen shots
will do.

Massimo

On Jan 4, 10:44 am, David Bain pigeonfli...@gmail.com wrote:
 Massimo,
 Nice! It works... so as long as I register first I'm the teacher :).
 I'm just looking at web2py again in the last few weeks. I'm very happy to
 help with documentation of this feature. Just point me in the right
 direction.

 see: Screenshot below:
 [image: user login.jpg]

 On Tue, Jan 4, 2011 at 10:54 AM, David Bain pigeonfli...@gmail.com wrote:
  Thanks Massimo,
  Checking out  trunk now.

  On Tue, Jan 4, 2011 at 10:49 AM, mdipierro mdipie...@cs.depaul.eduwrote:

  In trunk.

  - Deploy the latest admin
  - edit file applications/admin/models/0.py and set
   MULTI_USER_MODE = True
  - Try access admin and it will require registration/login
  - The first user to register is teacher (can see all apps)
  - All other users are students (can only see/edit/create their own
  apps)

  This does not prevent one user from writing dangerous code. The code,
  whoever creates it, always runs under the same privileged and has
  access to the entire web2py folder.

  At the moment students get access to each other appdmin controllers.

  Please help with testing!

  On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
   I like the modified admin approach, it would be simpler, for teaching
   purposes it would work, it would need to be modified for production
  style
   scenarios as it would not be an acceptable risk.

   On Tue, Jan 4, 2011 at 6:50 AM, mdipierro mdipie...@cs.depaul.edu
  wrote:
This can be done but it would not prevent one use to write code (an
app) that reads or deletes another user app. As long as this is clear,
I coud modify admin for this purpose (or create another admin).

On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
 I think it'll be convenient for multiple users to work on one web2py
 installation, if there's a layer on top of the admin app, providing
 the following features:

 1. The admin app allows user registration.
 2. Each user can view/edit only apps that he/she creates.

 This is strictly at the (admin) app level.  Everything is the same
  as
 before at the filesystem level.

 (This is particularly useful for teaching (I think): one web2py app,
 many students).



  user login.jpg
 41KViewDownload


[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread mdipierro
This is a big can of worms... Do we really need to pass vars?

On Jan 4, 10:45 am, blackthorne francisco@gmail.com wrote:
 sorry, I was considering on using the same code to the wiki pages in
 the markmin syntax so that you could also make this kind of links in
 wiki pages.
 [[namehttp://example.com, args=[], vars={}]]

 Other thing, you might want to consider...
 check your example
 page_name /controller/action/arg1/arg2?a=b

 instead of b if you have a string such as 'welcome page', it won't
 work because of the white space.
 page_name /controller/action/arg1/arg2?a='Welcome page'

 idea:
 changing the meta-menu separator character to '|' or '||'

 example:
 page_name|/controller/action/arg1/arg2?a='Welcome page'

 On Jan 4, 4:33 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  Are we still talking about menu links? Why should a menu item perform
  a post?

  On Jan 4, 10:31 am, blackthorne francisco@gmail.com wrote:

   fine with me

   any solution for POST method?

   On Jan 4, 4:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:

I have no objection to local URL.  but the author of the menu may not
be the administrator therefore we cannot eval(...) text in the meta-
menu. This poses restrictions on what we can put in there. I suggest
we just allow

page_name /controller/action/arg1/arg2?a=b

and if this starts with / this is interpreted as a local URL. No need
to specify app name.

On Jan 4, 10:09 am, blackthorne francisco@gmail.com wrote:

 no local urls for secure mode... yes/no?

 On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  There cannot be eval in there. The plugin may be in level=1 (secure
  mode).

  On Jan 4, 8:38 am, blackthorne francisco@gmail.com wrote:

   Broken here:
   In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

   In [22]: [part.strip('\'').strip('\') for part in 
   url[4:].split(',')]
   Out[22]: [args=['x, y'], vars=dict(z='t')]

   Just use:
                   elif url.lower().startswith('url:'):
                           url=eval(URL( + url[4:] + ))

   This was my first solution, it works well with args and vars.
   This case works, tested against:
   Home url:'homepage','plugin_wiki','index'
   Articles page:articles
   Links url:'homepage','default','links'
   Test url:'f',args=['x','y'],vars=dict(z='t')
   Projects url:'f',args=['x','y']

   Generated:http://127.0.0.1:8000/homepage/plugin_wiki/indexhttp://127.0.0.1:8000...

   The only small gotcha is white space absence being required 
   because of
   the regular expression being used to parse the meta-menu 
   lines...

   On Jan 4, 1:13 pm, blackthorne francisco@gmail.com wrote:

That way, you can use URL() to pass args [] and vars {} under 
the
web2py way. Have to test it though...

On Jan 4, 12:24 pm, mdipierro mdipie...@cs.depaul.edu wrote:

 but why not simply

 url:homepage/plugin_wiki/index

 or

 localurl:homepage/plugin_wiki/index

 and no quotes?

 On Jan 4, 6:00 am, blackthorne francisco@gmail.com 
 wrote:

  instead of having common strings ready to be passed as 
  arguments, you
  would get strings that contain quotes in it. I guess...

  Consider my example:
  home url:'homepage','plugin_wiki','index'

  you will get:
  In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

  In [10]: [part.strip('\'') for part in url[4:].split(',')]
  Out[10]: ['homepage', 'plugin_wiki', 'index']

  In [11]: [part for part in url[4:].split(',')]
  Out[11]: ['homepage', 'plugin_wiki', 'index']

  Best regards

  On Jan 4, 11:49 am, mdipierro mdipie...@cs.depaul.edu 
  wrote:

   Why

   +                elif url.lower().startswith('url:'):
   +                       url=URL(*[part.strip('\'') for 
   part in
   url[4:].split(',')])

   and not

   +                elif url.lower().startswith('url:'):
   +                       url=URL(*[part for part in
   url[4:].split(',')])

   Why the quotes?

   On Jan 3, 9:07 pm, blackthorne francisco@gmail.com 
   wrote:

Because it may not be obvious that the previous message 
includes a
patch, here is from another 
source:http://www.speedyshare.com/files/26051957/download/patch.plugin%20wik...

thank you

On Jan 4, 2:51 am, Francisco Gama 
blacktho...@ironik.org wrote:

 this patch allows you to define custom links using 
 the URL() helper in the meta-menu of plugin_wiki, so 
 you should apply it to:
 models/plugin_wiki.py

 the syntax used is Title url:URL_args

Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
Possible bug:
The teacher account is fine. However I created my first student account and
was unable to log in with the credentials.


Here's my checklist of nice to have features
--

   - Bulk import of users from a csv
   - by default prevent non-teachers from being able to use the application
   wizard/ check for upgrades/ new simple application/deply to google app
   engine (I've X'ed out what should not be in the interface by default)

[image: site-1.jpg]

   - possibly allow teachers to selectively enable features


On Tue, Jan 4, 2011 at 11:57 AM, mdipierro mdipie...@cs.depaul.edu wrote:

 It would be nice to have some documentation. For now even a simple
 blog post that explains purpose, how to, and shows some screen shots
 will do.

 Massimo

 On Jan 4, 10:44 am, David Bain pigeonfli...@gmail.com wrote:
  Massimo,
  Nice! It works... so as long as I register first I'm the teacher :).
  I'm just looking at web2py again in the last few weeks. I'm very happy to
  help with documentation of this feature. Just point me in the right
  direction.
 
  see: Screenshot below:
  [image: user login.jpg]
 
  On Tue, Jan 4, 2011 at 10:54 AM, David Bain pigeonfli...@gmail.com
 wrote:
   Thanks Massimo,
   Checking out  trunk now.
 
   On Tue, Jan 4, 2011 at 10:49 AM, mdipierro mdipie...@cs.depaul.edu
 wrote:
 
   In trunk.
 
   - Deploy the latest admin
   - edit file applications/admin/models/0.py and set
MULTI_USER_MODE = True
   - Try access admin and it will require registration/login
   - The first user to register is teacher (can see all apps)
   - All other users are students (can only see/edit/create their own
   apps)
 
   This does not prevent one user from writing dangerous code. The code,
   whoever creates it, always runs under the same privileged and has
   access to the entire web2py folder.
 
   At the moment students get access to each other appdmin controllers.
 
   Please help with testing!
 
   On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
I like the modified admin approach, it would be simpler, for
 teaching
purposes it would work, it would need to be modified for production
   style
scenarios as it would not be an acceptable risk.
 
On Tue, Jan 4, 2011 at 6:50 AM, mdipierro mdipie...@cs.depaul.edu
   wrote:
 This can be done but it would not prevent one use to write code
 (an
 app) that reads or deletes another user app. As long as this is
 clear,
 I coud modify admin for this purpose (or create another admin).
 
 On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
  I think it'll be convenient for multiple users to work on one
 web2py
  installation, if there's a layer on top of the admin app,
 providing
  the following features:
 
  1. The admin app allows user registration.
  2. Each user can view/edit only apps that he/she creates.
 
  This is strictly at the (admin) app level.  Everything is the
 same
   as
  before at the filesystem level.
 
  (This is particularly useful for teaching (I think): one web2py
 app,
  many students).
 
 
 
   user login.jpg
  41KViewDownload

site-1.jpg

Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
I missed the part about verification.  That's probably the issue.

On Tue, Jan 4, 2011 at 11:56 AM, mdipierro mdipie...@cs.depaul.edu wrote:

 Oops. I missed a file in the commit. adding it now.

 One more caveat. For security, the first user is the teacher and
 registration is enabled by default.
 For all other users of admin (students) registration requires
 verification. That means the teacher must login, user /admin/appadmin
 and clear the content of the registration_key field for approved
 students.

 This is for preventing non-students from getting their hands on the
 system.

 Massimo

 On Jan 4, 10:44 am, David Bain pigeonfli...@gmail.com wrote:
  Massimo,
  Nice! It works... so as long as I register first I'm the teacher :).
  I'm just looking at web2py again in the last few weeks. I'm very happy to
  help with documentation of this feature. Just point me in the right
  direction.
 
  see: Screenshot below:
  [image: user login.jpg]
 
  On Tue, Jan 4, 2011 at 10:54 AM, David Bain pigeonfli...@gmail.com
 wrote:
   Thanks Massimo,
   Checking out  trunk now.
 
   On Tue, Jan 4, 2011 at 10:49 AM, mdipierro mdipie...@cs.depaul.edu
 wrote:
 
   In trunk.
 
   - Deploy the latest admin
   - edit file applications/admin/models/0.py and set
MULTI_USER_MODE = True
   - Try access admin and it will require registration/login
   - The first user to register is teacher (can see all apps)
   - All other users are students (can only see/edit/create their own
   apps)
 
   This does not prevent one user from writing dangerous code. The code,
   whoever creates it, always runs under the same privileged and has
   access to the entire web2py folder.
 
   At the moment students get access to each other appdmin controllers.
 
   Please help with testing!
 
   On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
I like the modified admin approach, it would be simpler, for
 teaching
purposes it would work, it would need to be modified for production
   style
scenarios as it would not be an acceptable risk.
 
On Tue, Jan 4, 2011 at 6:50 AM, mdipierro mdipie...@cs.depaul.edu
   wrote:
 This can be done but it would not prevent one use to write code
 (an
 app) that reads or deletes another user app. As long as this is
 clear,
 I coud modify admin for this purpose (or create another admin).
 
 On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
  I think it'll be convenient for multiple users to work on one
 web2py
  installation, if there's a layer on top of the admin app,
 providing
  the following features:
 
  1. The admin app allows user registration.
  2. Each user can view/edit only apps that he/she creates.
 
  This is strictly at the (admin) app level.  Everything is the
 same
   as
  before at the filesystem level.
 
  (This is particularly useful for teaching (I think): one web2py
 app,
  many students).
 
 
 
   user login.jpg
  41KViewDownload



[web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread VP

 One more caveat. For security, the first user is the teacher and 
 registration is enabled by default.

I haven't tried this, but will soon.  One question: Would the password
of the first user be the same as the password given to web2py?

Thanks.


Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
VP,
No the password is the password that the first user signs up with.

On Tue, Jan 4, 2011 at 12:10 PM, VP vtp2...@gmail.com wrote:


  One more caveat. For security, the first user is the teacher and
 registration is enabled by default.

 I haven't tried this, but will soon.  One question: Would the password
 of the first user be the same as the password given to web2py?

 Thanks.



Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
I'm wondering about the authentication issue. I'm working behind a firewall
which blocks port 587 (used to communicate with gmail), which I'd like to
use as my smtp server.

I think for my use case I have two options:


   1. Host the server in front of the firewall
   2. Host the email sending code in front of the firewall e.g. something
   hosted on google appengine.


 Any other thoughts on this?

On Tue, Jan 4, 2011 at 12:13 PM, David Bain pigeonfli...@gmail.com wrote:

 VP,
 No the password is the password that the first user signs up with.


 On Tue, Jan 4, 2011 at 12:10 PM, VP vtp2...@gmail.com wrote:


  One more caveat. For security, the first user is the teacher and
 registration is enabled by default.

 I haven't tried this, but will soon.  One question: Would the password
 of the first user be the same as the password given to web2py?

 Thanks.





[web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread VP
Okay. Thanks.

On Jan 4, 11:13 am, David Bain pigeonfli...@gmail.com wrote:
 VP,
 No the password is the password that the first user signs up with.

 On Tue, Jan 4, 2011 at 12:10 PM, VP vtp2...@gmail.com wrote:

   One more caveat. For security, the first user is the teacher and
  registration is enabled by default.

  I haven't tried this, but will soon.  One question: Would the password
  of the first user be the same as the password given to web2py?

  Thanks.




[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread blackthorne
Well, I see your view.

In some cases, you can just use %20 instead of white space but not if
that is part of the argument.
example:
http://prernalal.com/banned%20books/ == http://prernalal.com/banned
books/ - valid
http://example.com/?page=banned%20books; != http://example.com/?page=banned
books - not valid

I think this character separation (white space) for meta-menu is way
too common. It's likely that the limitations won't stick with my
examples. An option to define it manually would solve it for all
cases, even if not by convention.

Aanother idea would be using newlines. One for different parts, two
for different options, e.g:
page_name
/controller/action/arg1/arg2?a='Welcome page'

page_name2
page_name /controller/action/arg1/arg2?a='Welcome page2'

This way it's clean, almost fail-proof and leaves you room to add
things with an arbitrary number of arguments/parts.

On the other hand, your latest suggestion doesn't require any change,
which is a plus.

On Jan 4, 4:59 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 This is a big can of worms... Do we really need to pass vars?

 On Jan 4, 10:45 am, blackthorne francisco@gmail.com wrote:



  sorry, I was considering on using the same code to the wiki pages in
  the markmin syntax so that you could also make this kind of links in
  wiki pages.
  [[namehttp://example.com, args=[], vars={}]]

  Other thing, you might want to consider...
  check your example
  page_name /controller/action/arg1/arg2?a=b

  instead of b if you have a string such as 'welcome page', it won't
  work because of the white space.
  page_name /controller/action/arg1/arg2?a='Welcome page'

  idea:
  changing the meta-menu separator character to '|' or '||'

  example:
  page_name|/controller/action/arg1/arg2?a='Welcome page'

  On Jan 4, 4:33 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   Are we still talking about menu links? Why should a menu item perform
   a post?

   On Jan 4, 10:31 am, blackthorne francisco@gmail.com wrote:

fine with me

any solution for POST method?

On Jan 4, 4:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:

 I have no objection to local URL.  but the author of the menu may not
 be the administrator therefore we cannot eval(...) text in the meta-
 menu. This poses restrictions on what we can put in there. I suggest
 we just allow

 page_name /controller/action/arg1/arg2?a=b

 and if this starts with / this is interpreted as a local URL. No need
 to specify app name.

 On Jan 4, 10:09 am, blackthorne francisco@gmail.com wrote:

  no local urls for secure mode... yes/no?

  On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   There cannot be eval in there. The plugin may be in level=1 
   (secure
   mode).

   On Jan 4, 8:38 am, blackthorne francisco@gmail.com wrote:

Broken here:
In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

In [22]: [part.strip('\'').strip('\') for part in 
url[4:].split(',')]
Out[22]: [args=['x, y'], vars=dict(z='t')]

Just use:
                elif url.lower().startswith('url:'):
                        url=eval(URL( + url[4:] + ))

This was my first solution, it works well with args and vars.
This case works, tested against:
Home url:'homepage','plugin_wiki','index'
Articles page:articles
Links url:'homepage','default','links'
Test url:'f',args=['x','y'],vars=dict(z='t')
Projects url:'f',args=['x','y']

Generated:http://127.0.0.1:8000/homepage/plugin_wiki/indexhttp://127.0.0.1:8000...

The only small gotcha is white space absence being required 
because of
the regular expression being used to parse the meta-menu 
lines...

On Jan 4, 1:13 pm, blackthorne francisco@gmail.com wrote:

 That way, you can use URL() to pass args [] and vars {} under 
 the
 web2py way. Have to test it though...

 On Jan 4, 12:24 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  but why not simply

  url:homepage/plugin_wiki/index

  or

  localurl:homepage/plugin_wiki/index

  and no quotes?

  On Jan 4, 6:00 am, blackthorne francisco@gmail.com 
  wrote:

   instead of having common strings ready to be passed as 
   arguments, you
   would get strings that contain quotes in it. I guess...

   Consider my example:
   home url:'homepage','plugin_wiki','index'

   you will get:
   In [9]: url=url:\'homepage\',\'plugin_wiki\',\'index\'

   In [10]: [part.strip('\'') for part in url[4:].split(',')]
   Out[10]: ['homepage', 'plugin_wiki', 'index']

   In [11]: [part for part in url[4:].split(',')]
   Out[11]: ['homepage', 'plugin_wiki', 'index']

   Best regards

   On Jan 4, 11:49 am, mdipierro 

Re: [web2py] why not PHP?

2011-01-04 Thread Branko Vukelić
Look at the comments below the post.

On Tue, Jan 4, 2011 at 5:46 PM, Martín Mulone mulone.mar...@gmail.com wrote:
 Nice bug

 2011/1/4 Jason (spot) Brower encomp...@gmail.com

 Wow, I like that one. :P

 On Tue, Jan 4, 2011 at 6:35 PM, mdipierro mdipie...@cs.depaul.edu wrote:

 among other reasons because you can bring down the server just by
 typing

   2.2250738585072011e-308

 in a web form integer value. (exploit requires 32bits machine).

 Source:

 http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/



 --
 My blog: http://martin.tecnodoc.com.ar
 My portfolio *spanish*: http://www.tecnodoc.com.ar
 Checkout my last proyect instant-press: http://www.instant2press.com
 Expert4Solution Profile:
 http://www.experts4solutions.com/e4s/default/expert/6






-- 
Branko Vukelic

stu...@brankovukelic.com
http://www.brankovukelic.com/


Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
Okay the register button is now present :)
[image: user login-1.jpg]

On Tue, Jan 4, 2011 at 12:17 PM, VP vtp2...@gmail.com wrote:

 Okay. Thanks.

 On Jan 4, 11:13 am, David Bain pigeonfli...@gmail.com wrote:
  VP,
  No the password is the password that the first user signs up with.
 
  On Tue, Jan 4, 2011 at 12:10 PM, VP vtp2...@gmail.com wrote:
 
One more caveat. For security, the first user is the teacher and
   registration is enabled by default.
 
   I haven't tried this, but will soon.  One question: Would the password
   of the first user be the same as the password given to web2py?
 
   Thanks.
 
 

user login-1.jpg

[web2py] Re: suggestion/feature request: multiple view support per each controller function

2011-01-04 Thread VP
Upon thinking about this, I think your solution will address the base
layout, from which each view extends.  Right?

What I want is that there are different views for (for instance) each
function

+ Index:   view/default/index.html, view/default/index.ipad.html, view/
default/index.mobile.html
+ Show_item: view/default/show_item.html, view/default/
show_item.ipad.html, etc.

I think your solution works if the base layout captures entirely
differences in view in different platforms.


On Jan 3, 10:33 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 I already do something like this.
 if 'iPad' in request.env.http_user_agent:
     response.view = 'default/mobile.html'


Re: [web2py] Re: How to get field values before form.accepts(...) [digression]

2011-01-04 Thread Jonathan Lundell
On Jan 4, 2011, at 8:26 AM, mdipierro wrote:
 
 We have that
 
 form.element(...)
 form.elements(...)
 
 both take jQuery syntax.

So the construction below can be expressed that way?

 
 Massimo
 
 On Jan 4, 10:13 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Jan 4, 2011, at 7:19 AM, annet wrote:
 
 
 
 Thanks for your reply. I tried:
 
 form[0][2][2].insert(0,A('already in
 database?',_onmouseover=this.style.cursor='pointer';,_onclick=javascript:details('%s/'+
 $('#kvk_number').val()+'/'+$
 ('#subdossiernumber').val())%URL(r=request,f='retrieve')))
 
 Wouldn't it be cool to have a systematic way of working with forms? A kind 
 of DOM, with jQuery-like syntax for talking about specific components? 
 Constructions like form[0][2][2].insert(0,… are impossibly opaque.




[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread mdipierro
I think we can go this way:

page_name /controller/action/arg1/arg2?a='Welcome page2'

but I would make so that the quotes optional (if provided content will
be replaced by urllib.quote(content).

Would you send me a revised patch?



On Jan 4, 11:21 am, blackthorne francisco@gmail.com wrote:
 Well, I see your view.

 In some cases, you can just use %20 instead of white space but not if
 that is part of the argument.
 example:http://prernalal.com/banned%20books/==http://prernalal.com/banned
 books/ - validhttp://example.com/?page=banned%20books; 
 !=http://example.com/?page=banned
 books - not valid

 I think this character separation (white space) for meta-menu is way
 too common. It's likely that the limitations won't stick with my
 examples. An option to define it manually would solve it for all
 cases, even if not by convention.

 Aanother idea would be using newlines. One for different parts, two
 for different options, e.g:
 page_name
 /controller/action/arg1/arg2?a='Welcome page'

 page_name2
 page_name /controller/action/arg1/arg2?a='Welcome page2'

 This way it's clean, almost fail-proof and leaves you room to add
 things with an arbitrary number of arguments/parts.

 On the other hand, your latest suggestion doesn't require any change,
 which is a plus.

 On Jan 4, 4:59 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  This is a big can of worms... Do we really need to pass vars?

  On Jan 4, 10:45 am, blackthorne francisco@gmail.com wrote:

   sorry, I was considering on using the same code to the wiki pages in
   the markmin syntax so that you could also make this kind of links in
   wiki pages.
   [[namehttp://example.com, args=[], vars={}]]

   Other thing, you might want to consider...
   check your example
   page_name /controller/action/arg1/arg2?a=b

   instead of b if you have a string such as 'welcome page', it won't
   work because of the white space.
   page_name /controller/action/arg1/arg2?a='Welcome page'

   idea:
   changing the meta-menu separator character to '|' or '||'

   example:
   page_name|/controller/action/arg1/arg2?a='Welcome page'

   On Jan 4, 4:33 pm, mdipierro mdipie...@cs.depaul.edu wrote:

Are we still talking about menu links? Why should a menu item perform
a post?

On Jan 4, 10:31 am, blackthorne francisco@gmail.com wrote:

 fine with me

 any solution for POST method?

 On Jan 4, 4:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  I have no objection to local URL.  but the author of the menu may 
  not
  be the administrator therefore we cannot eval(...) text in the meta-
  menu. This poses restrictions on what we can put in there. I suggest
  we just allow

  page_name /controller/action/arg1/arg2?a=b

  and if this starts with / this is interpreted as a local URL. No 
  need
  to specify app name.

  On Jan 4, 10:09 am, blackthorne francisco@gmail.com wrote:

   no local urls for secure mode... yes/no?

   On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu wrote:

There cannot be eval in there. The plugin may be in level=1 
(secure
mode).

On Jan 4, 8:38 am, blackthorne francisco@gmail.com wrote:

 Broken here:
 In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

 In [22]: [part.strip('\'').strip('\') for part in 
 url[4:].split(',')]
 Out[22]: [args=['x, y'], vars=dict(z='t')]

 Just use:
                 elif url.lower().startswith('url:'):
                         url=eval(URL( + url[4:] + ))

 This was my first solution, it works well with args and vars.
 This case works, tested against:
 Home url:'homepage','plugin_wiki','index'
 Articles page:articles
 Links url:'homepage','default','links'
 Test url:'f',args=['x','y'],vars=dict(z='t')
 Projects url:'f',args=['x','y']

 Generated:http://127.0.0.1:8000/homepage/plugin_wiki/indexhttp://127.0.0.1:8000...

 The only small gotcha is white space absence being required 
 because of
 the regular expression being used to parse the meta-menu 
 lines...

 On Jan 4, 1:13 pm, blackthorne francisco@gmail.com 
 wrote:

  That way, you can use URL() to pass args [] and vars {} 
  under the
  web2py way. Have to test it though...

  On Jan 4, 12:24 pm, mdipierro mdipie...@cs.depaul.edu 
  wrote:

   but why not simply

   url:homepage/plugin_wiki/index

   or

   localurl:homepage/plugin_wiki/index

   and no quotes?

   On Jan 4, 6:00 am, blackthorne francisco@gmail.com 
   wrote:

instead of having common strings ready to be passed as 
arguments, you
would get strings that contain quotes in it. I guess...

Consider my example:
home 

[web2py] Re: How to get field values before form.accepts(...)

2011-01-04 Thread mdipierro
How does the generated form look like.

Perhaps ('#kvk_number') should be ('input[name=kvk_number]') and
('#subdossiernumber') should be ('input[name=subdossiernumber]')




On Jan 4, 9:19 am, annet annet.verm...@gmail.com wrote:
 Massimo,

 Thanks for your reply. I tried:

 form[0][2][2].insert(0,A('already in
 database?',_onmouseover=this.style.cursor='pointer';,_onclick=javascript:details('%s/'+
 $('#kvk_number').val()+'/'+$
 ('#subdossiernumber').val())%URL(r=request,f='retrieve')))

 In the view this is rendered as follows:

 a onclick=javascript:details('/mock/crud_company/retrieve/'+$
 ('#kvk_number').val()+'/'+$('#subdossiernumber').val())
 onmouseover=this.style.cursor='pointer'; style=cursor: pointer;
 already in database?/a

 When I click the 'already in database? link it produces the following
 URL:http://127.0.0.1:8000/mock/crud_company/retrieve/undefined/undefined

 I hope I provided you with enough information to help me solve the
 problem.

 Kind regards,

 Annet.


[web2py] Re: How to get field values before form.accepts(...) [digression]

2011-01-04 Thread mdipierro
yes.

instead of

  form[0][2][2].insert(0,...)

use

  form.element('#table_field__row TD.w2p_fc').insert(0,...)

Not sure it is easier in this case.

  table_field__row is the id of the row for table.field
  w2p_fc is the class name of the comment column.

Massimo

On Jan 4, 11:32 am, Jonathan Lundell jlund...@pobox.com wrote:
 On Jan 4, 2011, at 8:26 AM, mdipierro wrote:



  We have that

  form.element(...)
  form.elements(...)

  both take jQuery syntax.

 So the construction below can be expressed that way?



  Massimo

  On Jan 4, 10:13 am, Jonathan Lundell jlund...@pobox.com wrote:
  On Jan 4, 2011, at 7:19 AM, annet wrote:

  Thanks for your reply. I tried:

  form[0][2][2].insert(0,A('already in
  database?',_onmouseover=this.style.cursor='pointer';,_onclick=javascript:details('%s/'+
  $('#kvk_number').val()+'/'+$
  ('#subdossiernumber').val())%URL(r=request,f='retrieve')))

  Wouldn't it be cool to have a systematic way of working with forms? A kind 
  of DOM, with jQuery-like syntax for talking about specific components? 
  Constructions like form[0][2][2].insert(0,… are impossibly opaque.




[web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread mdipierro


On Jan 4, 11:07 am, David Bain pigeonfli...@gmail.com wrote:
 Possible bug:
 The teacher account is fine. However I created my first student account and
 was unable to log in with the credentials.

 Here's my checklist of nice to have features
 --

    - Bulk import of users from a csv

you can do it already via admin/appadmin/

    - by default prevent non-teachers from being able to use the application
    wizard/ check for upgrades/ new simple application/deply to google app
    engine (I've X'ed out what should not be in the interface by default)

check for upgrades should already be disabled. I will look into it.

 [image: site-1.jpg]

    - possibly allow teachers to selectively enable features

We could have more flags in 0.py and corresponding if statements in
controllers.


 On Tue, Jan 4, 2011 at 11:57 AM, mdipierro mdipie...@cs.depaul.edu wrote:
  It would be nice to have some documentation. For now even a simple
  blog post that explains purpose, how to, and shows some screen shots
  will do.

  Massimo

  On Jan 4, 10:44 am, David Bain pigeonfli...@gmail.com wrote:
   Massimo,
   Nice! It works... so as long as I register first I'm the teacher :).
   I'm just looking at web2py again in the last few weeks. I'm very happy to
   help with documentation of this feature. Just point me in the right
   direction.

   see: Screenshot below:
   [image: user login.jpg]

   On Tue, Jan 4, 2011 at 10:54 AM, David Bain pigeonfli...@gmail.com
  wrote:
Thanks Massimo,
Checking out  trunk now.

On Tue, Jan 4, 2011 at 10:49 AM, mdipierro mdipie...@cs.depaul.edu
  wrote:

In trunk.

- Deploy the latest admin
- edit file applications/admin/models/0.py and set
 MULTI_USER_MODE = True
- Try access admin and it will require registration/login
- The first user to register is teacher (can see all apps)
- All other users are students (can only see/edit/create their own
apps)

This does not prevent one user from writing dangerous code. The code,
whoever creates it, always runs under the same privileged and has
access to the entire web2py folder.

At the moment students get access to each other appdmin controllers.

Please help with testing!

On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
 I like the modified admin approach, it would be simpler, for
  teaching
 purposes it would work, it would need to be modified for production
style
 scenarios as it would not be an acceptable risk.

 On Tue, Jan 4, 2011 at 6:50 AM, mdipierro mdipie...@cs.depaul.edu
wrote:
  This can be done but it would not prevent one use to write code
  (an
  app) that reads or deletes another user app. As long as this is
  clear,
  I coud modify admin for this purpose (or create another admin).

  On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
   I think it'll be convenient for multiple users to work on one
  web2py
   installation, if there's a layer on top of the admin app,
  providing
   the following features:

   1. The admin app allows user registration.
   2. Each user can view/edit only apps that he/she creates.

   This is strictly at the (admin) app level.  Everything is the
  same
as
   before at the filesystem level.

   (This is particularly useful for teaching (I think): one web2py
  app,
   many students).

    user login.jpg
   41KViewDownload



  site-1.jpg
 32KViewDownload


Re: [web2py] Re: Memory leak - followup

2011-01-04 Thread David Zejda
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi :)

You may check the issue even with the default simple application created
by web admin. Simply add this to the default controller:

class Blah():
def __init__(self):
pass

def blahstuff():
p = cache.ram('blahblah',Blah,time_expire=30)
return dict(p=BEAUTIFY(p))

def guppy():
from guppy import hpy
h = hpy()
label='h.heap()'
form = FORM(LABEL(Guppy code: ),INPUT(_name=code, _size='35',
_value=label),INPUT(_type=submit, _value=Execute..))
if form.accepts(request.vars, session):
heap = eval(request.vars.code)
label = request.vars.code
else:
heap = h.heap()
fullstack = h.heap().parts
return dict(heap=PRE(heap), fullstack=PRE(BEAUTIFY(fullstack)),
label=label, form=form)

If you visit heapy() first time, the results contains:

Partition of a set of 24 objects. Total size = 80448 bytes.
 Index  Count   % Size   % Cumulative  % Kind (class / dict of class)
 0 24 10080448 100 80448 100 dict of gluon.dal.Field

Once you run blahstuff(), heapy() reports:

Partition of a set of 48 objects. Total size = 160896 bytes.
 Index  Count   % Size   % Cumulative  % Kind (class / dict of class)
 0 48 100   160896 100160896 100 dict of gluon.dal.Field

David

mdipierro wrote:
 can you show us the guppy stats before and after caching? without
 caching any db object?
 can you also email me the entire app code?
 
 On Jan 4, 9:15 am, David Zejda d...@atlas.cz wrote:
 Whenever in controller/model is the class declared, the same result.
 
 Michele Comitini wrote:
 Try to put the Blah class in the global scope of the controller.  Do
 you get same result?

- --
David Zejda, Open-IT cz
web development  services
http://www.o-it.info
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAk0jYp0ACgkQ3oCkkciamVEyngCfeFLsLcFyo3+97O0wc0w/cbPM
oI8AoLY5t0URVVk2+ehOFomsMAjZzlyv
=0hmM
-END PGP SIGNATURE-


Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
@mdpierro,
More flags in 0.py would be good enough (tm) for my use case.

On Tue, Jan 4, 2011 at 1:01 PM, mdipierro mdipie...@cs.depaul.edu wrote:



 On Jan 4, 11:07 am, David Bain pigeonfli...@gmail.com wrote:
  Possible bug:
  The teacher account is fine. However I created my first student account
 and
  was unable to log in with the credentials.
 
  Here's my checklist of nice to have features
  --
 
 - Bulk import of users from a csv

 you can do it already via admin/appadmin/

 - by default prevent non-teachers from being able to use the
 application
 wizard/ check for upgrades/ new simple application/deply to google app
 engine (I've X'ed out what should not be in the interface by default)

 check for upgrades should already be disabled. I will look into it.

  [image: site-1.jpg]
 
 - possibly allow teachers to selectively enable features

 We could have more flags in 0.py and corresponding if statements in
 controllers.

 
  On Tue, Jan 4, 2011 at 11:57 AM, mdipierro mdipie...@cs.depaul.edu
 wrote:
   It would be nice to have some documentation. For now even a simple
   blog post that explains purpose, how to, and shows some screen shots
   will do.
 
   Massimo
 
   On Jan 4, 10:44 am, David Bain pigeonfli...@gmail.com wrote:
Massimo,
Nice! It works... so as long as I register first I'm the teacher :).
I'm just looking at web2py again in the last few weeks. I'm very
 happy to
help with documentation of this feature. Just point me in the right
direction.
 
see: Screenshot below:
[image: user login.jpg]
 
On Tue, Jan 4, 2011 at 10:54 AM, David Bain pigeonfli...@gmail.com
   wrote:
 Thanks Massimo,
 Checking out  trunk now.
 
 On Tue, Jan 4, 2011 at 10:49 AM, mdipierro 
 mdipie...@cs.depaul.edu
   wrote:
 
 In trunk.
 
 - Deploy the latest admin
 - edit file applications/admin/models/0.py and set
  MULTI_USER_MODE = True
 - Try access admin and it will require registration/login
 - The first user to register is teacher (can see all apps)
 - All other users are students (can only see/edit/create their own
 apps)
 
 This does not prevent one user from writing dangerous code. The
 code,
 whoever creates it, always runs under the same privileged and has
 access to the entire web2py folder.
 
 At the moment students get access to each other appdmin
 controllers.
 
 Please help with testing!
 
 On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
  I like the modified admin approach, it would be simpler, for
   teaching
  purposes it would work, it would need to be modified for
 production
 style
  scenarios as it would not be an acceptable risk.
 
  On Tue, Jan 4, 2011 at 6:50 AM, mdipierro 
 mdipie...@cs.depaul.edu
 wrote:
   This can be done but it would not prevent one use to write
 code
   (an
   app) that reads or deletes another user app. As long as this
 is
   clear,
   I coud modify admin for this purpose (or create another
 admin).
 
   On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
I think it'll be convenient for multiple users to work on
 one
   web2py
installation, if there's a layer on top of the admin app,
   providing
the following features:
 
1. The admin app allows user registration.
2. Each user can view/edit only apps that he/she creates.
 
This is strictly at the (admin) app level.  Everything is
 the
   same
 as
before at the filesystem level.
 
(This is particularly useful for teaching (I think): one
 web2py
   app,
many students).
 
 user login.jpg
41KViewDownload
 
 
 
   site-1.jpg
  32KViewDownload



[web2py] Re: How to get field values before form.accepts(...)

2011-01-04 Thread annet
Massimo,

 Perhaps ('#kvk_number') should be ('input[name=kvk_number]') and
 ('#subdossiernumber') should be ('input[name=subdossiernumber]')

Yes, problem solved! Thanks.


 instead of:
 form[0][2][2].insert(0,...)
 use:
 form.element('#table_field__row TD.w2p_fc').insert(0,...)
 Not sure it is easier in this case.

No, in this case form[0] etc. is easier to code.


Kind regards,

Annet


[web2py] Re: 1.79.2 - 1.91.6 migration error (SQL Server BIT field seems to break)

2011-01-04 Thread Roman Bataev
With mssql2:// it gives another error:

Thread-7 2011-01-04 13:34:58,770 ERROR login() Traceback (most recent call 
last):
  File c:\web2py\applications\scandabamc/controllers/default.py, line 129, 
in login
user = _find_user_by_name(request.vars.username)
  File c:\web2py\applications\scandabamc/controllers/default.py, line 164, 
in _find_user_by_name
return tntdb((tntdb.Employees.networkUsername == username)  
(tntdb.Employees.isManager == True)).select()
  File c:\web2py\gluon\dal.py, line 4507, in select
return self.db._adapter.select(self.query,fields,attributes)
  File c:\web2py\gluon\dal.py, line 1003, in select
rows = response(sql)
  File c:\web2py\gluon\dal.py, line 994, in response
self.execute(sql)
  File c:\web2py\gluon\dal.py, line 1851, in execute
return self.log_execute(a,'utf8')
  File c:\web2py\gluon\dal.py, line 1064, in log_execute
return self.cursor.execute(*a,**b)
ProgrammingError: ('The SQL contains 0 parameter markers, but 1 parameters 
were supplied', 'HY000')



Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
When I try to access /admin/appadmin in Multiuser/Teaching mode.
I get an error.

see traceback below:

Traceback (most recent call last):
  File /home/user/web2pytrunkagain/gluon/restricted.py, line 188, in
restricted
exec ccode in environment
  File /home/user/web2pytrunkagain/applications/admin/controllers/appadmin.py
https://localhost:8001/admin/default/edit/admin/controllers/appadmin.py,
line 33, in module
if not gluon.fileutils.check_credentials(request):
  File /home/user/web2pytrunkagain/gluon/fileutils.py, line 300, in
check_credentials
return get_session(request, other_application).authorized
  File /home/user/web2pytrunkagain/gluon/fileutils.py, line 278, in
get_session
raise KeyError
KeyError


On Tue, Jan 4, 2011 at 1:01 PM, mdipierro mdipie...@cs.depaul.edu wrote:



 On Jan 4, 11:07 am, David Bain pigeonfli...@gmail.com wrote:
  Possible bug:
  The teacher account is fine. However I created my first student account
 and
  was unable to log in with the credentials.
 
  Here's my checklist of nice to have features
  --
 
 - Bulk import of users from a csv

 you can do it already via admin/appadmin/

 - by default prevent non-teachers from being able to use the
 application
 wizard/ check for upgrades/ new simple application/deply to google app
 engine (I've X'ed out what should not be in the interface by default)

 check for upgrades should already be disabled. I will look into it.

  [image: site-1.jpg]
 
 - possibly allow teachers to selectively enable features

 We could have more flags in 0.py and corresponding if statements in
 controllers.

 
  On Tue, Jan 4, 2011 at 11:57 AM, mdipierro mdipie...@cs.depaul.edu
 wrote:
   It would be nice to have some documentation. For now even a simple
   blog post that explains purpose, how to, and shows some screen shots
   will do.
 
   Massimo
 
   On Jan 4, 10:44 am, David Bain pigeonfli...@gmail.com wrote:
Massimo,
Nice! It works... so as long as I register first I'm the teacher :).
I'm just looking at web2py again in the last few weeks. I'm very
 happy to
help with documentation of this feature. Just point me in the right
direction.
 
see: Screenshot below:
[image: user login.jpg]
 
On Tue, Jan 4, 2011 at 10:54 AM, David Bain pigeonfli...@gmail.com
   wrote:
 Thanks Massimo,
 Checking out  trunk now.
 
 On Tue, Jan 4, 2011 at 10:49 AM, mdipierro 
 mdipie...@cs.depaul.edu
   wrote:
 
 In trunk.
 
 - Deploy the latest admin
 - edit file applications/admin/models/0.py and set
  MULTI_USER_MODE = True
 - Try access admin and it will require registration/login
 - The first user to register is teacher (can see all apps)
 - All other users are students (can only see/edit/create their own
 apps)
 
 This does not prevent one user from writing dangerous code. The
 code,
 whoever creates it, always runs under the same privileged and has
 access to the entire web2py folder.
 
 At the moment students get access to each other appdmin
 controllers.
 
 Please help with testing!
 
 On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
  I like the modified admin approach, it would be simpler, for
   teaching
  purposes it would work, it would need to be modified for
 production
 style
  scenarios as it would not be an acceptable risk.
 
  On Tue, Jan 4, 2011 at 6:50 AM, mdipierro 
 mdipie...@cs.depaul.edu
 wrote:
   This can be done but it would not prevent one use to write
 code
   (an
   app) that reads or deletes another user app. As long as this
 is
   clear,
   I coud modify admin for this purpose (or create another
 admin).
 
   On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
I think it'll be convenient for multiple users to work on
 one
   web2py
installation, if there's a layer on top of the admin app,
   providing
the following features:
 
1. The admin app allows user registration.
2. Each user can view/edit only apps that he/she creates.
 
This is strictly at the (admin) app level.  Everything is
 the
   same
 as
before at the filesystem level.
 
(This is particularly useful for teaching (I think): one
 web2py
   app,
many students).
 
 user login.jpg
41KViewDownload
 
 
 
   site-1.jpg
  32KViewDownload



[web2py] Re: onlinestatus

2011-01-04 Thread pk
#
## Tabelle Onlineuser
#
db.define_table('online',
SQLField('user_id',db.auth_user),
SQLField('last_visit','integer'))

On 4 Jan., 16:40, Richard Vézina ml.richard.vez...@gmail.com wrote:
 The model are missing for db.online

 Richard







 On Mon, Jan 3, 2011 at 5:13 PM, pk peter.kirch...@youngdesigners.de wrote:
  hi together,

  i have a function for the onlineuser:

  usersall=db(db.online.last_visittime.time()-dt)
  (db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)
  return TABLE(*[TD(user.user_name) for user in usersall])

  but i will to get all the onlineuser which are friends of mine.
  here is my friendsdatabasetable:

  #
  ## Tabelle Freunde
  #
  db.define_table('friends',
                 SQLField('userid',
                          default=auth.user.id if auth.user else 0,
                          writable=False, readable=False),
                 SQLField('hauptperson',
                          default=auth.user.user_name if auth.user else
  0,
                          writable=False, readable=False,
  label='Hauptperson'),
                 SQLField('freund', label='Freund'),
                 SQLField('freundseit', 'datetime',
  default=request.now, label='Freund seit'),
                 SQLField('bestaetigt','boolean', default=False))

  db.friends.userid.requires=IS_IN_DB(db,'auth_user.id')
  db.friends.hauptperson.requires=IS_IN_DB(db,'auth_user.user_name')
  db.friends.freund.requires=IS_IN_DB(db,'auth_user.user_name')

  how can i get this list and how can i do the name clickable???

  thanks for your help

  peter


[web2py] Re: Another web2py powered site

2011-01-04 Thread nicopresto
 is that a modified version of Instant Press?
For our open source scientific programming group (the.hacker.within), I 
combined of the WordPress Clone and the wiki plugin. Replacing  'Read Full 
Story' with 'Wiki support materials', e.g.
http://hackerwithin.org/thw/plugin_wiki/page/welcome
http://hackerwithin.org/thw/blog/view/1

The source code is available at:
http://www.launchpad.net/thw

We're using the site to manage our peer-teaching materials and 
practice/teach collaborative software dev on campus.

We really should remove the web2py favicon from the Welcome ap
Oops, an oversight, I'll swap in ours. Yes, a generic favicon might be good 
idea for the source.

The site is only a few weeks old, with more features on the way. Any 
suggestions would be much appreciated. I'm slowly porting my research and 
teaching materials to web2py--it is a fantastic framework.

-Nico
http://www.nicopresto.com


[web2py] Re: web2py+FastCGI

2011-01-04 Thread walter
What permissions should I install?

On 4 янв, 16:27, mdipierro mdipie...@cs.depaul.edu wrote:
 This may be a permission issue as web2py cannot access the file system
 (either looking the wrong folder or unable to read/write).

 On Jan 4, 7:21 am, walter wdv...@gmail.com wrote:

  I have used thehttp://web2pyslices.com/main/slices/take_slice/76as
  an example. But when I try to call the http://w2p.edu/welcome/default/
  index I get a page with the next text: Internal error
  Ticket issued: unknown.




Re: [web2py] onlinestatus

2011-01-04 Thread Richard Vézina
On Mon, Jan 3, 2011 at 5:13 PM, pk peter.kirch...@youngdesigners.de wrote:

 hi together,

 i have a function for the onlineuser:

 usersall=db(db.online.last_visittime.time()-dt)

(db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)


This line should be :

 db(db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)




return TABLE(*[TD(user.user_name) for user in usersall])

 but i will to get all the onlineuser which are friends of mine.
 here is my friendsdatabasetable:

 #
 ## Tabelle Freunde
 #
 db.define_table('friends',
SQLField('userid',
 default=auth.user.id if auth.user else 0,
 writable=False, readable=False),
SQLField('hauptperson',
 default=auth.user.user_name if auth.user else
 0,
 writable=False, readable=False,
 label='Hauptperson'),
SQLField('freund', label='Freund'),
SQLField('freundseit', 'datetime',
 default=request.now, label='Freund seit'),
SQLField('bestaetigt','boolean', default=False))

 db.friends.userid.requires=IS_IN_DB(db,'auth_user.id')
 db.friends.hauptperson.requires=IS_IN_DB(db,'auth_user.user_name')
 db.friends.freund.requires=IS_IN_DB(db,'auth_user.user_name')

 how can i get this list and how can i do the name clickable???

 thanks for your help

 peter


Re: [web2py] Re: onlinestatus

2011-01-04 Thread Richard Vézina
Ok and how do you fill up this table?

By the way SQLField is deprecated... Use Field() instead.


Richard

On Tue, Jan 4, 2011 at 2:43 PM, pk peter.kirch...@youngdesigners.de wrote:

 #
 ## Tabelle Onlineuser
 #
 db.define_table('online',
SQLField('user_id',db.auth_user),
SQLField('last_visit','integer'))

 On 4 Jan., 16:40, Richard Vézina ml.richard.vez...@gmail.com wrote:
  The model are missing for db.online
 
  Richard
 
 
 
 
 
 
 
  On Mon, Jan 3, 2011 at 5:13 PM, pk peter.kirch...@youngdesigners.de
 wrote:
   hi together,
 
   i have a function for the onlineuser:
 
   usersall=db(db.online.last_visittime.time()-dt)
   (db.online.user_id==db.auth_user.id).select(db.auth_user.ALL)
   return TABLE(*[TD(user.user_name) for user in usersall])
 
   but i will to get all the onlineuser which are friends of mine.
   here is my friendsdatabasetable:
 
  
 #
   ## Tabelle Freunde
  
 #
   db.define_table('friends',
  SQLField('userid',
   default=auth.user.id if auth.user else 0,
   writable=False, readable=False),
  SQLField('hauptperson',
   default=auth.user.user_name if auth.user else
   0,
   writable=False, readable=False,
   label='Hauptperson'),
  SQLField('freund', label='Freund'),
  SQLField('freundseit', 'datetime',
   default=request.now, label='Freund seit'),
  SQLField('bestaetigt','boolean', default=False))
 
   db.friends.userid.requires=IS_IN_DB(db,'auth_user.id')
   db.friends.hauptperson.requires=IS_IN_DB(db,'auth_user.user_name')
   db.friends.freund.requires=IS_IN_DB(db,'auth_user.user_name')
 
   how can i get this list and how can i do the name clickable???
 
   thanks for your help
 
   peter



[web2py] Re: Memory leak - followup

2011-01-04 Thread mdipierro
This is odd. I can reproduce the problem. What is even stranger is
that if I call blahstuff once the count doubles from 24 to 48 but if I
blahstuff more than once (even if with lower cache time) it does not
increase the counter more than 48.

I also tried caching a lambda:repr(Blah()) as opposed to Blah and the
problem does not occur.

Looks like when caching an instance it keep a copy in cache of the
entire environment, which includes db.

I do not understand why that happens since there is not reference from
the cache.py code to the environment nor any reference from the Blah
class.

Let' move this discussion to web2py-developers. If you are not already
there, please join.

Massimo


On Jan 4, 12:10 pm, David Zejda d...@atlas.cz wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hi :)

 You may check the issue even with the default simple application created
 by web admin. Simply add this to the default controller:

 class Blah():
     def __init__(self):
         pass

 def blahstuff():
     p = cache.ram('blahblah',Blah,time_expire=30)
     return dict(p=BEAUTIFY(p))

 def guppy():
     from guppy import hpy
     h = hpy()
     label='h.heap()'
     form = FORM(LABEL(Guppy code: ),INPUT(_name=code, _size='35',
 _value=label),INPUT(_type=submit, _value=Execute..))
     if form.accepts(request.vars, session):
         heap = eval(request.vars.code)
         label = request.vars.code
     else:
         heap = h.heap()
     fullstack = h.heap().parts
     return dict(heap=PRE(heap), fullstack=PRE(BEAUTIFY(fullstack)),
 label=label, form=form)

 If you visit heapy() first time, the results contains:

 Partition of a set of 24 objects. Total size = 80448 bytes.
  Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
      0     24 100    80448 100     80448 100 dict of gluon.dal.Field

 Once you run blahstuff(), heapy() reports:

 Partition of a set of 48 objects. Total size = 160896 bytes.
  Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
      0     48 100   160896 100    160896 100 dict of gluon.dal.Field

 David

 mdipierro wrote:
  can you show us the guppy stats before and after caching? without
  caching any db object?
  can you also email me the entire app code?

  On Jan 4, 9:15 am, David Zejda d...@atlas.cz wrote:
  Whenever in controller/model is the class declared, the same result.

  Michele Comitini wrote:
  Try to put the Blah class in the global scope of the controller.  Do
  you get same result?

 - --
 David Zejda, Open-IT cz
 web development  serviceshttp://www.o-it.info
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.9 (GNU/Linux)
 Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org

 iEYEARECAAYFAk0jYp0ACgkQ3oCkkciamVEyngCfeFLsLcFyo3+97O0wc0w/cbPM
 oI8AoLY5t0URVVk2+ehOFomsMAjZzlyv
 =0hmM
 -END PGP SIGNATURE-


[web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread mdipierro
Can you try comment these two lines in gluon/fileutils.py

if request.application == other_application:
raise KeyError

Does this fix the problem?

Massimo

On Jan 4, 1:10 pm, David Bain pigeonfli...@gmail.com wrote:
 When I try to access /admin/appadmin in Multiuser/Teaching mode.
 I get an error.

 see traceback below:

 Traceback (most recent call last):
   File /home/user/web2pytrunkagain/gluon/restricted.py, line 188, in
 restricted
     exec ccode in environment
   File 
 /home/user/web2pytrunkagain/applications/admin/controllers/appadmin.py
 https://localhost:8001/admin/default/edit/admin/controllers/appadmin.py,
 line 33, in module
     if not gluon.fileutils.check_credentials(request):
   File /home/user/web2pytrunkagain/gluon/fileutils.py, line 300, in
 check_credentials
     return get_session(request, other_application).authorized
   File /home/user/web2pytrunkagain/gluon/fileutils.py, line 278, in
 get_session
     raise KeyError
 KeyError

 On Tue, Jan 4, 2011 at 1:01 PM, mdipierro mdipie...@cs.depaul.edu wrote:

  On Jan 4, 11:07 am, David Bain pigeonfli...@gmail.com wrote:
   Possible bug:
   The teacher account is fine. However I created my first student account
  and
   was unable to log in with the credentials.

   Here's my checklist of nice to have features
   --

      - Bulk import of users from a csv

  you can do it already via admin/appadmin/

      - by default prevent non-teachers from being able to use the
  application
      wizard/ check for upgrades/ new simple application/deply to google app
      engine (I've X'ed out what should not be in the interface by default)

  check for upgrades should already be disabled. I will look into it.

   [image: site-1.jpg]

      - possibly allow teachers to selectively enable features

  We could have more flags in 0.py and corresponding if statements in
  controllers.

   On Tue, Jan 4, 2011 at 11:57 AM, mdipierro mdipie...@cs.depaul.edu
  wrote:
It would be nice to have some documentation. For now even a simple
blog post that explains purpose, how to, and shows some screen shots
will do.

Massimo

On Jan 4, 10:44 am, David Bain pigeonfli...@gmail.com wrote:
 Massimo,
 Nice! It works... so as long as I register first I'm the teacher :).
 I'm just looking at web2py again in the last few weeks. I'm very
  happy to
 help with documentation of this feature. Just point me in the right
 direction.

 see: Screenshot below:
 [image: user login.jpg]

 On Tue, Jan 4, 2011 at 10:54 AM, David Bain pigeonfli...@gmail.com
wrote:
  Thanks Massimo,
  Checking out  trunk now.

  On Tue, Jan 4, 2011 at 10:49 AM, mdipierro 
  mdipie...@cs.depaul.edu
wrote:

  In trunk.

  - Deploy the latest admin
  - edit file applications/admin/models/0.py and set
   MULTI_USER_MODE = True
  - Try access admin and it will require registration/login
  - The first user to register is teacher (can see all apps)
  - All other users are students (can only see/edit/create their own
  apps)

  This does not prevent one user from writing dangerous code. The
  code,
  whoever creates it, always runs under the same privileged and has
  access to the entire web2py folder.

  At the moment students get access to each other appdmin
  controllers.

  Please help with testing!

  On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
   I like the modified admin approach, it would be simpler, for
teaching
   purposes it would work, it would need to be modified for
  production
  style
   scenarios as it would not be an acceptable risk.

   On Tue, Jan 4, 2011 at 6:50 AM, mdipierro 
  mdipie...@cs.depaul.edu
  wrote:
This can be done but it would not prevent one use to write
  code
(an
app) that reads or deletes another user app. As long as this
  is
clear,
I coud modify admin for this purpose (or create another
  admin).

On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
 I think it'll be convenient for multiple users to work on
  one
web2py
 installation, if there's a layer on top of the admin app,
providing
 the following features:

 1. The admin app allows user registration.
 2. Each user can view/edit only apps that he/she creates.

 This is strictly at the (admin) app level.  Everything is
  the
same
  as
 before at the filesystem level.

 (This is particularly useful for teaching (I think): one
  web2py
app,
 many students).

  user login.jpg
 41KViewDownload

    site-1.jpg
   32KViewDownload




Re: [web2py] Re: Memory leak - followup

2011-01-04 Thread Michele Comitini
David,

please open a ticket here also:

https://code.google.com/p/web2py/issues/entry

2011/1/4 mdipierro mdipie...@cs.depaul.edu:
 This is odd. I can reproduce the problem. What is even stranger is
 that if I call blahstuff once the count doubles from 24 to 48 but if I
 blahstuff more than once (even if with lower cache time) it does not
 increase the counter more than 48.

 I also tried caching a lambda:repr(Blah()) as opposed to Blah and the
 problem does not occur.

 Looks like when caching an instance it keep a copy in cache of the
 entire environment, which includes db.

 I do not understand why that happens since there is not reference from
 the cache.py code to the environment nor any reference from the Blah
 class.

 Let' move this discussion to web2py-developers. If you are not already
 there, please join.

 Massimo


 On Jan 4, 12:10 pm, David Zejda d...@atlas.cz wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hi :)

 You may check the issue even with the default simple application created
 by web admin. Simply add this to the default controller:

 class Blah():
     def __init__(self):
         pass

 def blahstuff():
     p = cache.ram('blahblah',Blah,time_expire=30)
     return dict(p=BEAUTIFY(p))

 def guppy():
     from guppy import hpy
     h = hpy()
     label='h.heap()'
     form = FORM(LABEL(Guppy code: ),INPUT(_name=code, _size='35',
 _value=label),INPUT(_type=submit, _value=Execute..))
     if form.accepts(request.vars, session):
         heap = eval(request.vars.code)
         label = request.vars.code
     else:
         heap = h.heap()
     fullstack = h.heap().parts
     return dict(heap=PRE(heap), fullstack=PRE(BEAUTIFY(fullstack)),
 label=label, form=form)

 If you visit heapy() first time, the results contains:

 Partition of a set of 24 objects. Total size = 80448 bytes.
  Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
      0     24 100    80448 100     80448 100 dict of gluon.dal.Field

 Once you run blahstuff(), heapy() reports:

 Partition of a set of 48 objects. Total size = 160896 bytes.
  Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
      0     48 100   160896 100    160896 100 dict of gluon.dal.Field

 David

 mdipierro wrote:
  can you show us the guppy stats before and after caching? without
  caching any db object?
  can you also email me the entire app code?

  On Jan 4, 9:15 am, David Zejda d...@atlas.cz wrote:
  Whenever in controller/model is the class declared, the same result.

  Michele Comitini wrote:
  Try to put the Blah class in the global scope of the controller.  Do
  you get same result?

 - --
 David Zejda, Open-IT cz
 web development  serviceshttp://www.o-it.info
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.9 (GNU/Linux)
 Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org

 iEYEARECAAYFAk0jYp0ACgkQ3oCkkciamVEyngCfeFLsLcFyo3+97O0wc0w/cbPM
 oI8AoLY5t0URVVk2+ehOFomsMAjZzlyv
 =0hmM
 -END PGP SIGNATURE-


Re: [web2py] why not PHP?

2011-01-04 Thread Kuba Kucharski
2011/1/4 Branko Vukelić stu...@brankovukelic.com:
 Look at the comments below the post.

?


[web2py] Excessive memory usage when caching Objects - followup

2011-01-04 Thread mdipierro
I changed the title because it is not technically a leak.

A leak is when memory is allocated but not referenced and therefore
the amount of memory grows with time.

In this case - when cache.ram is used to cache an object - reloading
the url does not cause additional memory loss which means the cached
object is referencing the environment of the previous request.

This is a problem because it is using more memory than required when
caching objects (not when caching strings, or other simpler types) but
the mount of memory used does not grows with time and with number of
http request, it only grows with number of cached objects.

On Jan 4, 2:57 pm, Michele Comitini michele.comit...@gmail.com
wrote:
 David,

 please open a ticket here also:

 https://code.google.com/p/web2py/issues/entry

 2011/1/4 mdipierro mdipie...@cs.depaul.edu:

  This is odd. I can reproduce the problem. What is even stranger is
  that if I call blahstuff once the count doubles from 24 to 48 but if I
  blahstuff more than once (even if with lower cache time) it does not
  increase the counter more than 48.

  I also tried caching a lambda:repr(Blah()) as opposed to Blah and the
  problem does not occur.

  Looks like when caching an instance it keep a copy in cache of the
  entire environment, which includes db.

  I do not understand why that happens since there is not reference from
  the cache.py code to the environment nor any reference from the Blah
  class.

  Let' move this discussion to web2py-developers. If you are not already
  there, please join.

  Massimo

  On Jan 4, 12:10 pm, David Zejda d...@atlas.cz wrote:
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1

  Hi :)

  You may check the issue even with the default simple application created
  by web admin. Simply add this to the default controller:

  class Blah():
      def __init__(self):
          pass

  def blahstuff():
      p = cache.ram('blahblah',Blah,time_expire=30)
      return dict(p=BEAUTIFY(p))

  def guppy():
      from guppy import hpy
      h = hpy()
      label='h.heap()'
      form = FORM(LABEL(Guppy code: ),INPUT(_name=code, _size='35',
  _value=label),INPUT(_type=submit, _value=Execute..))
      if form.accepts(request.vars, session):
          heap = eval(request.vars.code)
          label = request.vars.code
      else:
          heap = h.heap()
      fullstack = h.heap().parts
      return dict(heap=PRE(heap), fullstack=PRE(BEAUTIFY(fullstack)),
  label=label, form=form)

  If you visit heapy() first time, the results contains:

  Partition of a set of 24 objects. Total size = 80448 bytes.
   Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
       0     24 100    80448 100     80448 100 dict of gluon.dal.Field

  Once you run blahstuff(), heapy() reports:

  Partition of a set of 48 objects. Total size = 160896 bytes.
   Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
       0     48 100   160896 100    160896 100 dict of gluon.dal.Field

  David

  mdipierro wrote:
   can you show us the guppy stats before and after caching? without
   caching any db object?
   can you also email me the entire app code?

   On Jan 4, 9:15 am, David Zejda d...@atlas.cz wrote:
   Whenever in controller/model is the class declared, the same result.

   Michele Comitini wrote:
   Try to put the Blah class in the global scope of the controller.  Do
   you get same result?

  - --
  David Zejda, Open-IT cz
  web development  serviceshttp://www.o-it.info
  -BEGIN PGP SIGNATURE-
  Version: GnuPG v1.4.9 (GNU/Linux)
  Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org

  iEYEARECAAYFAk0jYp0ACgkQ3oCkkciamVEyngCfeFLsLcFyo3+97O0wc0w/cbPM
  oI8AoLY5t0URVVk2+ehOFomsMAjZzlyv
  =0hmM
  -END PGP SIGNATURE-




[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread blackthorne
sure, I'm just not sure what you mean with optional quotes.

e.g.:
page_name /controller/action/arg1/arg2?a='Welcome page2'
/Computers /controller/action/arg1/arg2?a=Hello Computer

should become:
page_name - /controller/action/arg1/arg2?a='Welcome page2'
/Computers - /controller/action/arg1/arg2?a='Hello Computer'

like this?

On Jan 4, 5:47 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I think we can go this way:

     page_name /controller/action/arg1/arg2?a='Welcome page2'

 but I would make so that the quotes optional (if provided content will
 be replaced by urllib.quote(content).

 Would you send me a revised patch?

 On Jan 4, 11:21 am, blackthorne francisco@gmail.com wrote:



  Well, I see your view.

  In some cases, you can just use %20 instead of white space but not if
  that is part of the argument.
  example:http://prernalal.com/banned%20books/==http://prernalal.com/banned
  books/ - validhttp://example.com/?page=banned%20books; 
  !=http://example.com/?page=banned
  books - not valid

  I think this character separation (white space) for meta-menu is way
  too common. It's likely that the limitations won't stick with my
  examples. An option to define it manually would solve it for all
  cases, even if not by convention.

  Aanother idea would be using newlines. One for different parts, two
  for different options, e.g:
  page_name
  /controller/action/arg1/arg2?a='Welcome page'

  page_name2
  page_name /controller/action/arg1/arg2?a='Welcome page2'

  This way it's clean, almost fail-proof and leaves you room to add
  things with an arbitrary number of arguments/parts.

  On the other hand, your latest suggestion doesn't require any change,
  which is a plus.

  On Jan 4, 4:59 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   This is a big can of worms... Do we really need to pass vars?

   On Jan 4, 10:45 am, blackthorne francisco@gmail.com wrote:

sorry, I was considering on using the same code to the wiki pages in
the markmin syntax so that you could also make this kind of links in
wiki pages.
[[namehttp://example.com, args=[], vars={}]]

Other thing, you might want to consider...
check your example
page_name /controller/action/arg1/arg2?a=b

instead of b if you have a string such as 'welcome page', it won't
work because of the white space.
page_name /controller/action/arg1/arg2?a='Welcome page'

idea:
changing the meta-menu separator character to '|' or '||'

example:
page_name|/controller/action/arg1/arg2?a='Welcome page'

On Jan 4, 4:33 pm, mdipierro mdipie...@cs.depaul.edu wrote:

 Are we still talking about menu links? Why should a menu item perform
 a post?

 On Jan 4, 10:31 am, blackthorne francisco@gmail.com wrote:

  fine with me

  any solution for POST method?

  On Jan 4, 4:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   I have no objection to local URL.  but the author of the menu may 
   not
   be the administrator therefore we cannot eval(...) text in the 
   meta-
   menu. This poses restrictions on what we can put in there. I 
   suggest
   we just allow

   page_name /controller/action/arg1/arg2?a=b

   and if this starts with / this is interpreted as a local URL. No 
   need
   to specify app name.

   On Jan 4, 10:09 am, blackthorne francisco@gmail.com wrote:

no local urls for secure mode... yes/no?

On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu wrote:

 There cannot be eval in there. The plugin may be in level=1 
 (secure
 mode).

 On Jan 4, 8:38 am, blackthorne francisco@gmail.com 
 wrote:

  Broken here:
  In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

  In [22]: [part.strip('\'').strip('\') for part in 
  url[4:].split(',')]
  Out[22]: [args=['x, y'], vars=dict(z='t')]

  Just use:
                  elif url.lower().startswith('url:'):
                          url=eval(URL( + url[4:] + ))

  This was my first solution, it works well with args and 
  vars.
  This case works, tested against:
  Home url:'homepage','plugin_wiki','index'
  Articles page:articles
  Links url:'homepage','default','links'
  Test url:'f',args=['x','y'],vars=dict(z='t')
  Projects url:'f',args=['x','y']

  Generated:http://127.0.0.1:8000/homepage/plugin_wiki/indexhttp://127.0.0.1:8000...

  The only small gotcha is white space absence being required 
  because of
  the regular expression being used to parse the meta-menu 
  lines...

  On Jan 4, 1:13 pm, blackthorne francisco@gmail.com 
  wrote:

   That way, you can use URL() to pass args [] and vars {} 
   under the
   web2py way. Have to test it though...

   On Jan 4, 12:24 pm, mdipierro 

[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread mdipierro
I mean

page_name /controller/action/arg1/arg2?a='Hello Computer'b=5
page_name /controller/action/arg1/arg2?a=Hello+Computerb=5

Should be equivalent. So the code should:
0) If path starts with /
1) use regex to find '(?Px.*(?!))' and replace with
urllib.quote(math.group('x'))
2) break the URL into controller, action, everything-else
3) rebuild the url using URL(..) (in case routes is being used)

Not too easy but should do it.


On Jan 4, 3:33 pm, blackthorne francisco@gmail.com wrote:
 sure, I'm just not sure what you mean with optional quotes.

 e.g.:
 page_name /controller/action/arg1/arg2?a='Welcome page2'
 /Computers /controller/action/arg1/arg2?a=Hello Computer

 should become:
 page_name - /controller/action/arg1/arg2?a='Welcome page2'
 /Computers - /controller/action/arg1/arg2?a='Hello Computer'

 like this?

 On Jan 4, 5:47 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  I think we can go this way:

      page_name /controller/action/arg1/arg2?a='Welcome page2'

  but I would make so that the quotes optional (if provided content will
  be replaced by urllib.quote(content).

  Would you send me a revised patch?

  On Jan 4, 11:21 am, blackthorne francisco@gmail.com wrote:

   Well, I see your view.

   In some cases, you can just use %20 instead of white space but not if
   that is part of the argument.
   example:http://prernalal.com/banned%20books/==http://prernalal.com/banned
   books/ - validhttp://example.com/?page=banned%20books; 
   !=http://example.com/?page=banned
   books - not valid

   I think this character separation (white space) for meta-menu is way
   too common. It's likely that the limitations won't stick with my
   examples. An option to define it manually would solve it for all
   cases, even if not by convention.

   Aanother idea would be using newlines. One for different parts, two
   for different options, e.g:
   page_name
   /controller/action/arg1/arg2?a='Welcome page'

   page_name2
   page_name /controller/action/arg1/arg2?a='Welcome page2'

   This way it's clean, almost fail-proof and leaves you room to add
   things with an arbitrary number of arguments/parts.

   On the other hand, your latest suggestion doesn't require any change,
   which is a plus.

   On Jan 4, 4:59 pm, mdipierro mdipie...@cs.depaul.edu wrote:

This is a big can of worms... Do we really need to pass vars?

On Jan 4, 10:45 am, blackthorne francisco@gmail.com wrote:

 sorry, I was considering on using the same code to the wiki pages in
 the markmin syntax so that you could also make this kind of links in
 wiki pages.
 [[namehttp://example.com, args=[], vars={}]]

 Other thing, you might want to consider...
 check your example
 page_name /controller/action/arg1/arg2?a=b

 instead of b if you have a string such as 'welcome page', it won't
 work because of the white space.
 page_name /controller/action/arg1/arg2?a='Welcome page'

 idea:
 changing the meta-menu separator character to '|' or '||'

 example:
 page_name|/controller/action/arg1/arg2?a='Welcome page'

 On Jan 4, 4:33 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  Are we still talking about menu links? Why should a menu item 
  perform
  a post?

  On Jan 4, 10:31 am, blackthorne francisco@gmail.com wrote:

   fine with me

   any solution for POST method?

   On Jan 4, 4:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:

I have no objection to local URL.  but the author of the menu 
may not
be the administrator therefore we cannot eval(...) text in the 
meta-
menu. This poses restrictions on what we can put in there. I 
suggest
we just allow

page_name /controller/action/arg1/arg2?a=b

and if this starts with / this is interpreted as a local URL. 
No need
to specify app name.

On Jan 4, 10:09 am, blackthorne francisco@gmail.com wrote:

 no local urls for secure mode... yes/no?

 On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  There cannot be eval in there. The plugin may be in level=1 
  (secure
  mode).

  On Jan 4, 8:38 am, blackthorne francisco@gmail.com 
  wrote:

   Broken here:
   In [21]: url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

   In [22]: [part.strip('\'').strip('\') for part in 
   url[4:].split(',')]
   Out[22]: [args=['x, y'], vars=dict(z='t')]

   Just use:
                   elif url.lower().startswith('url:'):
                           url=eval(URL( + url[4:] + ))

   This was my first solution, it works well with args and 
   vars.
   This case works, tested against:
   Home url:'homepage','plugin_wiki','index'
   Articles page:articles
   Links url:'homepage','default','links'
   Test 

[web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread mdipierro
I think this is now fixed.

On Jan 4, 1:10 pm, David Bain pigeonfli...@gmail.com wrote:
 When I try to access /admin/appadmin in Multiuser/Teaching mode.
 I get an error.

 see traceback below:

 Traceback (most recent call last):
   File /home/user/web2pytrunkagain/gluon/restricted.py, line 188, in
 restricted
     exec ccode in environment
   File 
 /home/user/web2pytrunkagain/applications/admin/controllers/appadmin.py
 https://localhost:8001/admin/default/edit/admin/controllers/appadmin.py,
 line 33, in module
     if not gluon.fileutils.check_credentials(request):
   File /home/user/web2pytrunkagain/gluon/fileutils.py, line 300, in
 check_credentials
     return get_session(request, other_application).authorized
   File /home/user/web2pytrunkagain/gluon/fileutils.py, line 278, in
 get_session
     raise KeyError
 KeyError

 On Tue, Jan 4, 2011 at 1:01 PM, mdipierro mdipie...@cs.depaul.edu wrote:

  On Jan 4, 11:07 am, David Bain pigeonfli...@gmail.com wrote:
   Possible bug:
   The teacher account is fine. However I created my first student account
  and
   was unable to log in with the credentials.

   Here's my checklist of nice to have features
   --

      - Bulk import of users from a csv

  you can do it already via admin/appadmin/

      - by default prevent non-teachers from being able to use the
  application
      wizard/ check for upgrades/ new simple application/deply to google app
      engine (I've X'ed out what should not be in the interface by default)

  check for upgrades should already be disabled. I will look into it.

   [image: site-1.jpg]

      - possibly allow teachers to selectively enable features

  We could have more flags in 0.py and corresponding if statements in
  controllers.

   On Tue, Jan 4, 2011 at 11:57 AM, mdipierro mdipie...@cs.depaul.edu
  wrote:
It would be nice to have some documentation. For now even a simple
blog post that explains purpose, how to, and shows some screen shots
will do.

Massimo

On Jan 4, 10:44 am, David Bain pigeonfli...@gmail.com wrote:
 Massimo,
 Nice! It works... so as long as I register first I'm the teacher :).
 I'm just looking at web2py again in the last few weeks. I'm very
  happy to
 help with documentation of this feature. Just point me in the right
 direction.

 see: Screenshot below:
 [image: user login.jpg]

 On Tue, Jan 4, 2011 at 10:54 AM, David Bain pigeonfli...@gmail.com
wrote:
  Thanks Massimo,
  Checking out  trunk now.

  On Tue, Jan 4, 2011 at 10:49 AM, mdipierro 
  mdipie...@cs.depaul.edu
wrote:

  In trunk.

  - Deploy the latest admin
  - edit file applications/admin/models/0.py and set
   MULTI_USER_MODE = True
  - Try access admin and it will require registration/login
  - The first user to register is teacher (can see all apps)
  - All other users are students (can only see/edit/create their own
  apps)

  This does not prevent one user from writing dangerous code. The
  code,
  whoever creates it, always runs under the same privileged and has
  access to the entire web2py folder.

  At the moment students get access to each other appdmin
  controllers.

  Please help with testing!

  On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
   I like the modified admin approach, it would be simpler, for
teaching
   purposes it would work, it would need to be modified for
  production
  style
   scenarios as it would not be an acceptable risk.

   On Tue, Jan 4, 2011 at 6:50 AM, mdipierro 
  mdipie...@cs.depaul.edu
  wrote:
This can be done but it would not prevent one use to write
  code
(an
app) that reads or deletes another user app. As long as this
  is
clear,
I coud modify admin for this purpose (or create another
  admin).

On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
 I think it'll be convenient for multiple users to work on
  one
web2py
 installation, if there's a layer on top of the admin app,
providing
 the following features:

 1. The admin app allows user registration.
 2. Each user can view/edit only apps that he/she creates.

 This is strictly at the (admin) app level.  Everything is
  the
same
  as
 before at the filesystem level.

 (This is particularly useful for teaching (I think): one
  web2py
app,
 many students).

  user login.jpg
 41KViewDownload

    site-1.jpg
   32KViewDownload




[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread blackthorne


what if?
  menu item path   possible arg
/Computer_option /path/function?a=/Computer /option
/Computer /option /path/function?a='/Computer /option'
/Computer_option   page:computer

I'm complicating, I know but I'm sure that could find more realistic
examples to fit these real possibilities.

On Jan 4, 9:39 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I mean

 page_name /controller/action/arg1/arg2?a='Hello Computer'b=5
 page_name /controller/action/arg1/arg2?a=Hello+Computerb=5

 Should be equivalent. So the code should:
 0) If path starts with /
 1) use regex to find '(?Px.*(?!))' and replace with
 urllib.quote(math.group('x'))
 2) break the URL into controller, action, everything-else
 3) rebuild the url using URL(..) (in case routes is being used)

 Not too easy but should do it.

 On Jan 4, 3:33 pm, blackthorne francisco@gmail.com wrote:



  sure, I'm just not sure what you mean with optional quotes.

  e.g.:
  page_name /controller/action/arg1/arg2?a='Welcome page2'
  /Computers /controller/action/arg1/arg2?a=Hello Computer

  should become:
  page_name - /controller/action/arg1/arg2?a='Welcome page2'
  /Computers - /controller/action/arg1/arg2?a='Hello Computer'

  like this?

  On Jan 4, 5:47 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   I think we can go this way:

       page_name /controller/action/arg1/arg2?a='Welcome page2'

   but I would make so that the quotes optional (if provided content will
   be replaced by urllib.quote(content).

   Would you send me a revised patch?

   On Jan 4, 11:21 am, blackthorne francisco@gmail.com wrote:

Well, I see your view.

In some cases, you can just use %20 instead of white space but not if
that is part of the argument.
example:http://prernalal.com/banned%20books/==http://prernalal.com/banned
books/ - validhttp://example.com/?page=banned%20books; 
!=http://example.com/?page=banned
books - not valid

I think this character separation (white space) for meta-menu is way
too common. It's likely that the limitations won't stick with my
examples. An option to define it manually would solve it for all
cases, even if not by convention.

Aanother idea would be using newlines. One for different parts, two
for different options, e.g:
page_name
/controller/action/arg1/arg2?a='Welcome page'

page_name2
page_name /controller/action/arg1/arg2?a='Welcome page2'

This way it's clean, almost fail-proof and leaves you room to add
things with an arbitrary number of arguments/parts.

On the other hand, your latest suggestion doesn't require any change,
which is a plus.

On Jan 4, 4:59 pm, mdipierro mdipie...@cs.depaul.edu wrote:

 This is a big can of worms... Do we really need to pass vars?

 On Jan 4, 10:45 am, blackthorne francisco@gmail.com wrote:

  sorry, I was considering on using the same code to the wiki pages in
  the markmin syntax so that you could also make this kind of links in
  wiki pages.
  [[namehttp://example.com, args=[], vars={}]]

  Other thing, you might want to consider...
  check your example
  page_name /controller/action/arg1/arg2?a=b

  instead of b if you have a string such as 'welcome page', it won't
  work because of the white space.
  page_name /controller/action/arg1/arg2?a='Welcome page'

  idea:
  changing the meta-menu separator character to '|' or '||'

  example:
  page_name|/controller/action/arg1/arg2?a='Welcome page'

  On Jan 4, 4:33 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   Are we still talking about menu links? Why should a menu item 
   perform
   a post?

   On Jan 4, 10:31 am, blackthorne francisco@gmail.com wrote:

fine with me

any solution for POST method?

On Jan 4, 4:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:

 I have no objection to local URL.  but the author of the menu 
 may not
 be the administrator therefore we cannot eval(...) text in 
 the meta-
 menu. This poses restrictions on what we can put in there. I 
 suggest
 we just allow

 page_name /controller/action/arg1/arg2?a=b

 and if this starts with / this is interpreted as a local URL. 
 No need
 to specify app name.

 On Jan 4, 10:09 am, blackthorne francisco@gmail.com 
 wrote:

  no local urls for secure mode... yes/no?

  On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu 
  wrote:

   There cannot be eval in there. The plugin may be in 
   level=1 (secure
   mode).

   On Jan 4, 8:38 am, blackthorne francisco@gmail.com 
   wrote:

Broken here:
In [21]: 
url=\'f\',args=[\'x\',\'y\'],vars=dict(z=\'t\')

In [22]: [part.strip('\'').strip('\') for part in 

Re: [web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread David Bain
I didn't get much out of commenting out those lines. In Chrome I got an
unresolvable url.

On Tue, Jan 4, 2011 at 4:47 PM, mdipierro mdipie...@cs.depaul.edu wrote:

 I think this is now fixed.

 On Jan 4, 1:10 pm, David Bain pigeonfli...@gmail.com wrote:
  When I try to access /admin/appadmin in Multiuser/Teaching mode.
  I get an error.
 
  see traceback below:
 
  Traceback (most recent call last):
File /home/user/web2pytrunkagain/gluon/restricted.py, line 188, in
  restricted
  exec ccode in environment
File
 /home/user/web2pytrunkagain/applications/admin/controllers/appadmin.py
  https://localhost:8001/admin/default/edit/admin/controllers/appadmin.py
 ,
  line 33, in module
  if not gluon.fileutils.check_credentials(request):
File /home/user/web2pytrunkagain/gluon/fileutils.py, line 300, in
  check_credentials
  return get_session(request, other_application).authorized
File /home/user/web2pytrunkagain/gluon/fileutils.py, line 278, in
  get_session
  raise KeyError
  KeyError
 
  On Tue, Jan 4, 2011 at 1:01 PM, mdipierro mdipie...@cs.depaul.edu
 wrote:
 
   On Jan 4, 11:07 am, David Bain pigeonfli...@gmail.com wrote:
Possible bug:
The teacher account is fine. However I created my first student
 account
   and
was unable to log in with the credentials.
 
Here's my checklist of nice to have features
--
 
   - Bulk import of users from a csv
 
   you can do it already via admin/appadmin/
 
   - by default prevent non-teachers from being able to use the
   application
   wizard/ check for upgrades/ new simple application/deply to google
 app
   engine (I've X'ed out what should not be in the interface by
 default)
 
   check for upgrades should already be disabled. I will look into it.
 
[image: site-1.jpg]
 
   - possibly allow teachers to selectively enable features
 
   We could have more flags in 0.py and corresponding if statements in
   controllers.
 
On Tue, Jan 4, 2011 at 11:57 AM, mdipierro mdipie...@cs.depaul.edu
   wrote:
 It would be nice to have some documentation. For now even a simple
 blog post that explains purpose, how to, and shows some screen
 shots
 will do.
 
 Massimo
 
 On Jan 4, 10:44 am, David Bain pigeonfli...@gmail.com wrote:
  Massimo,
  Nice! It works... so as long as I register first I'm the teacher
 :).
  I'm just looking at web2py again in the last few weeks. I'm very
   happy to
  help with documentation of this feature. Just point me in the
 right
  direction.
 
  see: Screenshot below:
  [image: user login.jpg]
 
  On Tue, Jan 4, 2011 at 10:54 AM, David Bain 
 pigeonfli...@gmail.com
 wrote:
   Thanks Massimo,
   Checking out  trunk now.
 
   On Tue, Jan 4, 2011 at 10:49 AM, mdipierro 
   mdipie...@cs.depaul.edu
 wrote:
 
   In trunk.
 
   - Deploy the latest admin
   - edit file applications/admin/models/0.py and set
MULTI_USER_MODE = True
   - Try access admin and it will require registration/login
   - The first user to register is teacher (can see all apps)
   - All other users are students (can only see/edit/create their
 own
   apps)
 
   This does not prevent one user from writing dangerous code.
 The
   code,
   whoever creates it, always runs under the same privileged and
 has
   access to the entire web2py folder.
 
   At the moment students get access to each other appdmin
   controllers.
 
   Please help with testing!
 
   On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
I like the modified admin approach, it would be simpler, for
 teaching
purposes it would work, it would need to be modified for
   production
   style
scenarios as it would not be an acceptable risk.
 
On Tue, Jan 4, 2011 at 6:50 AM, mdipierro 
   mdipie...@cs.depaul.edu
   wrote:
 This can be done but it would not prevent one use to write
   code
 (an
 app) that reads or deletes another user app. As long as
 this
   is
 clear,
 I coud modify admin for this purpose (or create another
   admin).
 
 On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
  I think it'll be convenient for multiple users to work
 on
   one
 web2py
  installation, if there's a layer on top of the admin
 app,
 providing
  the following features:
 
  1. The admin app allows user registration.
  2. Each user can view/edit only apps that he/she
 creates.
 
  This is strictly at the (admin) app level.  Everything
 is
   the
 same
   as
  before at the filesystem level.
 
  (This is particularly useful for teaching (I think): one
   web2py
 app,
  many students).
 
   user login.jpg
  41KViewDownload
 
 site-1.jpg
32KViewDownload
 
 



[web2py] BETA 2: new routing facility

2011-01-04 Thread Jonathan Lundell
The second beta of the new routing logic is in the trunk. The example file 
isn't quite up to date as I write, but it will be shortly. The text below is 
taken from it.

The underlying logic hasn't changed significantly, but the format of the 
routes.py file is new. You now specify routers, a dict of dicts. Each member of 
routers is a router (this is simpler than it sounds).

There are three kinds of routers.

BASE is the base router that contains global routing configuration such as the 
default application.

DEFAULT is the default app-specific routing configuration that serves as the 
starting point for app-specific routers (and *is* the router for apps that 
aren't explicitly listed.

The other routers are named for individual applications, so you can have a 
configuration like this:

routers = dict(

# base router
BASE = dict(
default_application = 'welcome',
),

# default application router
DEFAULT = dict(),

welcome = dict(),
)

...except that you don't need the 'welcome' router, since it doesn't change the 
default. 

In Python terms, the effective router for the welcome app is a composite of 
the specified routers, something like BASE.update(DEFAULT).update(welcome), so 
you can override values set in the default(s).

In fact, BASE and DEFAULT are themselves updates to built-in base and 
default-app routers (see below for what they contain). 

Give it a try.

One more thing: there's a new function, 
gluon.rewrite.get_effective_router(appname) that will return to you a private 
copy of the effective router (hence the name) of the app whose name you 
specify, or None if routing is not enabled or the appname isn't recognized. You 
can specify BASE or DEFAULT as the appname to get a copy of the base or 
default routers.

#  router is a dictionary of URL routing parameters.
#
#  For each request, the effective router is the default router (below),
#  updated by the base router (if any) from routes.py,
#  updated by the relevant application-specific router (if any)
#  from applications/app/routes.py.
#
#  Optional members of base router:
#
#  default_application: default application name
#  applications: list of all recognized applications, or 'ALL' to use all 
currently installed applications
#  Names in applications are always treated as an application names when 
they appear first in an incoming URL.
#  domains: dict used to map domain names to application names
#
#  These values may be overridden by app-specific routers:
#
#  default_controller: name of default controller
#  default_function: name of default function (all controllers)
#  root_static: list of static files accessed from root
#   (mapped to the selected application's static/ directory)
#
#
#  Optional members of application-specific router:
#
#  These values override those in the base router:
#
#  default_controller
#  default_function
#  root_static
#
#  When these appear in the base router, they apply to the default application 
only:
#
#  domain: the domain that maps to this application (alternative to using 
domains in the base router)
#  languages: list of all supported languages
#  Names in controllers are always treated as language names when they 
appear in an incoming URL after
#  the (optional) application name. 
#  controllers: list of valid controllers in selected app
#   or DEFAULT to use all controllers in the selected app plus 'static'
#   or [] to disable controller-name omission
#  Names in controllers are always treated as controller names when they 
appear in an incoming URL after
#  the (optional) application and language names. 
#  default_language
#   The language code (for example: en, it-it) optionally appears in the 
URL following
#   the application (which may be omitted). For incoming URLs, the code is 
copied to
#   request.language; for outgoing URLs it is taken from request.language.
#   If languages=[], language support is disabled.
#   The default_language, if any, is omitted from the URL.
#  check_args: set to False to suppress arg checking
#   request.raw_args always contains a list of raw args from the URL, not 
unquoted
#   request.args are the same values, unquoted
#   By default (check_args=True), args are required to match args_match.
#  acfe_match: regex for valid application, controller, function, extension 
/a/c/f.e
#  file_match: regex for valid file (used for static file names)
#  args_match: regex for valid args (see also check_args flag)
#
#
#  The built-in default routers supply default values (undefined members are 
None):
#
# base_router = dict(
# default_application = 'init',
# applications = 'ALL',
# root_static = ['favicon.ico', 'robots.txt'],
# domains = dict(),
# acfe_match = r'\w+$',  # legal app/ctlr/fcn/ext
# file_match = r'(\w+[-=./]?)+$',# legal file (path) name
# )
#
# default_router = dict(
# 

[web2py] Re: Setting up a dedicated web2py server that supports multiple users, separate folders

2011-01-04 Thread mdipierro
never mind. should now be fixed in trunk.

On Jan 4, 4:05 pm, David Bain pigeonfli...@gmail.com wrote:
 I didn't get much out of commenting out those lines. In Chrome I got an
 unresolvable url.

 On Tue, Jan 4, 2011 at 4:47 PM, mdipierro mdipie...@cs.depaul.edu wrote:
  I think this is now fixed.

  On Jan 4, 1:10 pm, David Bain pigeonfli...@gmail.com wrote:
   When I try to access /admin/appadmin in Multiuser/Teaching mode.
   I get an error.

   see traceback below:

   Traceback (most recent call last):
     File /home/user/web2pytrunkagain/gluon/restricted.py, line 188, in
   restricted
       exec ccode in environment
     File
  /home/user/web2pytrunkagain/applications/admin/controllers/appadmin.py
   https://localhost:8001/admin/default/edit/admin/controllers/appadmin.py
  ,
   line 33, in module
       if not gluon.fileutils.check_credentials(request):
     File /home/user/web2pytrunkagain/gluon/fileutils.py, line 300, in
   check_credentials
       return get_session(request, other_application).authorized
     File /home/user/web2pytrunkagain/gluon/fileutils.py, line 278, in
   get_session
       raise KeyError
   KeyError

   On Tue, Jan 4, 2011 at 1:01 PM, mdipierro mdipie...@cs.depaul.edu
  wrote:

On Jan 4, 11:07 am, David Bain pigeonfli...@gmail.com wrote:
 Possible bug:
 The teacher account is fine. However I created my first student
  account
and
 was unable to log in with the credentials.

 Here's my checklist of nice to have features
 --

    - Bulk import of users from a csv

you can do it already via admin/appadmin/

    - by default prevent non-teachers from being able to use the
application
    wizard/ check for upgrades/ new simple application/deply to google
  app
    engine (I've X'ed out what should not be in the interface by
  default)

check for upgrades should already be disabled. I will look into it.

 [image: site-1.jpg]

    - possibly allow teachers to selectively enable features

We could have more flags in 0.py and corresponding if statements in
controllers.

 On Tue, Jan 4, 2011 at 11:57 AM, mdipierro mdipie...@cs.depaul.edu
wrote:
  It would be nice to have some documentation. For now even a simple
  blog post that explains purpose, how to, and shows some screen
  shots
  will do.

  Massimo

  On Jan 4, 10:44 am, David Bain pigeonfli...@gmail.com wrote:
   Massimo,
   Nice! It works... so as long as I register first I'm the teacher
  :).
   I'm just looking at web2py again in the last few weeks. I'm very
happy to
   help with documentation of this feature. Just point me in the
  right
   direction.

   see: Screenshot below:
   [image: user login.jpg]

   On Tue, Jan 4, 2011 at 10:54 AM, David Bain 
  pigeonfli...@gmail.com
  wrote:
Thanks Massimo,
Checking out  trunk now.

On Tue, Jan 4, 2011 at 10:49 AM, mdipierro 
mdipie...@cs.depaul.edu
  wrote:

In trunk.

- Deploy the latest admin
- edit file applications/admin/models/0.py and set
 MULTI_USER_MODE = True
- Try access admin and it will require registration/login
- The first user to register is teacher (can see all apps)
- All other users are students (can only see/edit/create their
  own
apps)

This does not prevent one user from writing dangerous code.
  The
code,
whoever creates it, always runs under the same privileged and
  has
access to the entire web2py folder.

At the moment students get access to each other appdmin
controllers.

Please help with testing!

On Jan 4, 8:28 am, David Bain pigeonfli...@gmail.com wrote:
 I like the modified admin approach, it would be simpler, for
  teaching
 purposes it would work, it would need to be modified for
production
style
 scenarios as it would not be an acceptable risk.

 On Tue, Jan 4, 2011 at 6:50 AM, mdipierro 
mdipie...@cs.depaul.edu
wrote:
  This can be done but it would not prevent one use to write
code
  (an
  app) that reads or deletes another user app. As long as
  this
is
  clear,
  I coud modify admin for this purpose (or create another
admin).

  On Jan 3, 10:13 pm, VP vtp2...@gmail.com wrote:
   I think it'll be convenient for multiple users to work
  on
one
  web2py
   installation, if there's a layer on top of the admin
  app,
  providing
   the following features:

   1. The admin app allows user registration.
   2. Each user can view/edit only apps that he/she
  creates.

   This is strictly at the (admin) app level.  Everything
  is
the
  same
as
   before at the filesystem level.

   (This is 

[web2py] Re: patch for URL() in meta-menu (plugin_wiki)

2011-01-04 Thread mdipierro
I do not understand the notation you propose. Are you suggesting a= to
specify args? Why the / on the right of =?

On Jan 4, 3:55 pm, blackthorne francisco@gmail.com wrote:
 what if?
   menu item             path               possible arg
 /Computer_option     /path/function?a=/Computer /option
 /Computer /option     /path/function?a='/Computer /option'
 /Computer_option       page:computer

 I'm complicating, I know but I'm sure that could find more realistic
 examples to fit these real possibilities.

 On Jan 4, 9:39 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  I mean

  page_name /controller/action/arg1/arg2?a='Hello Computer'b=5
  page_name /controller/action/arg1/arg2?a=Hello+Computerb=5

  Should be equivalent. So the code should:
  0) If path starts with /
  1) use regex to find '(?Px.*(?!))' and replace with
  urllib.quote(math.group('x'))
  2) break the URL into controller, action, everything-else
  3) rebuild the url using URL(..) (in case routes is being used)

  Not too easy but should do it.

  On Jan 4, 3:33 pm, blackthorne francisco@gmail.com wrote:

   sure, I'm just not sure what you mean with optional quotes.

   e.g.:
   page_name /controller/action/arg1/arg2?a='Welcome page2'
   /Computers /controller/action/arg1/arg2?a=Hello Computer

   should become:
   page_name - /controller/action/arg1/arg2?a='Welcome page2'
   /Computers - /controller/action/arg1/arg2?a='Hello Computer'

   like this?

   On Jan 4, 5:47 pm, mdipierro mdipie...@cs.depaul.edu wrote:

I think we can go this way:

    page_name /controller/action/arg1/arg2?a='Welcome page2'

but I would make so that the quotes optional (if provided content will
be replaced by urllib.quote(content).

Would you send me a revised patch?

On Jan 4, 11:21 am, blackthorne francisco@gmail.com wrote:

 Well, I see your view.

 In some cases, you can just use %20 instead of white space but not if
 that is part of the argument.
 example:http://prernalal.com/banned%20books/==http://prernalal.com/banned
 books/ - validhttp://example.com/?page=banned%20books; 
 !=http://example.com/?page=banned
 books - not valid

 I think this character separation (white space) for meta-menu is way
 too common. It's likely that the limitations won't stick with my
 examples. An option to define it manually would solve it for all
 cases, even if not by convention.

 Aanother idea would be using newlines. One for different parts, two
 for different options, e.g:
 page_name
 /controller/action/arg1/arg2?a='Welcome page'

 page_name2
 page_name /controller/action/arg1/arg2?a='Welcome page2'

 This way it's clean, almost fail-proof and leaves you room to add
 things with an arbitrary number of arguments/parts.

 On the other hand, your latest suggestion doesn't require any change,
 which is a plus.

 On Jan 4, 4:59 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  This is a big can of worms... Do we really need to pass vars?

  On Jan 4, 10:45 am, blackthorne francisco@gmail.com wrote:

   sorry, I was considering on using the same code to the wiki pages 
   in
   the markmin syntax so that you could also make this kind of links 
   in
   wiki pages.
   [[namehttp://example.com, args=[], vars={}]]

   Other thing, you might want to consider...
   check your example
   page_name /controller/action/arg1/arg2?a=b

   instead of b if you have a string such as 'welcome page', it won't
   work because of the white space.
   page_name /controller/action/arg1/arg2?a='Welcome page'

   idea:
   changing the meta-menu separator character to '|' or '||'

   example:
   page_name|/controller/action/arg1/arg2?a='Welcome page'

   On Jan 4, 4:33 pm, mdipierro mdipie...@cs.depaul.edu wrote:

Are we still talking about menu links? Why should a menu item 
perform
a post?

On Jan 4, 10:31 am, blackthorne francisco@gmail.com wrote:

 fine with me

 any solution for POST method?

 On Jan 4, 4:25 pm, mdipierro mdipie...@cs.depaul.edu wrote:

  I have no objection to local URL.  but the author of the 
  menu may not
  be the administrator therefore we cannot eval(...) text in 
  the meta-
  menu. This poses restrictions on what we can put in there. 
  I suggest
  we just allow

  page_name /controller/action/arg1/arg2?a=b

  and if this starts with / this is interpreted as a local 
  URL. No need
  to specify app name.

  On Jan 4, 10:09 am, blackthorne francisco@gmail.com 
  wrote:

   no local urls for secure mode... yes/no?

   On Jan 4, 3:51 pm, mdipierro mdipie...@cs.depaul.edu 
   wrote:

There cannot be eval in there. The plugin may be in 
level=1 (secure
 

  1   2   >