[web2py] Data fixtures in web2py

2010-10-19 Thread Luther Goh Lu Feng
I am also trying to prepopulate my database with records similar 
to 
http://groups.google.com/group/web2py/browse_thread/thread/4a80b47d8139e105/54ff156bdce3bc42?lnk=gst&q=fixture#54ff156bdce3bc42


What is the best way to achieve this in web2py?


  


[web2py] Re: Getting the user id for login redirect

2010-10-19 Thread Luther Goh Lu Feng
So a quick google on the google group shows that auth.user_id is the variable I 
am looking for. 

I am really sorry for spamming the list for this simple question. Will search 
more thoroughly next time.


- Original Message 
> From: Luther Goh Lu Feng 
> To: web2py 
> Sent: Wed, October 20, 2010 1:52:19 PM
> Subject: Getting the user id for login redirect
> 
> Good day,
> 
> I am trying to construct a login system that redirects the  login to 
> different 

> controllers depending on which membership they belong to.  Below is the code 
> snippet. I need some tips to access the variable  containing the user id. I 
> believe I might need to look at a session  variable.  If there are any other 
> 
> @auth.requires_login()
> def  index():
> """
> Redirects user to the appropriate  controller based on the group user 
>belongs 
>
> to
> """
>  membership =  db.auth_membership(user_id=SOME_SESSION_USER_VARIABLE)
> if  membership.group_id == 2:
>  redirect(URL(f=workspace))
> elif membership.group_id ==  3:
>  redirect(URL(f=dashboard))
> 
> 
> 
>   
> 


  


[web2py] Getting the user id for login redirect

2010-10-19 Thread Luther Goh Lu Feng
Good day,

I am trying to construct a login system that redirects the login to different 
controllers depending on which membership they belong to. Below is the code 
snippet. I need some tips to access the variable containing the user id. I 
believe I might need to look at a session variable.  If there are any other 

@auth.requires_login()
def index():
"""
Redirects user to the appropriate controller based on the group user 
belongs 
to
"""
membership = db.auth_membership(user_id=SOME_SESSION_USER_VARIABLE)
if membership.group_id == 2:
redirect(URL(f=workspace))
elif membership.group_id == 3:
redirect(URL(f=dashboard))



  


[web2py] Best way to represent list:string on the widget side?

2010-10-19 Thread Chris
I'm trying to make an HTML widget that saves its data as a
list:string.

Currently I'm using a hidden control and saving data joined by '|',
like 'M|T|W', but that only appears to work in displaying the data,
not when saving the data back to DB.

How should I render the control so it saves back to DB properly?

Thanks!


[web2py] Re: Instant Press in beta

2010-10-19 Thread Richard
On Oct 19, 8:58 pm, "Martin.Mulone"  wrote:
> > Opening and closing all those admin panels takes a lot of mouse work
>
> I'm going to see, I don't know anything about events keys in js

I used this library for a previous project: http://code.google.com/p/js-hotkeys/
Very simple: $('div.foo').bind('keydown', 'Ctrl+a', fn);


> >- I saw you can change the CSS. Can you also embed additional JavaScript?
>
> Not at this moment but its easy to implement, do you think that this is 
> usefull?

I was thinking about migrating an existing site to Instant Press that
has a photo gallery via the lightbox library: 
http://leandrovieira.com/projects/jquery/lightbox/
Also I usually embed the Google Analytics ga.js file.

Would supporting JavaScript be the best approach to supporting this?


BTW love your code style - lots of whitespace.

Do you have plans for the future? Is this a personal project or for
work?
Regarding a better method for full text search, is this useful:
http://billkatz.com/2009/6/Simple-Full-Text-Search-for-App-Engine

Richard


[web2py] Re: Stand Alone DAL and migrations (again)

2010-10-19 Thread mart
forgot to mention something a well...

I think the issue I had was related to yours with the migration,
because creating a table, without specifying migrate=  produces the
following exception while defining a table. That migration data as
well as the parameters I passed in both get validated by
t._create(migrate=migrate, fake_migrate=fake_migrate). This is why I
think migrating or creating tables with no migration... both are
subject to the same rules, risking the same exceptions.


db.define_table(tableName,
SQLField('blueModuleStr'),
SQLField('blueModuleObj','blob'),
SQLField('blueModuleImports'))


objMakeDB.instModule(folder)
  File "/Users/mart/Documents/Aptana Studio Workspace/blueLite/src/
blueLite/pyModules/createModuleTable.py", line 34, in instModule

SQLField('blueModuleImports'))
  File "/Users/mart/Documents/Aptana Studio Workspace/blueLite/src/
blueLite/pyUtils/gluon/dal.py", line 1399, in define_table

t._create(migrate=migrate, fake_migrate=fake_migrate)
  File "/Users/mart/Documents/Aptana Studio Workspace/blueLite/src/
blueLite/pyUtils/gluon/dal.py", line 1869, in _create


Mart :)

On Oct 19, 7:11 pm, mart  wrote:
> I have recently introduced the web2py DAL to some back-end stuff so
> that it would play well with the front end (web2py). Although I did
> trim it down and the amount of files in the gluon folder (I bootstrap
> for each start of each software build, so size matters) and got rid of
> some unresolved imports caused by the triming (i don't need web access
> here, just the dal). So, are you taking about where (path) the .db and
> tables get created? if this is the case, then I found 2 things:
>
> 1) the db and tables don't seem to follow the same rule in that the db
> can get created just about anywhere, where the tables seem to get
> created relative to where *db.define_table(tableName,...)* is called
> (seems to be the default). so depending on where you are in the
> structure... also, I notice I had to be xtra sensitive with error
> handling in that, if a previous step failed to lets say do an update
> or an insert and if I didn't handle that well at THAT moment, then the
> next time that field was referenced (which caused an exception), it
> create the entire set of default tables I setup and would do so where
> ever the module doing the EXECUTE would be. Which lead to look at
> dal.py
>
> 2)so, her, the code can be changed to modify that behavior, and I kept
> good focus while following the flow of the script, but it is
> relatively large file, and I didn't take notes as I was reading. But
> it should be doable. the trick is to isolate the code directly related
> to 1) the adapter of the of the db your are using and the table/and
> migration related actions (that's where we see most of the references
> to the folder housing the tables). I haven't tried yet, and i don"t
> know if doing this would offend Massimo, so I held back and stuck with
> being relative to the folders where I generate tables.
>
> BTW - i believe this is the code causing your exception, so one of
> your params is not in line with what's expected ("if not in key") or
> its type is wrong (just guessing though).
>
>         for key in args:
>             if key not in [
>                     'migrate',
>                     'primarykey',
>                     'fake_migrate',
>                     'format',
>                     'trigger_name',
>                     'sequence_name']:
>                 raise SyntaxError, 'invalid table "%s" attribute: %s'
> % (tablename, key)
>
> hope it helps.
>
> Mart :)
>
> On Oct 19, 3:37 pm, Bruno Rocha  wrote:
>
> > Somebody knows a trick?
>
> > 2010/10/19 Bruno Rocha 
>
> > > I forgot to mention that I tried:
>
> > >  DAL(,folder=...) pointing folder="" to the directory where .table
> > > files are, but does not works.
>
> > > 2010/10/19 Bruno Rocha 
>
> > > I know DAL was not made for that, but I'm using the DAL in a desktop
> > >> application with PyGTK, and it is working very well :-)
>
> > >> It is a simple application that monitors the presence of employees in a
> > >> company and reads small CSV files from a time clock,
> > >> people has cards that open the gates/doors of the company factory, I use 
> > >> a
> > >> stream to read the track from serial port of time clock,
> > >> then, I take the information serialized as CSV, I parse and write it into
> > >> SQLite db, after that , the Janitor uses a PyGTK app to access that
> > >> information.
>
> > >> already been running for about 6 months, So far everything is working
> > >> fine, but I can not run the automatic migrations.
>
> > >> Does anyone know a way to make migration work automatically with DAL 
> > >> Stand
> > >> Alone?
>
> > >> I'm importing sql.py I'm connecting with SQLite, setting tables, 
> > >> accessing
> > >> and doing out any crud operation.
>
> > >> The only thing missing is to make migration works.
>
> > >> I

[web2py] Re: What does this mean?

2010-10-19 Thread BigBaaadBob
# The origin of the requirement: i.e. whether it is fundamental or
derived
db.define_table('origin',
Field('name', requires=IS_NOT_EMPTY()),
Field('key', requires=IS_NOT_EMPTY()),
format='%(name)s'
)

# The category of the requirement
db.define_table('kind',
Field('name', requires=IS_NOT_EMPTY()),
Field('key', requires=IS_NOT_EMPTY()),
format='%(name)s'
)

# The actual requirement object
db.define_table('requirement',
Field('title',requires=IS_NOT_EMPTY()),
Field('body', 'text',requires=IS_NOT_EMPTY()),
Field('rationale', 'text'),
Field('preconditions', 'text'),
Field('postconditions', 'text'),
Field('traces_to', 'reference
requirement',requires=IS_EMPTY_OR(IS_IN_DB(db, 'requirement.id',
'requirement.title'))),
Field('origin', db.origin,requires=IS_IN_DB(db, 'origin.id',
'origin.name')),
Field('kind', db.kind,requires=IS_IN_DB(db, 'kind.id',
'kind.name')),
Field('is_safety_critical','boolean'),
Field('updated_by', db.auth_user, default=auth.user_id,
update=auth.user_id, readable=False, writable=False),
Field('updated_on', 'datetime', default=request.now,
update=request.now, readable=False, writable=False),
format='%(title)s'
)

# Put fake data in the requirements table
from gluon.contrib.populate import populate
if db(db.origin.id>0).count() == 0:
populate(db.origin,5)
db.commit()

if db(db.kind.id>0).count() == 0:
populate(db.kind,5)
db.commit()

if db(db.requirement.id>0).count() == 0:
populate(db.requirement,50)
db.commit()


On Oct 19, 8:16 pm, BigBaaadBob  wrote:
> I can reliably create this problem with a model that contains
> "references xxx" and using populate.  Trying to access the table in
> the db manager causes the referenced error.


[web2py] Re: What does this mean?

2010-10-19 Thread BigBaaadBob
I can reliably create this problem with a model that contains
"references xxx" and using populate.  Trying to access the table in
the db manager causes the referenced error.


[web2py] Re: kind of newbie question

2010-10-19 Thread DenesL
Hello Richard,

if I understood correctly, you want:

...
BlackList = [ 'fieldx', 'fieldy', ...]
rows = db().select(*[f for f in db['table1'].fields if f not in
BlackList])
...

Denes

On Oct 19, 6:14 pm, Richard Vézina 
wrote:
> Hello,
>
> I would do this :
>
> def grid():
>     if request.args[0] in tableSubSet:
>         allFieldsSet=set(db['table1'].fields) # all the fields in the table
>         fieldsBlackListSet=set(['f1ToRem','f2ToRem','f1ToRem']) # fields to
> be remove from the grid
>         allFieldsSet-=fieldsBlackListSet # removing fields to be removed
>         fieldsRequested=[]
>         for field in allFieldsSet:
>             fieldsRequestedList.append('db.test_activity.'+field) # building
> the select list of elements
>
>         a=','.join(fieldsRequestedList) # transform the list into a string
>
>         rows = db().select(a) # BLOCKED BECAUSE OF THE QUOTES
> (*'*db.table1.field1,
> db.table1.field2, etc.*'*)!!!
>         table=SQLTABLE(rows)
>         return dict(table=table)
>
> Thanks for your help.
>
> Richard


Re: [web2py] Google Moderator...

2010-10-19 Thread Bruno Rocha
Nice!

in web2py site we have a link to http://web2py.uservoice.com, which is a
place where everyone can send ideas, questions, features desirability etc..


2010/10/19 Anand Vaidya 

> We can use google moderator to collect ideas, questions on new
> features (desirability) etc , vote on them and I believe will enhance
> the web2py community process.
>
>
> http://www.google.com/moderator/#0
>
>*  Let your audience decide
>  Get to know your audience by letting them decide which
> questions, suggestions or ideas interest them most.
>
>   *  Everyone's voice is heard
>  The voting box at the top of page focuses attention on
> submissions recently added and on the rise, making it simple and easy
> to participate.
>
>*  Be creative
>  Include people in your preparation for lectures, interviews and
> hard decisions or work together to organize feature requests and
> brainstorm new ideas.
>



-- 

http://rochacbruno.com.br


[web2py] Get query from string

2010-10-19 Thread toan75
I have string, ex: "((person.id>0)&(person.car=car.id))", i like get
my query = (db.person.id>0) & (db.person.car==db.car.id),  same like
get_query function in appadmin controller?

def get_query(request):
try:
return eval_in_global_env(request.vars.query)
except Exception:
return None

Pls help me. Thanks.


[web2py] Google Moderator...

2010-10-19 Thread Anand Vaidya
We can use google moderator to collect ideas, questions on new
features (desirability) etc , vote on them and I believe will enhance
the web2py community process.


http://www.google.com/moderator/#0

*  Let your audience decide
  Get to know your audience by letting them decide which
questions, suggestions or ideas interest them most.

   *  Everyone's voice is heard
  The voting box at the top of page focuses attention on
submissions recently added and on the rise, making it simple and easy
to participate.

*  Be creative
  Include people in your preparation for lectures, interviews and
hard decisions or work together to organize feature requests and
brainstorm new ideas.


[web2py] "Pack all" and databases

2010-10-19 Thread BigBaaadBob
I gather "pack all" just packages the contents of the application's
directory...right?

This would then include the content "databases", right ?  But if I
want to deploy an app, it seems like I usually wouldn't want to also
deploy the content of a database.

Is there a way to "pack all" without including the content of
databases?


[web2py] Components and LOAD function

2010-10-19 Thread pecos1046
I have been using the LOAD function in an application, but by looking
at comments from this user group, I get the impression that it is
still experimental. Is that correct? Anyway, I enjoy using it and an
example on how to pass args and vars to its associated functions will
be very helpful.



[web2py] Re: Stand Alone DAL and migrations (again)

2010-10-19 Thread mart
I have recently introduced the web2py DAL to some back-end stuff so
that it would play well with the front end (web2py). Although I did
trim it down and the amount of files in the gluon folder (I bootstrap
for each start of each software build, so size matters) and got rid of
some unresolved imports caused by the triming (i don't need web access
here, just the dal). So, are you taking about where (path) the .db and
tables get created? if this is the case, then I found 2 things:

1) the db and tables don't seem to follow the same rule in that the db
can get created just about anywhere, where the tables seem to get
created relative to where *db.define_table(tableName,...)* is called
(seems to be the default). so depending on where you are in the
structure... also, I notice I had to be xtra sensitive with error
handling in that, if a previous step failed to lets say do an update
or an insert and if I didn't handle that well at THAT moment, then the
next time that field was referenced (which caused an exception), it
create the entire set of default tables I setup and would do so where
ever the module doing the EXECUTE would be. Which lead to look at
dal.py


2)so, her, the code can be changed to modify that behavior, and I kept
good focus while following the flow of the script, but it is
relatively large file, and I didn't take notes as I was reading. But
it should be doable. the trick is to isolate the code directly related
to 1) the adapter of the of the db your are using and the table/and
migration related actions (that's where we see most of the references
to the folder housing the tables). I haven't tried yet, and i don"t
know if doing this would offend Massimo, so I held back and stuck with
being relative to the folders where I generate tables.

BTW - i believe this is the code causing your exception, so one of
your params is not in line with what's expected ("if not in key") or
its type is wrong (just guessing though).


for key in args:
if key not in [
'migrate',
'primarykey',
'fake_migrate',
'format',
'trigger_name',
'sequence_name']:
raise SyntaxError, 'invalid table "%s" attribute: %s'
% (tablename, key)

hope it helps.

Mart :)

On Oct 19, 3:37 pm, Bruno Rocha  wrote:
> Somebody knows a trick?
>
> 2010/10/19 Bruno Rocha 
>
>
>
> > I forgot to mention that I tried:
>
> >  DAL(,folder=...) pointing folder="" to the directory where .table
> > files are, but does not works.
>
> > 2010/10/19 Bruno Rocha 
>
> > I know DAL was not made for that, but I'm using the DAL in a desktop
> >> application with PyGTK, and it is working very well :-)
>
> >> It is a simple application that monitors the presence of employees in a
> >> company and reads small CSV files from a time clock,
> >> people has cards that open the gates/doors of the company factory, I use a
> >> stream to read the track from serial port of time clock,
> >> then, I take the information serialized as CSV, I parse and write it into
> >> SQLite db, after that , the Janitor uses a PyGTK app to access that
> >> information.
>
> >> already been running for about 6 months, So far everything is working
> >> fine, but I can not run the automatic migrations.
>
> >> Does anyone know a way to make migration work automatically with DAL Stand
> >> Alone?
>
> >> I'm importing sql.py I'm connecting with SQLite, setting tables, accessing
> >> and doing out any crud operation.
>
> >> The only thing missing is to make migration works.
>
> >> I already set migrate='Mytable.table' and I tried with migrate=True
>
> >> 
> >> An example of what I have working in my
>
> >> "connect.py"
> >> >>> from gluon.sql import *
> >> >>> db = DAL('sqlite://timeclock1.db')
> >> >>> Track =
> >> db.define_table('track',Field('regnumber','integer'),Field('action','integer'),Field('timestamp','datetime'),migrate='track.table')
>
> >> "Form_workflow.py"
> >> >>> Track.insert(regnumber=123,action=2,timestamp='2010-10-19')
> >> 1
> >> >>> Track.insert(regnumber=124,action=2,timestamp='2010-10-19')
> >> 2
> >> >>> db.commit
>
> >> Until here, its ok.
>
> >> But now I am wanting to change the model, and including
> >> Field('department')
>
> >>  "connect.py"
> >> >>> Track =
> >> db.define_table('track',Field('regnumber','integer'),Field('action','integer'),Field('timestamp','datetime'),
> >> *Field('department')*,migrate='track.table')
>
> >> Traceback (most recent call last):
> >>   File "", line 1, in 
> >>   File "/bin/DAL/gluon/sql.py", line 1346, in define_table
> >>     raise SyntaxError, 'invalid table name: %s' % tablename
> >> SyntaxError: invalid table name: track
>
> >> 
>
> >> If this is not possible, I'll have to create new fields in SQLite and then
> >> update my model.
>
> > --
>
> >http://rochacbruno.com.br
>
> --
>
> http://rochacbruno.com.br


Re: [web2py] how to install plugin_wiki?

2010-10-19 Thread Bruno Rocha
You just have to upload and submit the plugin_wiki file throught /appadmin,
or you can just copy "plugin_?" files in to models, controllers, views,
static etc..

2010/10/19 Tim Michelsen 

> The book on http://web2py.com/book/default/chapter/13#plugin_wiki
> does not tell anything about this.
>
>


-- 

http://rochacbruno.com.br


[web2py] kind of newbie question

2010-10-19 Thread Richard Vézina
Hello,

I would do this :

def grid():
if request.args[0] in tableSubSet:
allFieldsSet=set(db['table1'].fields) # all the fields in the table
fieldsBlackListSet=set(['f1ToRem','f2ToRem','f1ToRem']) # fields to
be remove from the grid
allFieldsSet-=fieldsBlackListSet # removing fields to be removed
fieldsRequested=[]
for field in allFieldsSet:
fieldsRequestedList.append('db.test_activity.'+field) # building
the select list of elements

a=','.join(fieldsRequestedList) # transform the list into a string

rows = db().select(a) # BLOCKED BECAUSE OF THE QUOTES
(*'*db.table1.field1,
db.table1.field2, etc.*'*)!!!
table=SQLTABLE(rows)
return dict(table=table)

Thanks for your help.

Richard


[web2py] how to install plugin_wiki?

2010-10-19 Thread Tim Michelsen
The book on http://web2py.com/book/default/chapter/13#plugin_wiki
does not tell anything about this.



Re: [web2py] In trunk. admin wizard. Please give it a try (alpha)

2010-10-19 Thread Bruno Rocha
Very nice!

I like the possibility to have different themes for scaffold, could use the
actual, the one proposed by Martin, the oldest one, and a blank.

2010/10/19 mdipierro 

> http://127.0.0.1:8000/admin/wizard




-- 

http://rochacbruno.com.br


[web2py] present a wait page to user

2010-10-19 Thread meland
Hello Group...

I'm both new to web2py and web programming... but I have been learning
web2py for a couple months now.

The scenario I'm trying to implement server-side is as follows...

A user "A" clicks a link and the corresponding function 1) initiates a
database poll that may take a few seconds or so to complete; 2)
simultaneously presents user "A" with a link-free page asking them to
wait; 3) when the database poll has completed - checking to see that a
value has been posted by user "B" - user "A" is redirected from the
wait page to another URL.

I'm stuck with this.  I've tried coding this different ways, but what
typically happens is that the wait page does not display until after
the polling operation has completed and the user is not redirected to
the new URL.  I have read over the intro and core sections of the book
regarding processing flow, but I'm still not sure how to solve this
issue.  In need of some some direction :)

Cheers.


Re: [web2py] Re: PyScripter is nice Python IDE for Windows ....

2010-10-19 Thread Stef Mientki
 On 19-10-2010 22:43, cjrh wrote:
> On Oct 19, 2:26 pm, DenesL  wrote:
>> Have you used it to debug a running web2py app?.
> No.  I tend to use print statements and look at what comes out in the
> shell window.
I used a few times,
I can only say it works,
but the problem I found is that a lot of errors are already captured by web2py.

The new PyScripter seems to have a nice feature, don't debug in certain files,
so it should be possible to ignore the web2py core files (if you want).

I think for debugging winpdb might be a better solution,
at least that's what I've chosen for web2py_cc ;-)

cheers,
Stef


[web2py] Re: URL redirect depending on user group

2010-10-19 Thread Luther Goh Lu Feng
Please ignore this.. I resolve it. Always a bad idea to code till 5am in the 
morning...


- Original Message 
> From: Luther Goh Lu Feng 
> To: web2py@googlegroups.com
> Sent: Wed, October 20, 2010 4:50:50 AM
> Subject: URL redirect depending on user group
> 
> Hi,
> 
> I am trying to redirect login users to different pages/controllers,  
> depending 
>on 
>
> which group they belong to. What is the best way to do this? I  am not too 
> familiar with the syntax but my educated guess seems to indicated  that it 
>would 
>
> be something similar to:
> 
> auth.settings.login_next =  URL('index', args=db.auth_membership.group_id)
> 
> At the index controller, I  will process request.vars to decide which 
>controller 
>
> to redirect  to.
> 
> Any tips?
> 
> 
> Cheers,
> 
> Luther
> 
> 
>
> 


  


[web2py] Re: In trunk. admin wizard. Please give it a try (alpha)

2010-10-19 Thread Tim Michelsen
> http://127.0.0.1:8000/admin/wizard
I think what could also be useful is to add a new table or field to a
table later on after the app had created.



[web2py] URL redirect depending on user group

2010-10-19 Thread Luther Goh Lu Feng
Hi,

I am trying to redirect login users to different pages/controllers, depending 
on 
which group they belong to. What is the best way to do this? I am not too 
familiar with the syntax but my educated guess seems to indicated that it would 
be something similar to:

auth.settings.login_next = URL('index', args=db.auth_membership.group_id)

At the index controller, I will process request.vars to decide which controller 
to redirect to.

Any tips?


Cheers,

Luther


  


[web2py] Re: In trunk. admin wizard. Please give it a try (alpha)

2010-10-19 Thread Tim Michelsen
Am 19.10.2010 18:20, schrieb mdipierro:
> http://127.0.0.1:8000/admin/wizard
Please do also link to this from
http://127.0.0.1:8000/admin/default/site

at best in the create new app section.



[web2py] Re: PyScripter is nice Python IDE for Windows ....

2010-10-19 Thread cjrh
On Oct 19, 2:26 pm, DenesL  wrote:
> Have you used it to debug a running web2py app?.

No.  I tend to use print statements and look at what comes out in the
shell window.


[web2py] Re: In trunk. admin wizard. Please give it a try (alpha)

2010-10-19 Thread Tim Michelsen
Hey,
this is very nic.

The only think is that the INFO sentences are
a) not very accessible from the readability pointof view
b)not very helpful. example in step 3:

 You can use special attributes like "integer", "boolean", "float",
"file", "date", "time", "datetime" to specify the fields type. You can
also use "multiple", "notnull" and "unique" to add attributes. To create
a reference just add the name of the table you want to reference.

It does simple to help.

I suggest:
* Divide messages into paragraphs
* have a animated GIF or small video for each step.
* include a WSIWYG editor for the HTML editing

and extended  feature could be the selection of installed plugins and
layout pages for inclusion into the respecitve pages.

Apart from that, this is just sooo biiig thing. Web app development
fully in browser!

Go on!



Re: [web2py] Re: sorry I don't understand URL

2010-10-19 Thread Stef Mientki
 ok thanks,
I think I was using URl as the os.path.join() function ;-)

cheers,
Stef
On 19-10-2010 21:37, mdipierro wrote:
> URL can take 0, 1, 2, or 3 un-named argument:
>
> URL(args=[],vars={})
> URL(function,args=[],vars={})
> URL(controller, function,args=[],vars={})
> URL(application, controller, function,args=[],vars={})
>
> args and vars and also optional but, if you pass values for them, they
> must be named.
>
> You should not specify application, controller and/or function if they
> are the same as the current ones.
>
> Massimo
>
>
>
> On Oct 19, 2:28 pm, Stef Mientki  wrote:
>>  thanks Massimo,
>>
>> but your answers just makes me more confuse ...
>>
>> On 19-10-2010 02:06, mdipierro wrote:> Mind that it is not a good idea to do 
>> this:
>>
>>> URL("call", "run", "Set_Page", args="77" )
>> well this the exactly what the books says at page 396,
>> and it although I don't understand why "call" and "run" is needed,
>> (but I think it has something todo with services)
>> but it works.
>>
>>> i.e. pass the application name. You want instead
>>> URL("run", "Set_Page", args="77" )
>> this is not in the book and it doesn't work (in my case) ;-)
>>
>> here a small overview:
>>   LSB_Menu.append ( [ 'Stef1',  URL("run","Set_Page","77") ])  ## invalid 
>> request
>>
>>   LSB_Menu.append ( [ 'Stef2',  URL("call","run","Set_Page","77") ])  ## 
>> internal error
>>   LSB_Menu.append ( [ 'Stef3',  "call/run/Set_Page/77"  ])  ## OK
>>   LSB_Menu.append ( [ 'Stef4',  URL("call/run/Set_Page/77") ])  ## OK
>>
>>   LSB_Menu.append ( [ 'Stef3',  "run/Set_Page/77"   ])  ## invalid 
>> function
>>   LSB_Menu.append ( [ 'Stef5',  URL("run/Set_Page/77")  ])  ## invalid 
>> function
>>
>> What am I doing wrong ?
>>
>> thanks,
>> Stef
>>
>>> else if the app is renamed the links break.
>>> On Oct 18, 6:52 pm, Stef Mientki  wrote:
  hello,
 I'm trying to call a service from menu buttons,
 and I read somewhere in the manual, you should always use URL()
 Now this works:
   LSB_Menu.append ( [ 'Stef3',"call/run/Set_Page/77" ])
 But the following don't (while printing the URL result, looks ok), why ??
   #LSB_Menu.append ( [ 'Stef4',URL("call", "run", "Set_Page", args="77" ) 
 ])
   #LSB_Menu.append ( [ 'Stef5',URL("call", "run", "Set_Page", vars="77" ) 
 ])
   #LSB_Menu.append ( [ 'Stef5',URL("call", "run", "Set_Page", "77" )])
 # this is the service
 from gluon.tools import Service
 service = Service(globals())
 def call():
   return service()
 @service.run
 def Set_Page(Nr):
   return dict ( m='aap',b=99,c=Nr)
 thanks,
 Stef Mientki
>>



[web2py] Re: Stand Alone DAL and migrations (again)

2010-10-19 Thread Bruno Rocha
Somebody knows a trick?

2010/10/19 Bruno Rocha 

> I forgot to mention that I tried:
>
>  DAL(,folder=...) pointing folder="" to the directory where .table
> files are, but does not works.
>
> 2010/10/19 Bruno Rocha 
>
> I know DAL was not made for that, but I'm using the DAL in a desktop
>> application with PyGTK, and it is working very well :-)
>>
>> It is a simple application that monitors the presence of employees in a
>> company and reads small CSV files from a time clock,
>> people has cards that open the gates/doors of the company factory, I use a
>> stream to read the track from serial port of time clock,
>> then, I take the information serialized as CSV, I parse and write it into
>> SQLite db, after that , the Janitor uses a PyGTK app to access that
>> information.
>>
>> already been running for about 6 months, So far everything is working
>> fine, but I can not run the automatic migrations.
>>
>> Does anyone know a way to make migration work automatically with DAL Stand
>> Alone?
>>
>> I'm importing sql.py I'm connecting with SQLite, setting tables, accessing
>> and doing out any crud operation.
>>
>> The only thing missing is to make migration works.
>>
>> I already set migrate='Mytable.table' and I tried with migrate=True
>>
>> 
>> An example of what I have working in my
>>
>> "connect.py"
>> >>> from gluon.sql import *
>> >>> db = DAL('sqlite://timeclock1.db')
>> >>> Track =
>> db.define_table('track',Field('regnumber','integer'),Field('action','integer'),Field('timestamp','datetime'),migrate='track.table')
>>
>> "Form_workflow.py"
>> >>> Track.insert(regnumber=123,action=2,timestamp='2010-10-19')
>> 1
>> >>> Track.insert(regnumber=124,action=2,timestamp='2010-10-19')
>> 2
>> >>> db.commit
>>
>> Until here, its ok.
>>
>> But now I am wanting to change the model, and including
>> Field('department')
>>
>>  "connect.py"
>> >>> Track =
>> db.define_table('track',Field('regnumber','integer'),Field('action','integer'),Field('timestamp','datetime'),
>> *Field('department')*,migrate='track.table')
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File "/bin/DAL/gluon/sql.py", line 1346, in define_table
>> raise SyntaxError, 'invalid table name: %s' % tablename
>> SyntaxError: invalid table name: track
>> >>>
>>
>> 
>>
>> If this is not possible, I'll have to create new fields in SQLite and then
>> update my model.
>
>
>
>
> --
>
> http://rochacbruno.com.br
>



-- 

http://rochacbruno.com.br


[web2py] Re: sorry I don't understand URL

2010-10-19 Thread mdipierro
URL can take 0, 1, 2, or 3 un-named argument:

URL(args=[],vars={})
URL(function,args=[],vars={})
URL(controller, function,args=[],vars={})
URL(application, controller, function,args=[],vars={})

args and vars and also optional but, if you pass values for them, they
must be named.

You should not specify application, controller and/or function if they
are the same as the current ones.

Massimo



On Oct 19, 2:28 pm, Stef Mientki  wrote:
>  thanks Massimo,
>
> but your answers just makes me more confuse ...
>
> On 19-10-2010 02:06, mdipierro wrote:> Mind that it is not a good idea to do 
> this:
>
> > URL("call", "run", "Set_Page", args="77" )
>
> well this the exactly what the books says at page 396,
> and it although I don't understand why "call" and "run" is needed,
> (but I think it has something todo with services)
> but it works.
>
> > i.e. pass the application name. You want instead
>
> > URL("run", "Set_Page", args="77" )
>
> this is not in the book and it doesn't work (in my case) ;-)
>
> here a small overview:
>   LSB_Menu.append ( [ 'Stef1',  URL("run","Set_Page","77") ])  ## invalid 
> request
>
>   LSB_Menu.append ( [ 'Stef2',  URL("call","run","Set_Page","77") ])  ## 
> internal error
>   LSB_Menu.append ( [ 'Stef3',  "call/run/Set_Page/77"      ])  ## OK
>   LSB_Menu.append ( [ 'Stef4',  URL("call/run/Set_Page/77") ])  ## OK
>
>   LSB_Menu.append ( [ 'Stef3',  "run/Set_Page/77"           ])  ## invalid 
> function
>   LSB_Menu.append ( [ 'Stef5',  URL("run/Set_Page/77")      ])  ## invalid 
> function
>
> What am I doing wrong ?
>
> thanks,
> Stef
>
> > else if the app is renamed the links break.
>
> > On Oct 18, 6:52 pm, Stef Mientki  wrote:
> >>  hello,
>
> >> I'm trying to call a service from menu buttons,
> >> and I read somewhere in the manual, you should always use URL()
>
> >> Now this works:
> >>   LSB_Menu.append ( [ 'Stef3',"call/run/Set_Page/77" ])
>
> >> But the following don't (while printing the URL result, looks ok), why ??
> >>   #LSB_Menu.append ( [ 'Stef4',URL("call", "run", "Set_Page", args="77" ) 
> >> ])
> >>   #LSB_Menu.append ( [ 'Stef5',URL("call", "run", "Set_Page", vars="77" ) 
> >> ])
> >>   #LSB_Menu.append ( [ 'Stef5',URL("call", "run", "Set_Page", "77" )])
>
> >> # this is the service
> >> from gluon.tools import Service
> >> service = Service(globals())
> >> def call():
> >>   return service()
> >> @service.run
> >> def Set_Page(Nr):
> >>   return dict ( m='aap',b=99,c=Nr)
>
> >> thanks,
> >> Stef Mientki
>
>


Re: [web2py] Re: sorry I don't understand URL

2010-10-19 Thread Stef Mientki
 thanks Massimo,

but your answers just makes me more confuse ...

On 19-10-2010 02:06, mdipierro wrote:
> Mind that it is not a good idea to do this:
>
> URL("call", "run", "Set_Page", args="77" )
well this the exactly what the books says at page 396,
and it although I don't understand why "call" and "run" is needed,
(but I think it has something todo with services)
but it works.

> i.e. pass the application name. You want instead
>
> URL("run", "Set_Page", args="77" )
>
this is not in the book and it doesn't work (in my case) ;-)

here a small overview:
  LSB_Menu.append ( [ 'Stef1',  URL("run","Set_Page","77") ])  ## invalid 
request
 
  LSB_Menu.append ( [ 'Stef2',  URL("call","run","Set_Page","77") ])  ## 
internal error
  LSB_Menu.append ( [ 'Stef3',  "call/run/Set_Page/77"  ])  ## OK
  LSB_Menu.append ( [ 'Stef4',  URL("call/run/Set_Page/77") ])  ## OK
 
  LSB_Menu.append ( [ 'Stef3',  "run/Set_Page/77"   ])  ## invalid 
function
  LSB_Menu.append ( [ 'Stef5',  URL("run/Set_Page/77")  ])  ## invalid 
function

What am I doing wrong ?

thanks,
Stef
> else if the app is renamed the links break.
>
> On Oct 18, 6:52 pm, Stef Mientki  wrote:
>>  hello,
>>
>> I'm trying to call a service from menu buttons,
>> and I read somewhere in the manual, you should always use URL()
>>
>> Now this works:
>>   LSB_Menu.append ( [ 'Stef3',"call/run/Set_Page/77" ])
>>
>> But the following don't (while printing the URL result, looks ok), why ??
>>   #LSB_Menu.append ( [ 'Stef4',URL("call", "run", "Set_Page", args="77" ) ])
>>   #LSB_Menu.append ( [ 'Stef5',URL("call", "run", "Set_Page", vars="77" ) ])
>>   #LSB_Menu.append ( [ 'Stef5',URL("call", "run", "Set_Page", "77" )])
>>
>> # this is the service
>> from gluon.tools import Service
>> service = Service(globals())
>> def call():
>>   return service()
>> @service.run
>> def Set_Page(Nr):
>>   return dict ( m='aap',b=99,c=Nr)
>>
>> thanks,
>> Stef Mientki



Re: [web2py] Re: In trunk. admin wizard. Please give it a try (alpha)

2010-10-19 Thread R. Strusberg
Yes!. You are right. :-)

2010/10/19 mdipierro 

> Did you copy the wizard without upgrading? DEMO_MODE is defined in
> admin/models/0.py
>
> On Oct 19, 11:54 am, "R. Strusberg"  wrote:
> > Massimo,
> >
> > The wizard generated an error when I tried to create the application,
> > because DEMO_MOD is not defined. I comment the three lines where the test
> > about DEMO_MOD is done in the wizard.py and the application is built
> without
> > problems.
> >
> > Ricardo
> >
> > 2010/10/19 mdipierro 
> >
> > >http://127.0.0.1:8000/admin/wizard
> >
> >
>


[web2py] Re: In trunk. admin wizard. Please give it a try (alpha)

2010-10-19 Thread mdipierro
Did you copy the wizard without upgrading? DEMO_MODE is defined in
admin/models/0.py

On Oct 19, 11:54 am, "R. Strusberg"  wrote:
> Massimo,
>
> The wizard generated an error when I tried to create the application,
> because DEMO_MOD is not defined. I comment the three lines where the test
> about DEMO_MOD is done in the wizard.py and the application is built without
> problems.
>
> Ricardo
>
> 2010/10/19 mdipierro 
>
> >http://127.0.0.1:8000/admin/wizard
>
>


[web2py] Re: Local date format in INPUT tag

2010-10-19 Thread annet
Hi Mirek,

Here's an excerpt of my log that might be helpful:

Formatting date

Model file:

T.force('en-de')  ## en-de is a language file you'll create below

In the table definition:

SQLField('fieldname', type='date')

... a validator on this field which reads like:

db.tablename.fieldname.requires=IS_NULL_OR(IS_DATE(str(T('%Y-%m-
%d'

Languages file:

... create a language file e.g. en-de.py and edit the dates:

OriginalTranslation
%Y-%m-%d%d-%m-%Y
%Y-%m-%d %H:%M:%S   %d-%m-%Y %H:%M:%S

Click update.

Views file:

... to use the date in a view:

{{=db.tablename.fieldname.formatter(tablename.fieldname)}}

If you use form_factory to create a custom form, the code in the
controller should read:

SQLField('fieldname',type='date',requires=IS_DATE(str(T('%Y-%m-
%d'

Kind regards,

Annet.


Re: [web2py] In trunk. admin wizard. Please give it a try (alpha)

2010-10-19 Thread R. Strusberg
Massimo,

The wizard generated an error when I tried to create the application,
because DEMO_MOD is not defined. I comment the three lines where the test
about DEMO_MOD is done in the wizard.py and the application is built without
problems.

Ricardo

2010/10/19 mdipierro 

> http://127.0.0.1:8000/admin/wizard


[web2py] In trunk. admin wizard. Please give it a try (alpha)

2010-10-19 Thread mdipierro
http://127.0.0.1:8000/admin/wizard


[web2py] Re: What is default or best datagrid? Webgrid or Jqgrid?

2010-10-19 Thread Savio Sabino
Ok. Thanks for you explanation.


On Oct 19, 11:22 am, "mr.freeze"  wrote:
> I would say jqGrid is definitely better.  I wrote WebGrid because I
> needed something that didn't require javascript.  jqGrid has more
> features, an excellent API and is better supported.
>
> On Oct 19, 6:37 am, Savio Sabino  wrote:
>
> > Hi.
> > What is best choose to use datagrid in web2py? Webgrid or jqgrid?
> > What the comparision be do with this tools?
> > Or is the best use the two to interoperate? If is this, how?
>
>


[web2py] Re: Vote for a new logo

2010-10-19 Thread mdipierro
+1

On Oct 19, 10:19 am, weheh  wrote:
> It's really heartwarming to see the enthusiasm for web2py in the large
> number of logo submissions. Congrats to all for their efforts and may
> the best logo win!


[web2py] Re: Vote for a new logo

2010-10-19 Thread weheh
It's really heartwarming to see the enthusiasm for web2py in the large
number of logo submissions. Congrats to all for their efforts and may
the best logo win!


[web2py] Re: dealing with extra clicks on a link

2010-10-19 Thread meland
Hi Alex,

Thanks for your suggestions.  I was hoping to make this app work
without resorting to client-side code mostly because I'm already
behind schedule and getting up to speed with even simple jQuery will
take time.  But if I'm not able to resolve the current issue with
web2py/Python on the server-side, then I will step back and take the
client-side approach.

Cheers!

On Oct 15, 1:13 pm, Alex  wrote:
> Hello,
>
> I was going to do something similar with some 2 players games (which I
> have yet to implement), but was planning on doing the polling on the
> client-side with Javascript and AJAX.
>
> There is a function in Javascript:
>    window.setTimeout(jsFunctionToRun, timeToRunInMilliseconds);
>
> That can be called to force the page to call the passed in JS function
> after timeToRunInMilliseconds.  What I am planning on doing is having
> my JSFunctionToRun be a function that makes an AJAX call (which will
> call something to check the database) and gets the state of the game.
> Then based on the state I get back, I'll do what I need on the
> callback.  The framework would look something like:
>
> setTimeout("CheckState()", 5000)  //Call JS Function CheckState() @ 5
> seconds
>
> function CheckState()
> {
>   //Make AJAX call to function that will check and get the state value
> from the DB
>   //Callback function:  ProcessState()
>
> }
>
> function ProcessState()
> {
>   //IF the db state says it's my turn, do code to make it my turn,
> call setTimeoutAgain after I take my turn to get back in the polling
> status
>   //ELSE  call setTimeout("CheckState", 5000) to check if it's my turn
> again in 5 seconds
>
> }
>
> I hope something like this helps :)
>
> On Oct 15, 12:01 pm, meland  wrote:
>
>
>
> > Hello,
>
> > First, I would appreciate if anyone can help with this issue I'm
> > facing.  Second, I am new to web2py, and not a programmer by
> > profession.  I have written an application for conducting tournaments
> > with the ultimatum game - a simple bargaining game.  The problem: it
> > seems to work fine running on my personal machine via localhost, but
> > when hosted (WebFaction) the application locks up if a particular link
> > is clicked more than once.
>
> > The details... one player must wait for information from another
> > player.  I'm using a database poll as a means for the waiting player
> > to know when information is available.  While the polling takes place,
> > the player's view is still presenting an active link.  Clicking this
> > link more than once causes a problem.  As I mentioned above, the
> > server-side pattern I've implemented works when running locally, but
> > seems to fail in a hosted situation.  Oh, since I'm less familiar with
> > javascript than Python I was trying for a server-side solution.  I
> > have started reading about jQuery but have not yet been able to
> > get .one() working to prevent extra clicks.  Thank you in advance!
>
> > The relevant code...
>
> > The view and controller function from which the player clicks to begin
> > the database poll...
>
> > def responder_enter_game():
> >     """
> >     The point at which the responder enters the game.
> >     The view will hang on this page as the database polling is
> > processed in
> >     the next page called from the view.
> >     Prior to calling this function, session.first_time must be set to
> > True!
> >     """
> >     return dict()
>
> > Note: I using the default layout.html
>
> > {{extend 'layout.html'}}
> > You are playing as a responder in this game...
> > 
> >   {{=A(B(T("Click to enter game")), _href=URL('responder_waits'))}}
> > 
> >   {{=T('Please be patient...')}}
> >   {{=T('You will leave this page after a proposal has been
> > offered.')}}
> > 
>
> > {{extend 'layout.html'}}
> > Waiting for a response... please be patient
> > {{redirect(URL('game_results_proposer'))}}
>
> > Here is the controller code for responder_waits...
>
> > def check_proposal_confirmed():
> >     """
> >     The resopnder's view is hanging on respnder_enters_game() until
> > proposal_confirmed is True.
> >     The function time.sleep(0.5) causes a 0.5 second delay between
> >     polls on the database.
> >     """
> >     proposal_confirmed = False
>
> >     while not proposal_confirmed:
> >         proposal_confirmed =
> > db.games[session.game_id].proposal_confirmed
> >         time.sleep(0.5)
>
> > def responder_waits():
> >     """
> >     The responder is waiting for a proposal confirmation to be found
> > in the database
> >     """
> >     if session.first_time:                  ## The first time the
> > player clicks the link processing continues
> >         session.first_time = False      ## The first time has passed
> >         check_proposal_confirmed()   ## This function holds until the
> > proposer confirms a proposal
> >     else:                                         ## Any additional
> > time the player clicks the link no action is taken
> >         pass
>
> >     return dict()


[web2py] Local date format in INPUT tag

2010-10-19 Thread Mirek Zvolský
Hi,
I'm new in web2py (and web programming at all).

Can anybody help me, how should I display dates in  (I want use
SQLFORM())?

At this time I see 2010-10-19 and same I receive from javascript
calendar.

However proper local setting for our country is 19.10.2010 and of
course users want to see this that way in the web form.

What I should do in model?

And more...
If I translate the application to the language wit same date format
dd.mm., there is no additional problem. But if the country uses
different date format, I think formatting cannot be made in model.
Is there a property of T() object, where formatting can be set (and
changed based on current language).

I'm sorry for the basic question, however I cannot find the answer
here in user group messages nor in web2py book.
Thanks, Mirek


[web2py] Re: What is default or best datagrid? Webgrid or Jqgrid?

2010-10-19 Thread mr.freeze
I would say jqGrid is definitely better.  I wrote WebGrid because I
needed something that didn't require javascript.  jqGrid has more
features, an excellent API and is better supported.


On Oct 19, 6:37 am, Savio Sabino  wrote:
> Hi.
> What is best choose to use datagrid in web2py? Webgrid or jqgrid?
> What the comparision be do with this tools?
> Or is the best use the two to interoperate? If is this, how?


[web2py] Re: Who made this? It is great!

2010-10-19 Thread mdipierro
I made some improvements

On Oct 19, 9:08 am, Jason Brower  wrote:
> FUN!  I think this is something more people can contribute to as it's
> higherlevel then the server/framework.
> BR,
> Jason
>
> On Tue, 2010-10-19 at 05:41 -0700, mdipierro wrote:
> > I am stealing this idea. In trunk:
>
> > /admin/widget
>
> > It is a work in progress so not everything works yet.
>
> > On Oct 17, 4:14 pm, mdipierro  wrote:
> > >http://vimeo.com/15886413
>
> > > I can see lots of uses for it.
>
> > > I have some questions: does it store meta-info in the db? Or does it
> > > uses something like YAML? Where can we get it?
>
> > > Some suggestions for improvement:
> > > - a checkbox for [use auth]
> > > - allow adding fields for auth_user
> > > - have a checkbox [use janrain] and seup janrain key/domain
> > > - use the same interface that you use to create tables to create
> > > controller actions (even if initially empty) (perhaps allows adding
> > > widgets from plugin_wiki)
> > > - It would be nice to have a way to display graphically the structure
> > > of an app as a tree. Two main branches: tables, pages
> > > - merge withhttp://web2py.com/layouts/plugin_layouts/index(perhaps
> > > just pick best layouts)
>
>


Re: [web2py] Re: Who made this? It is great!

2010-10-19 Thread Jason Brower
FUN!  I think this is something more people can contribute to as it's
higherlevel then the server/framework.
BR,
Jason

On Tue, 2010-10-19 at 05:41 -0700, mdipierro wrote: 
> I am stealing this idea. In trunk:
> 
> /admin/widget
> 
> It is a work in progress so not everything works yet.
> 
> On Oct 17, 4:14 pm, mdipierro  wrote:
> > http://vimeo.com/15886413
> >
> > I can see lots of uses for it.
> >
> > I have some questions: does it store meta-info in the db? Or does it
> > uses something like YAML? Where can we get it?
> >
> > Some suggestions for improvement:
> > - a checkbox for [use auth]
> > - allow adding fields for auth_user
> > - have a checkbox [use janrain] and seup janrain key/domain
> > - use the same interface that you use to create tables to create
> > controller actions (even if initially empty) (perhaps allows adding
> > widgets from plugin_wiki)
> > - It would be nice to have a way to display graphically the structure
> > of an app as a tree. Two main branches: tables, pages
> > - merge withhttp://web2py.com/layouts/plugin_layouts/index(perhaps
> > just pick best layouts)




[web2py] Re: question re form processing via ajax

2010-10-19 Thread weheh
Thanks Bruno, I'll check it out. Seems like it should work. - Richard

On Oct 19, 12:48 am, Bruno Rocha  wrote:
> I tried here, and you can use FORM()
>
> If your raw html is  name='bar'>
>
> you need index to:
>
> form=FORM(INPUT(_name='bar',_type='text',requires=IS_NOT_EMPTY(error_message='it
> is empty')))
> errors=form.errors
> if form.accepts(request.vars,session=None,formname='foo'):
>           redirect(URL(r=request, f='index'))
> elif form.errors:
>           return dict(errors=form.errors)
> return dict(errors=errors)
>
> The same as SQLFORM.factory, but this is pure HTML.
>
> 2010/10/19 Bruno Rocha 
>
>
>
> > Not sure, but I think you need to specify a form object in order to use
> > .accepts to validate
>
> > from the book:
> > All the work is done by the accepts method of the form object. It filters
> > the request.varsaccording to the declared requirements (expressed by
> > validators). accepts stores those variables that pass validation into
> > form.vars. If a field value does not meet a requirement, the failing
> > validator returns an error and the error is stored in form.errors. Both
> > form.vars andform.errors are gluon.storage.Storage objects similar to
> > request.vars.
>
> > So:
>
> > You can try to create a form object using
>
> > form = SQLFORM .factory
>
> > But, this form created by .factory needs to have the same model as the one
> > you created in raw html.
>
> > you can try to loop the request.vars to build a instance of form object
> > with the validators that you want, then you will be able to use .accepts()
>
> > I am really not sure, But by now, I think it is the only way.
>
> > 2010/10/19 Bruno Rocha 
>
> > What is the name of the form, really?
>
> >> Which one you specified in  does not works?
>
> >> 2010/10/19 weheh 
>
> >> If I build a form comprising a few raw html input fields and then use
> >>> ajax to submit them, their values end up in request.vars. Now, I would
> >>> like to use my_html_form.accepts(...) to process the contents, but is
> >>> that possible? What is the name of the form, really?
>
> >> --
>
> >>http://rochacbruno.com.br
>
> > --
>
> >http://rochacbruno.com.br
>
> --
>
> http://rochacbruno.com.br


[web2py] Re: Using upload fixtures in GAE

2010-10-19 Thread Wikus van de Merwe
This is not really web2py related question. You can use either the GAE
Bulk Loader:
http://code.google.com/appengine/docs/python/tools/uploadingdata.html
or the remote API directly:
http://stackoverflow.com/questions/774265/how-do-i-bulkupload-image-blobs-in-google-app-engine

Alternatively you may decide to store just the paths to images which
you upload to GAE as static data.


[web2py] Re: Who made this? It is great!

2010-10-19 Thread mdipierro
I am stealing this idea. In trunk:

/admin/widget

It is a work in progress so not everything works yet.

On Oct 17, 4:14 pm, mdipierro  wrote:
> http://vimeo.com/15886413
>
> I can see lots of uses for it.
>
> I have some questions: does it store meta-info in the db? Or does it
> uses something like YAML? Where can we get it?
>
> Some suggestions for improvement:
> - a checkbox for [use auth]
> - allow adding fields for auth_user
> - have a checkbox [use janrain] and seup janrain key/domain
> - use the same interface that you use to create tables to create
> controller actions (even if initially empty) (perhaps allows adding
> widgets from plugin_wiki)
> - It would be nice to have a way to display graphically the structure
> of an app as a tree. Two main branches: tables, pages
> - merge withhttp://web2py.com/layouts/plugin_layouts/index(perhaps
> just pick best layouts)


[web2py] Re: Who made this? It is great!

2010-10-19 Thread Mirek Zvolský
The idea write a meta-app is really great. And web2py could be great
tool for it.

However, I think, generate individual code for "dogs", "cats",.. is
not good way.
Much better direction is create common classes or common code, where
will be one controller, one/two views with meta-names of tables,
fields,..; something like db().select(db.eval(tablename).ALL)

Because in first case we have lot of kB of generated code, which we
cannot touch and edit, but in the second case we can inherit the
classes and make something special, where we need it.





On 18 říj, 04:55, Bruno Rocha  wrote:
> That could be a good start to a Killer CMS built with WEB2PY.
>
> I think he uses YAML to generate the models, but I am going to check with
> him, and try to get the source.
>
> 2010/10/17 mdipierro 
>
>
>
>
>
> >http://vimeo.com/15886413
>
> > I can see lots of uses for it.
>
> > I have some questions: does it store meta-info in the db? Or does it
> > uses something like YAML? Where can we get it?
>
> > Some suggestions for improvement:
> > - a checkbox for [use auth]
> > - allow adding fields for auth_user
> > - have a checkbox [use janrain] and seup janrain key/domain
> > - use the same interface that you use to create tables to create
> > controller actions (even if initially empty) (perhaps allows adding
> > widgets from plugin_wiki)
> > - It would be nice to have a way to display graphically the structure
> > of an app as a tree. Two main branches: tables, pages
> > - merge withhttp://web2py.com/layouts/plugin_layouts/index(perhaps
> > just pick best layouts)
>
> --
>
> http://rochacbruno.com.br


[web2py] Re: PyScripter is nice Python IDE for Windows ....

2010-10-19 Thread DenesL

Thank you cjrh.

What do you mean by "refresh your browser"?
aren't you using the pyscripter built-in editor?.

Have you used it to debug a running web2py app?.

Denes.

On Oct 19, 2:06 am, cjrh  wrote:
> On Oct 19, 2:37 am, DenesL  wrote:
>
> > Looks good. Thanks.
> > Any tips on using it with web2py?.
>
> Not much.  Edit your files.   You get code-completion and method
> argument "intellisense" for Python built-ins as well as your own code
> in the same file.  As you edit, refresh your browser and the changes
> happen immediately, because web2py is awesome.   The embedded
> interpreter is useful for testing.   There are some project-management
> capabilities, so you can work with multiple files easily.    You can
> also switch between different python versions in the interpreter, e.g.
> for testing whether syntax works properly in older versions.
>
> Nothing too complicated, simple, fast, works.


[web2py] Re: TypeError: slice indices must be integers or None or have an __index__ method

2010-10-19 Thread DenesL
Hi Annet,

the error is in the first line

Field('inschrijving',length='36',...

should be

Field('inschrijving',length=36,...

Denes


On Oct 19, 8:07 am, annet  wrote:
> I defined the following table:
>
> db.define_table('applicationform',
>
> Field('inschrijving',length='36',default='',notnull=True,ondelete='RESTRICT'),
>     Field('bedrijfsnaam',length=54,default='',notnull=True),
>     Field('kvk_nummer',length=8),
>     Field('subdossiernummer',length=4,default=''),
>     Field('rechtsvorm',default='',notnull=True),
>     Field('straat',length=42,default='',notnull=True),
>     Field('huisnummer',length=9,default='',notnull=True),
>     Field('huisnummerextensie',length=6),
>     Field('postcode',length=7,default='',notnull=True),
>     Field('plaats',length=42,default='',notnull=True),
>     Field('telefoonnummer',length=72),
>     Field('faxnummer',length=72),
>     Field('mobielnummer',length=72),
>     Field('email',length=72),
>     Field('website',length=72),
>     Field('aanhef'),
>     Field('first_name',length=24),
>     Field('last_name',length=42,default='',notnull=True),
>     Field('email_persoon',length=72,default='',notnull=True),
>     Field('application',length=24,writable=False,readable=False),
>     Field('created_on',type='datetime',writable=False,readable=False),
>
> Field('modified_on',type='datetime',writable=False,readable=False),
>     Field('replied_on',type='datetime',writable=False,readable=False),
>     migrate=False)
>
> db.applicationform.inschrijving.requires=IS_IN_DB(db,db.inschrijving.inschrijving,'%
> (inschrijving)s',zero=None)
> db.applicationform.bedrijfsnaam.requires=[IS_LENGTH(54,error_message='lengte
> overschreidt 54 tekens'),IS_NOT_EMPTY()]
> db.applicationform.bedrijfsnaam.label='Bedrijfsnaam * '
> db.applicationform.kvk_nummer.requires=[IS_MATCH('\d{8}',error_message='geen
> match 8 cijfers'),IS_NOT_EMPTY()]
> db.applicationform.kvk_nummer.label='Kvk-nummer * '
> db.applicationform.subdossiernummer.requires=[IS_MATCH('\d{4}',error_message='geen
> match 4 cijfers'),IS_NOT_EMPTY()]
> db.applicationform.subdossiernummer.default=''
> db.applicationform.subdossiernummer.label='Subdossiernummer * '
> db.applicationform.rechtsvorm.requires=IS_IN_DB(db,db.rechtsvorm.rechtsvorm,'%
> (rechtsvorm)s',zero=None)
> db.applicationform.rechtsvorm.default='Onbekend'
> db.applicationform.straat.requires=[IS_LENGTH(42,error_message='lengte
> overschreidt 42 tekens'),IS_NOT_EMPTY()]
> db.applicationform.straat.label='Straat * '
> db.applicationform.huisnummer.requires=[IS_LENGTH(9,error_message='lengte
> overschreidt 9 tekens'),IS_NOT_EMPTY()]
> db.applicationform.huisnummer.label='Huisnummer * '
> db.applicationform.huisnummerextensie.requires=IS_LENGTH(6,error_message='length
> overschreidt 6 tekens')
> db.applicationform.postcode.requires=[IS_LENGTH(7,error_message='length
> overschreidt 7 tekens'),IS_NOT_EMPTY()]
> db.applicationform.plaats.requires=[IS_IN_DB(db,db.plaats.plaats,'%
> (plaats)s')]
> db.applicationform.plaats.widget=SQLFORM.widgets.autocomplete(request,db.plaats.plaats,min_length=2)
> db.applicationform.plaats.label='Plaats * '
> db.applicationform.telefoonnummer.requires=IS_LENGTH(72,error_message='lengte
> overschreidt 72 tekens')
> db.applicationform.faxnummer.requires=IS_LENGTH(72,error_message='lengte
> overschreidt 72 tekens')
> db.applicationform.mobielnummer.requires=IS_LENGTH(72,error_message='lengte
> overschreidt 72 tekens')
> db.applicationform.email.requires=[IS_LENGTH(72,error_message='lengte
> overschreidt 72 tekens'), IS_NULL_OR(IS_EMAIL())]
> db.applicationform.email.label='E-mail'
> db.applicationform.website.requires=IS_LENGTH(72,error_message='lengte
> overschreidt 72 tekens')
> db.applicationform.website.label='Web site'
> db.applicationform.aanhef.requires=IS_IN_SET(['de
> heer','mevrouw'],zero=None)
> db.applicationform.first_name.requires=IS_LENGTH(24,error_message='lengte
> overschreidt 24 tekens')
> db.applicationform.first_name.label='Voornaam'
> db.applicationform.last_name.requires=[IS_LENGTH(42,error_message='lengte
> overschreidt 42 tekens'),IS_NOT_EMPTY()]
> db.applicationform.last_name.label='Achternaam * '
> db.applicationform.email_persoon.requires=[IS_LENGTH(72,error_message='lengte
> overschreidt 72 tekens'), IS_EMAIL(), IS_NOT_EMPTY()]
> db.applicationform.email_persoon.label='E-mail * '
> db.applicationform.application.requires=IS_LENGTH(24,error_message='lengte
> overschreidt 24 tekens')
> db.applicationform.created_on.default=request.now
> db.applicationform.modified_on.default=request.now
> db.applicationform.modified_on.update=request.now
> db.applicationform.replied_on.default=''
>
> In this function I expose the form:
>
> def application_form():
>     if not len(request.args):
>         redirect(URL(r=request,c='default',f='error'))
>     else:
>         response.functionname='Aanmeldingsformulier'
>         db.applicationform.application.default=request.args(0)
>         form=SQLFORM(db.applicationform)

[web2py] Re: page redirect

2010-10-19 Thread b0j3
Haha, Seems I forgot to add http://.
It works. Thanks.

Boštjan

On Oct 14, 4:17 pm, mdipierro  wrote:
> you an redirect anywhere with
>
> redirect('http://www.there.com')
>
> or internal URLs with
>
> redirect(URL('controller','function',args=[],vars=dict()))
>
> On Oct 14, 7:23 am,b0j3 wrote:
>
> > Hi!
>
> > I need to open an URL from the controller, but the URL is not part of
> > the domain where web2py runs.
> > So what I would like is Redirect to work on the other URL e.g. my
> > domain iswww.home.com, but I'd like redirect to go towww.there.com.
> > Can that be done?
>
> > Thanks,
>
> > B.
>
>


[web2py] What is default or best datagrid? Webgrid or Jqgrid?

2010-10-19 Thread Savio Sabino
Hi.
What is best choose to use datagrid in web2py? Webgrid or jqgrid?
What the comparision be do with this tools?
Or is the best use the two to interoperate? If is this, how?


[web2py] TypeError: slice indices must be integers or None or have an __index__ method

2010-10-19 Thread annet
I defined the following table:

db.define_table('applicationform',
 
Field('inschrijving',length='36',default='',notnull=True,ondelete='RESTRICT'),
Field('bedrijfsnaam',length=54,default='',notnull=True),
Field('kvk_nummer',length=8),
Field('subdossiernummer',length=4,default=''),
Field('rechtsvorm',default='',notnull=True),
Field('straat',length=42,default='',notnull=True),
Field('huisnummer',length=9,default='',notnull=True),
Field('huisnummerextensie',length=6),
Field('postcode',length=7,default='',notnull=True),
Field('plaats',length=42,default='',notnull=True),
Field('telefoonnummer',length=72),
Field('faxnummer',length=72),
Field('mobielnummer',length=72),
Field('email',length=72),
Field('website',length=72),
Field('aanhef'),
Field('first_name',length=24),
Field('last_name',length=42,default='',notnull=True),
Field('email_persoon',length=72,default='',notnull=True),
Field('application',length=24,writable=False,readable=False),
Field('created_on',type='datetime',writable=False,readable=False),
 
Field('modified_on',type='datetime',writable=False,readable=False),
Field('replied_on',type='datetime',writable=False,readable=False),
migrate=False)

db.applicationform.inschrijving.requires=IS_IN_DB(db,db.inschrijving.inschrijving,'%
(inschrijving)s',zero=None)
db.applicationform.bedrijfsnaam.requires=[IS_LENGTH(54,error_message='lengte
overschreidt 54 tekens'),IS_NOT_EMPTY()]
db.applicationform.bedrijfsnaam.label='Bedrijfsnaam * '
db.applicationform.kvk_nummer.requires=[IS_MATCH('\d{8}',error_message='geen
match 8 cijfers'),IS_NOT_EMPTY()]
db.applicationform.kvk_nummer.label='Kvk-nummer * '
db.applicationform.subdossiernummer.requires=[IS_MATCH('\d{4}',error_message='geen
match 4 cijfers'),IS_NOT_EMPTY()]
db.applicationform.subdossiernummer.default=''
db.applicationform.subdossiernummer.label='Subdossiernummer * '
db.applicationform.rechtsvorm.requires=IS_IN_DB(db,db.rechtsvorm.rechtsvorm,'%
(rechtsvorm)s',zero=None)
db.applicationform.rechtsvorm.default='Onbekend'
db.applicationform.straat.requires=[IS_LENGTH(42,error_message='lengte
overschreidt 42 tekens'),IS_NOT_EMPTY()]
db.applicationform.straat.label='Straat * '
db.applicationform.huisnummer.requires=[IS_LENGTH(9,error_message='lengte
overschreidt 9 tekens'),IS_NOT_EMPTY()]
db.applicationform.huisnummer.label='Huisnummer * '
db.applicationform.huisnummerextensie.requires=IS_LENGTH(6,error_message='length
overschreidt 6 tekens')
db.applicationform.postcode.requires=[IS_LENGTH(7,error_message='length
overschreidt 7 tekens'),IS_NOT_EMPTY()]
db.applicationform.plaats.requires=[IS_IN_DB(db,db.plaats.plaats,'%
(plaats)s')]
db.applicationform.plaats.widget=SQLFORM.widgets.autocomplete(request,db.plaats.plaats,min_length=2)
db.applicationform.plaats.label='Plaats * '
db.applicationform.telefoonnummer.requires=IS_LENGTH(72,error_message='lengte
overschreidt 72 tekens')
db.applicationform.faxnummer.requires=IS_LENGTH(72,error_message='lengte
overschreidt 72 tekens')
db.applicationform.mobielnummer.requires=IS_LENGTH(72,error_message='lengte
overschreidt 72 tekens')
db.applicationform.email.requires=[IS_LENGTH(72,error_message='lengte
overschreidt 72 tekens'), IS_NULL_OR(IS_EMAIL())]
db.applicationform.email.label='E-mail'
db.applicationform.website.requires=IS_LENGTH(72,error_message='lengte
overschreidt 72 tekens')
db.applicationform.website.label='Web site'
db.applicationform.aanhef.requires=IS_IN_SET(['de
heer','mevrouw'],zero=None)
db.applicationform.first_name.requires=IS_LENGTH(24,error_message='lengte
overschreidt 24 tekens')
db.applicationform.first_name.label='Voornaam'
db.applicationform.last_name.requires=[IS_LENGTH(42,error_message='lengte
overschreidt 42 tekens'),IS_NOT_EMPTY()]
db.applicationform.last_name.label='Achternaam * '
db.applicationform.email_persoon.requires=[IS_LENGTH(72,error_message='lengte
overschreidt 72 tekens'), IS_EMAIL(), IS_NOT_EMPTY()]
db.applicationform.email_persoon.label='E-mail * '
db.applicationform.application.requires=IS_LENGTH(24,error_message='lengte
overschreidt 24 tekens')
db.applicationform.created_on.default=request.now
db.applicationform.modified_on.default=request.now
db.applicationform.modified_on.update=request.now
db.applicationform.replied_on.default=''




In this function I expose the form:

def application_form():
if not len(request.args):
redirect(URL(r=request,c='default',f='error'))
else:
response.functionname='Aanmeldingsformulier'
db.applicationform.application.default=request.args(0)
form=SQLFORM(db.applicationform)
form[0].insert(0,TR(H4('Bedrijfsgegevens:')))
form[0].insert(5,TR(H4('Adresgegevens:')))
form[0].insert(11,TR(H4('Communicatiegegevens:')))
form[0].insert(17,TR(H4('Contactpersoon:')))
form[0][-1][1].append(INPUT(_type='reset',_value='Reset'))
if form.accepts(request.vars,session):
response.fla

[web2py] Re: tip of the day. The power of routes

2010-10-19 Thread Martin.Mulone
Great tip!. This is very usefull! and you make it in trunk :D

On 17 oct, 23:03, mdipierro  wrote:
> Replace your web2py/routes.py with this:
>
> - begin routes.py---
> try: config=open('routes.conf','r').read()
> except: config=''
> def auto_in(apps):
>     routes=[
>         ('/robots.txt','/welcome/static/robots.txt'),
>         ('/favicon.ico','/welcome/static/favicon.ico'),
>         ('/admin$a','/admin$a'),
>         ]
>     for a,b in [x.strip().split() for x in apps.split('\n') \
>         if x.strip() and not x.strip().startswith('#')]:
>         if not b.startswith('/'): b='/'+b
>         if b.endswith('/'): b=b[:-1]
>         app = b.split('/')[1]
>         routes+=[
>             ('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b),
>             ('.*:https?://(.*\.)?%s:$method /static/$a' % a,'%s/static/
> $a' % app),
>             ('.*:https?://(.*\.)?%s:$method /appadmin/$a' % a,'%s/
> appadmin/$a' % app),
>             ('.*:https?://(.*\.)?%s:$method /$a' % a,'%s/$a' % b),
>             ]
>     return routes
>
> def auto_out(apps):
>     routes=[]
>     for a,b in [x.strip().split() for x in apps.split('\n') \
>         if x.strip() and not x.strip().startswith('#')]:
>         if not b.startswith('/'): b='/'+b
>         if b.endswith('/'): b=b[:-1]
>         app = b.split('/')[1]
>         routes+=[
>             ('%s/static/$a' % app,'static/$a'),
>             ('%s/appadmin/$a' % app, '/appadmin/$a'),
>             ('%s/$a' % b, '/$a'),
>             ]
>     return routes
>
> routes_in=auto_in(config)
> routes_out=auto_out(config)
> --- END ---
>
> what does it do? It writes routes for you based on a simpler routing
> configuration file called routes.conf. here is an example:
>
> - BEGIN routes.conf---
> 127.0.0.1       /examples/default
> domain1.com /app1/default
> domain2.com /app2/default
> domain3.com /app3/default
> - END --
>
> It maps a domain (the left had side) into an app and it shortens the
> URLs for the app, by removing the listed path prefix. That means
>
> http://domain1.com/indexwill be mapped into  
> /app1/default/indexhttp://domain2.com/indexwill be mapped into  
> /app2/default/index
>
> It is safe in that it preserves admin, appadmin, static files,
> favicon.ico and robots.txt.
>
> http://domain1.com/favicon.icohttp://domain1.com/robots.txthttp://domain1.com/admin/...
>    /admin/...http://domain1.com/appadmin/...  
> /app1/appadmin/...http://domain1.com/static/...  /app1/static/...
>
> and vice-versa.
>
> It does assume one app per domain.
>
> I think something like this should be default since lots of people
> find routes.py hard to work with.
> Comments? Suggestions?
>
> Massimo


[web2py] Re: Instant Press in beta

2010-10-19 Thread Martin.Mulone
> Martin, a suggestion is to include the option of writing in Markmin format.

Ok I believe this not hard to implement

> Do you have a clone in BitBicket or Mercurial in Google ?

I'm planning to move to bitbucket.

> Opening and closing all those admin panels takes a lot of mouse work

I'm going to see, I don't know anything about events keys in js

>- I saw you can change the CSS. Can you also embed additional
JavaScript?

Not at this moment but its easy to implement, do you think that this
is usefull?

>- How would you recommend adding extensions, such as a contact form?

I dont think about that yet, but it can be future feature. It's not
hard to implement, the problem is design problem of putting another
action in article list :p.