[web2py] newbie question - recursively finding children

2012-08-31 Thread web-dev-m
Hey everyone!

Wow Web2py 2.0 looks so cool! I can't wait to try all the new features.  
This has made it so easy for me (a non-programmer) to make viable web 
applications!

My question is as follows:  
For one of my views, each page in my application has a variable number of 
child pages, each of which can have a variable number of child pages, 
and so on.  I want each child page to have its own div like so:

div  the big container div
div  variable number of divs here
div/div  variable number of child div's here 
each with their own text
/div
div

How do I write the controllers, so that it recurses as deep as the deepest 
node and generates those divs??

My design is as follows:

Two tables:
table1
-id (auto generated)
-field for text

table2
-id(autogenerated)
-parent_id(created from form)
-childid(created from form)

I know that I have to write a function that returns a div for each, but I 
just wasnt sure how to do it.

Please help!

Thanks!

-- 





[web2py] solicitation for help with public health project for lip reading

2012-07-15 Thread web-dev-m
I am working on many projects, and I figured I would ask for help on here 
to see if anyone wants to help with this.

We are currently working on a project to help hearing impaired people learn 
to read lips better.  When hearing impaired people learn to speak, they 
must rely on lip reading more than the average person in order to improve 
their vocabulary.  As a result, many hearing impaired people have 
vocabulary and reading abilities many grade levels below the average 
person.  We are working on a web2py solution to this problem.  The basic 
setup of the site is as follows:

Users will come to the site and be able to navigate a categorical list of 
uploaded words. This program will display videos of people saying words, 
along with their definition, and use in a sentence. Ideally, users will be 
able to read the words into their computer microphone and get feedback on 
computer recognition of their pronunciation.

Users can also add entries wikipedia style. On the back end, a select group 
of users is defined which can allow user entries to be displayed to the 
public.  These users can also edit the uploaded videos/their 
definitions/and sentences.

If you have any interest in helping make this project a success, please let 
me know.  If you want to take over development of this project, we are also 
willing to pay up to $1500 for a nice looking, complete solution.


[web2py] unable to create application (permissions?)

2012-04-17 Thread web-dev-m
Hey everyone,

I recently upgraded web2py. Afterwards, I am unable to create 
applications.  I chown'd www-data:www-data the web2py directory, so 
everything is correctly permitted.  I also chmod 755 everything.

I had a NEWINSTALL file in there, and my deposit folder is there as well.  
My current applications run, but I can't add another.  I restarted apache 
multiple times.

I am running on debian linux/apache.

I looked through all the posts and google'd it, tried everything there.  
Any suggestions?


[web2py] Re: Broken application after upgrade.

2012-03-27 Thread web-dev-m
No, After much trying to no avail these are the symptoms:

All Controllers, Views, Tables show up in AppAdmin.
No ability to administrate the DB from AppAdmin.
No ability to connect to any application while the affected
application is installed.

I think somehow my database might have been corrupted.  I was doing
some stupid testing and one of my .table files was corrupted so I
deleted it.  They only store database structure right?...

On Mar 26, 10:28 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 If this for a specific application? A specific action?







 On Monday, 26 March 2012 21:00:33 UTC-5, web-dev-m wrote:

  I am having a strange problem.  I just upgraded from 1.99.2 to 1.99.7
  (manually by running update-web2py.sh from /scripts as the link was
  not working in the application).

  I can see my application and all the files are there, but when I try
  to get into any of the files it doesn't load.  It just hangs at
  connecting no matter what controller I try to access.

  I then packed it, and reinstalled via Web2py admin interface.  Still
  no luck.

  Just before I started having this problem, I was having another wierd
  problem.  I was getting an operational error:no such table after just
  creating a simple table like I have done many many times.

  Any suggestions?


[web2py] Re: Broken application after upgrade.

2012-03-27 Thread web-dev-m
Just continues trying to connect to any application.  The application is 
still under development.  After your suggestion, I dumped my db and deleted 
everything from the databases folder. 

It's working now...not sure what exactly happened.

On Tuesday, March 27, 2012 4:54:51 PM UTC-5, pbreit wrote:

 It's weird that one app would affect other apps since usually they are 
 pretty insulated from each other.

 Deleting .table files can be a problem. Was the app under development and 
 you wouldn't care if you erased the DB? If so (and it's SQLite), you can 
 delete all the files in the database directory and start with a fresh new 
 DB.

 When you say that it's not working, how exactly does it behave? Do you get 
 any error messages? Have you touched the routes.py file?

 Another thing to consider is downloading a fresh version of Web2py and 
 then copying the applications over one-by-one.



[web2py] Re: _title tag for looped OPTION attribute

2012-03-26 Thread web-dev-m
This is embarassing.  Thank you.  I swear, I tried and tried.

On Mar 26, 10:25 am, villas villa...@gmail.com wrote:
 Do this:

 files=db(myquery).select()
 files_as_list=[]
 for x in files:
     files_as_list.append(OPTION(x.resource_title[0:50], _value=x.id,
 _title=x.resource_title, ))







 On Sunday, 25 March 2012 21:25:33 UTC+1, web-dev-m wrote:

  I may not be following some sort of convention, but I'm trying to
  build a selector form element with a for loop from a query.  It
  renders when i do it manually:

  select
  option title=test test test test test
  /select

  Howerver,

  when I do:
      files=db(myquery).select()
      files_as_list=[]
      for x in files:
          files_as_list+=(OPTION(x.resource_title[0:50], value=x.id,
  _title=x.resource_title, ))

  the resulting html doesnt have the title attribute.  I am running
  1.99.2.

  Any suggestions?


[web2py] Broken application after upgrade.

2012-03-26 Thread web-dev-m
I am having a strange problem.  I just upgraded from 1.99.2 to 1.99.7
(manually by running update-web2py.sh from /scripts as the link was
not working in the application).

I can see my application and all the files are there, but when I try
to get into any of the files it doesn't load.  It just hangs at
connecting no matter what controller I try to access.

I then packed it, and reinstalled via Web2py admin interface.  Still
no luck.

Just before I started having this problem, I was having another wierd
problem.  I was getting an operational error:no such table after just
creating a simple table like I have done many many times.

Any suggestions?


[web2py] _title tag for looped OPTION attribute

2012-03-25 Thread web-dev-m
I may not be following some sort of convention, but I'm trying to
build a selector form element with a for loop from a query.  It
renders when i do it manually:

select
option title=test test test test test
/select

Howerver,

when I do:
files=db(myquery).select()
files_as_list=[]
for x in files:
files_as_list+=(OPTION(x.resource_title[0:50], value=x.id,
_title=x.resource_title, ))

the resulting html doesnt have the title attribute.  I am running
1.99.2.

Any suggestions?



[web2py] global search form

2012-03-08 Thread web-dev-m
Hey everyone,

Thank you so much for your help on my previous issues.

I am trying to create a global search form.  I followed Massimo's
example on the social networking example to get a great form working.
I then embedded it in a model and posted the view into my common
layout.   I followed the slice for the autocomplete widget as well.

However, everytime I submit a DIFFERENT form on the same page, it
posts an error.

I assume that somehow I need to get a form ID as SQLFORM uses. I tried
to create a sqlform.factory field, but I don't know how to set the
attributes _onkeyup and autocomplete in the form.

1.) If I make it a sqlform.factory form, will that fix the submission
problem?
2.) If not, any suggestions on how to do this correctly?

Here is my code in the model.

searchform=FORM(
INPUT(_type=text, _id=person, _name=person,
_onkeyup=getData(this.value);, autocomplete=off),
INPUT(_type=submit, _value=Search))
searchform['_action']=URL('people','search')
if searchform.accepts(request.vars):
tokens=searchform.vars.person.split()
query = reduce(lambda a,b:ab,
[db.auth_user.first_name.contains(k)|
db.auth_user.last_name.contains(k) for k in tokens])
res_people=db(query).select()
else:
res_people=[]


[web2py] Re: crontab sytax

2012-02-21 Thread web-dev-m
The chapter works, the link to the syntax does not.

http://web2py.com/books/default/reference/29/cron


On Feb 21, 4:50 am, Wikus van de Merwe dupakrop...@googlemail.com
wrote:
 I say the book works just fine:http://web2py.com/book/default/chapter/04#Cron

 The syntax you want to use is: @reboot * * * * root
 *applications/test/controllers/private.py
 Set that in your app/cron/crontab and make sure your controller does
 db.commit() at the end.

 Also you need SOFTCRON = True in the wsgihandler (if you run it as WSGI
 script).


[web2py] Re: crontab sytax

2012-02-20 Thread web-dev-m
I apologize, this should have been in my original post.

For more specifics, my crontab file has only one line in it:

@reboot root python web2py.py -S test -M -N -R applications/test/
controllers/private.py

I have tried to restart the server multiple times, to no avail with
getting this process working.

the script in private.py works when i run it as root from my command
line on my server, so I don't think the problem is with the script
itself.

Any help is greatly, greatly appreciated.

Thank you in advance!


[web2py] crontab sytax

2012-02-20 Thread web-dev-m
Hey everyone,

I'm trying to figure out how to run a background process and write a
very simple script to test it.  It's not working, and I can't seem to
find the right syntax.  The link in the web2py book is broken.  Can
anyone break it down for me or is there an updated link?

Thanks!


[web2py] Re: loop inside helper

2012-02-16 Thread web-dev-m
You got it!  Thanks!!!

On Feb 16, 1:10 am, Anthony abasta...@gmail.com wrote:
  I am trying to add a jquery effect, to each row based on its id, but i
  am having trouble formatting the _onclick=jQuery('id').toggle()

 _onclick=jQuery('%s').toggle() % row.id

 Anthony


[web2py] loop inside helper

2012-02-15 Thread web-dev-m
I am trying to construct a complex form in a web2py controller that
loops over a query and inserts an INPUT() element in a TD() element.

Is there a syntax for looping within a helper or should I do this some
other way?

Thanks!


[web2py] Re: loop inside helper

2012-02-15 Thread web-dev-m
That is seeming to work, except for one thing.

I am trying to add a jquery effect, to each row based on its id, but i
am having trouble formatting the _onclick=jQuery('id').toggle() ...I
cant seem to find a way to get the dynamic id in there.  I guess I
will have to write a jquery function to parse for the id.  Probably
neater too!

Thanks for the help!

On Feb 15, 11:49 pm, Anthony abasta...@gmail.com wrote:
 A list comprehension might be easier. Note, if you put non-TD elements in a
 TR, they will automatically be put inside separate TD's within the TR. If
 you provide some details regarding your query and the result you're trying
 to achieve, we may be able to provide more specific advice.

 Anthony







 On Thursday, February 16, 2012 12:35:34 AM UTC-5, web-dev-m wrote:

  I am trying to construct a complex form in a web2py controller that
  loops over a query and inserts an INPUT() element in a TD() element.

  Is there a syntax for looping within a helper or should I do this some
  other way?

  Thanks!


[web2py] Re: passing navigational links in the header and ajax woes

2012-01-23 Thread web-dev-m
Massimo,

Thank you very much for your reply.  I have made the changes to my
code, but it still didn't solve my problem with the AJAX call not
working.  Any suggestions?

On Jan 21, 11:40 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 In your code you have many calls to this:

    db(db.mydb.id==request.args(0)).select().first()

 which could be simplified into the equivalent expression

    db.mydb(request.args(0))

 You also have this:

     records=db(db.mydb.id==request.args(0)).select()
     ...
     counter=len(records)

 but id is unique so counter is always only 1 or 0.

 You also have:

         check=db(db.mydb.id==request.args(0)).select().first()
         if check !=None:
             
         else:
             row = db(db.mydb.id==request.args(0)).select().first()

 so row is exactly like check and therefore always None.

 Basically you code is equivalent to this:

 def my_func():
     if request.args:
         row = db.mydb(request.args(0))
         counter = 1 if row else 0
         if not row: # should be if row?
             my_id=row.id # always fails!
             (filename, stream)
 = db.mydb.myfield.retrieve(row.resourcefield)
             myfunc(id,filename,stream)
     else:
         redirect(URL('mycontroller','this_function'))
     records = [row] if row else []
     return(counter=counter, records=recods, row=row)

 On Jan 21, 5:54 am, web-dev-m mgrave...@gmail.com wrote:







  Dear Massimo,

  Thank you in advance for your time just looking.  If I can write a
  functional web application, you must be brilliant to have created this
  software.

  I am essentially trying to write a google docs clone with the ability
  to add notes.

  My users upload documents which a python function uses, modifies, and
  then stores the text in the database.  The view displays the text from
  the page in a set of divs.  I then use AJAX to create a note on the
  side via a form.

  The text from the document and the document title/file are in
  different tables.  Also, there is not guaranteed to be file text yet,
  as not every user that uploads a file will need to see the text, so I
  upload the file and get the text in two separate functions.

  My workflow is:

  1.) check to see if file exists in database
  2.) IF it doesnt, make it, and store the text in a table, then get the
  text fields.
  3.) IF it does, get the text fields from one table and the filename
  from another
  4.) Display file text in the view

  I then use AJAX to add a form which allows the user to add a note next
  to the text.


[web2py] Re: passing navigational links in the header and ajax woes

2012-01-21 Thread web-dev-m
Dear Massimo,

Thank you in advance for your time just looking.  If I can write a
functional web application, you must be brilliant to have created this
software.

I am essentially trying to write a google docs clone with the ability
to add notes.

My users upload documents which a python function uses, modifies, and
then stores the text in the database.  The view displays the text from
the page in a set of divs.  I then use AJAX to create a note on the
side via a form.

The text from the document and the document title/file are in
different tables.  Also, there is not guaranteed to be file text yet,
as not every user that uploads a file will need to see the text, so I
upload the file and get the text in two separate functions.

My workflow is:

1.) check to see if file exists in database
2.) IF it doesnt, make it, and store the text in a table, then get the
text fields.
3.) IF it does, get the text fields from one table and the filename
from another
4.) Display file text in the view

I then use AJAX to add a form which allows the user to add a note next
to the text.


[web2py] Re: passing navigational links in the header and ajax woes

2012-01-20 Thread web-dev-m
To pass information from one controller to another.  I assume it is
poor programming practice then? I taught myself web programming on
web2py, so I have never had formal training and it was the easiest way
I could think of to do this.  I think I have seen it in other posted
examples as well.

On Jan 20, 12:14 pm, Cliff cjk...@gmail.com wrote:
  Currently, in my application, I am passing navigational links in the
  header, such as /app/controller/view/1/2/3

  Where 1/2/3 are things the controller and view use to set the correct
  page.

 Why are you doing this?

 On Jan 19, 11:53 pm, web-dev-m mgrave...@gmail.com wrote:







  Currently, in my application, I am passing navigational links in the
  header, such as /app/controller/view/1/2/3

  Where 1/2/3 are things the controller and view use to set the correct
  page.

  In my application, I am finding two problems with this.  First is
  security.  Although I have written validation on my controllers (I
  hope), I just worry that with more users some malicious person will
  find a way to get access they shouldn't.

  Second and more urgent is my application broke when I tried to write
  my first ajax function, I assume because the navigational variables
  are competing with the ajax variables somehow.  I say this because
  when I make the controller empty and just return a dict everything
  works as normal.  However, when I have the controller look for
  variables in request.vars and I then try to call an ajax function, it
  breaks hideously.

  I don't claim to be a great programmer, so it could definitely be a
  convention I am not following.

  Has anyone had this problem before?  How did you solve it? Should I
  pass my request.vars into the session and then have the view call
  them?

   I read in the book that I can do ajax trapping and I haven't tried
  that yet, but I didn't think it would be necessary since I could make
  it work without it.  I will try it, but regardless I would love to get
  some feedback.

  for clarity, my code causing problems is below:

  def my_func():
      if request.args:
          #First, I check to see if there is a record, if there is, I
  get some information.
          check=db(db.mydb.id==request.args(0)).select().first()
          if check !=None:
              records=db(db.mydb.id==request.args(0)).select()
              row = db(db.mydb.id==request.args(0)).select().first()
              counter=len(records)
          #if it isnt, I make it with a function
          else:
              row = db(db.mydb.id==request.args(0)).select().first()
              my_id=row.id
              (filename, stream) =
  db.mydb.myfield.retrieve(row.resourcefield)
              myfunc(id,filename,stream)
              records=db(db.mydb.id==request.args(0)).select()
              counter=len(records)
          pass
      #if there is no specific document request, generate a list of
  available files
      else:
          redirect(URL('mycontroller','this_function'))
      return(counter=counter, records=records, row=row)

  def myajaxfunc():
      form=SQLFORM(db.mydb2, _action=myajaxfunc)
      if form.errors:
          session.flash=Error:  + str(form.errors)
      return XML(form)

  my view:

  {{for i in range(1,5):}}
      div id=my_div onclick=ajax('myajaxfunc',[''],
  'mytarget_{{=str(i)}}')Click me to add a note/div
      div id=mytarget_{{=str(i)}}/div
  {{pass}}


[web2py] passing navigational links in the header and ajax woes

2012-01-19 Thread web-dev-m
Currently, in my application, I am passing navigational links in the
header, such as /app/controller/view/1/2/3

Where 1/2/3 are things the controller and view use to set the correct
page.

In my application, I am finding two problems with this.  First is
security.  Although I have written validation on my controllers (I
hope), I just worry that with more users some malicious person will
find a way to get access they shouldn't.

Second and more urgent is my application broke when I tried to write
my first ajax function, I assume because the navigational variables
are competing with the ajax variables somehow.  I say this because
when I make the controller empty and just return a dict everything
works as normal.  However, when I have the controller look for
variables in request.vars and I then try to call an ajax function, it
breaks hideously.

I don't claim to be a great programmer, so it could definitely be a
convention I am not following.

Has anyone had this problem before?  How did you solve it? Should I
pass my request.vars into the session and then have the view call
them?

 I read in the book that I can do ajax trapping and I haven't tried
that yet, but I didn't think it would be necessary since I could make
it work without it.  I will try it, but regardless I would love to get
some feedback.

for clarity, my code causing problems is below:

def my_func():
if request.args:
#First, I check to see if there is a record, if there is, I
get some information.
check=db(db.mydb.id==request.args(0)).select().first()
if check !=None:
records=db(db.mydb.id==request.args(0)).select()
row = db(db.mydb.id==request.args(0)).select().first()
counter=len(records)
#if it isnt, I make it with a function
else:
row = db(db.mydb.id==request.args(0)).select().first()
my_id=row.id
(filename, stream) =
db.mydb.myfield.retrieve(row.resourcefield)
myfunc(id,filename,stream)
records=db(db.mydb.id==request.args(0)).select()
counter=len(records)
pass
#if there is no specific document request, generate a list of
available files
else:
redirect(URL('mycontroller','this_function'))
return(counter=counter, records=records, row=row)

def myajaxfunc():
form=SQLFORM(db.mydb2, _action=myajaxfunc)
if form.errors:
session.flash=Error:  + str(form.errors)
return XML(form)

my view:

{{for i in range(1,5):}}
div id=my_div onclick=ajax('myajaxfunc',[''],
'mytarget_{{=str(i)}}')Click me to add a note/div
div id=mytarget_{{=str(i)}}/div
{{pass}}


[web2py] Re: dynamic SQLForm.factory from query

2012-01-18 Thread web-dev-m
Awesome.  So easy, I dont know why I didnt think of that.  Thank you.

On Jan 18, 1:57 am, Annet anneve...@googlemail.com wrote:
 Did you have a look at the wiki example in the web2py 
 book:http://www.web2py.com/books/default/chapter/29/3#A-wiki?

 Instead of a 'page' table you have the table from which you retrieve
 the list and, just like in the example, a table to store the comments.
 page_id in your case becomes list_id.

 I don't see why you need the fields and counter variable. I would move
 the for loop to the view and do something like:

 {{for row in rows:}}
   tr
     td{{=row.field_name}}/td
     td{{=A('Add comment',_href=URL('addComment',args=row.id))}}/td
   /tr
 {{pass}}

 .. and in the addComment function something like:

 db.comment.list_id.default=request.args(0)
 form=crud.create(table=db.comment)

 I hope this helps you solve the problem.

 Kind regards,

 Annet


[web2py] dynamic SQLForm.factory from query

2012-01-17 Thread web-dev-m
Dear Everyone,

I am still plugging away on web2py and loving it more and more the
better I understand python.

I have a page where a large list is generated from a database query.
Next to each item from the list, I would like to put the ability to
add a comment.

I did this statically by creating X number of forms for X number of
list items displayed on the page, so I know the concept is possible.
Now, I want to make it dynamic.  I searched this group, and all over
the web for dynamic form web2py, multiple form web2py, etc. and
all iterations thereof.

I did find these threads:
http://groups.google.com/group/web2py/browse_thread/thread/1f577d46bd535433
https://groups.google.com/forum/#!topic/web2py/nE_-yhDG-3o

The second one seemed closer to what I'm trying to do, but for now, my
problem is much simpler.  I have one table, one query, and just a
variable number of fields.  I tried every syntax I could muster
blindly trying to pass in a list of fields to SQLFORM or
SQLFORM.factory.

Below is my code, chopped of the unimportant bits for clarity:

def multi_comment():
records=db(myquery).select()
fields=[]
counter=1
for i in records:
fields.append(Field('note','text'))
fields.append(Field('div_id', default=str(counter)))
counter=counter+1
pass
form=SQLFORM.factory(*fields)
return dict(form=form, fields=fields)

I am getting only one field in my form with a div_id of 1.  I know
there has to be a simple way to do this, I am just not skilled enough
to do it.

Any suggestions?  Also, any help with implementing the db insert after
the form has been processed would be wonderful!

Thank you in advance!


[web2py] Soliciting freelance developers

2012-01-03 Thread web-dev-m
I am developing an application, and I love web2py.  I am new to
programming, and I have gotten quite far on limited expertise.
However, I reached a point where I am going to need help to finish my
application.

Anyone have experience with sites like guru.com to hire a freelance
developer to help with web2py?  Any existing ones that list web2py as
a skill?

Thanks!


[web2py] limiting web2py to my LAN in order to expose secure access to /admin /appadmin

2011-12-11 Thread web-dev-m
Dear Everyone,

I am closing in on a finished web2py application that I will
eventually launch to the web (woo hoo!)

I am using Debian/Apache2 and I want to expose it only to my LAN so I
can do a mini-launch and test it with some other developers that VPN
in. I understand that this is primarily an Apache question, but I
managed to get a similar thing to work for another (non-web2py) site,
and I can't figure this out...

I found an article on how to expose admin and appadmin on old
versions, but i couldn't make that work..

Any suggestions?