[web2py] Open menu item in new window.

2010-06-26 Thread annet
In a view I have the following link which opens in a new window:

{{=A('Contact
form',_href=URL(r=request,a='utilities',c='forms',f='contact_form',args='init'),_target='_blank')}}


In a menu I have a menu item which references the same function:

['Contact
form',request.function=='contact_form',URL(r=request,a='utilities',c='forms',f='contact_form',args='init')]]


To keep their behaviour consistent I would like to open the menu item
in a new window also, is that possible?


Kind regards,

Annet.


Re: [web2py] Re: Anvanced applications in gae

2010-06-26 Thread Carles Gonzalez
Very interesting, i didn't know about collection_name and the associated query.

You are shedding some light on doing relationships the GAE way.

Thanks again.

On Sat, Jun 26, 2010 at 8:52 AM, dlypka  wrote:
>
> For starters:
>
> Refer to
> http://arbingersys.blogspot.com/2008/04/google-app-engine-one-to-many-join_26.html?showComment=1244344382942#c5661660955046324965
>
> And Here is the posting about using native GAE properties
>
> http://groups.google.com/group/web2py/browse_thread/thread/7112ef7dee1ccf32/d2b0d24c0e499924?lnk=gst&q=native#d2b0d24c0e499924
>
> So for example you would do
>
> from gluon.contrib.gql import gae
> :
> :
>   db.define_table('ChildItem',
>                                # NOTE: web2py provides the 'id'
> column automatically
>                               db.Field('idParentFolder','reference
> MyParent'),
>                               db.Field('name','text'),
>                               db.Field('gaeParentInstance',
> gae.ReferenceProperty(MyParent,
>                                              required=False,
> collection_name='linksFromChildItemToParent')))
>
>                           )
>
> and define the parent class in a similar fashion.
>
> It is also necessary to add some plumbing to find and track the native
> GAE references
> which lie underneath the web2py sql objects because the native refs
> have to be
> put into the collections.
>
> I'll provide more details in some followup posts.
>
> On Jun 25, 2:48 pm, Carles  wrote:
>> Thanks a lot Dave.
>>
>> There isn't a deadline, tale your time :)
>>
>> Carles
>>
>> El 25/06/2010, a las 20:42, dlypka  escribió:
>>
>>
>>
>> > OK will do - please give me a few days...
>>
>> > On Jun 24, 8:43 pm, Carles Gonzalez  wrote:
>> >> Not to be annoying, but can you post an example?
>>
>> >> Just to organize the things in my head...
>>
>> >> Thanks again.
>>
>> >> On Fri, Jun 25, 2010 at 2:41 AM, Carles Gonzalez  
>> >> wrote:
>> >>> Very interesting!
>>
>> >>> I'll try tomorrow.
>>
>> >>> Thanks a lot, Dave.
>>
>> >>> On Fri, Jun 25, 2010 at 1:21 AM, dlypka  wrote:
>>  I've done a parent - to - many child GAE / web2py implementation using
>>  SelfReference  fields (or you can use Reference as well) using the
>>  technique for adding native GAE fields into a web2py table definition.
>>
>>  It gives fantastic retrieval performance because GAE automatically
>>  adds the link from the child back into the parent's reference list
>>  at the time you create each child.   When you later query for the
>>  parent, voila GAE retrieves all the child entities along with it in
>>  one backend call!
>>
>>  Hopefully this technique is relevant to your application.
>>
>>  I also develop some other tricks for inheriting native GAE classes
>>  into your web2py model, though
>>  this is less attractive perhaps now that GAE native properties can be
>>  directly declared in web2py tables.
>>
>>  - Dave Lypka.
>>
>>  On Jun 21, 10:25 am, Carles Gonzalez  wrote:
>> > Hi,
>>
>> > I have developed some applications in web2py, and 2 are running
>> > currently in gae, but now i have serious problem.
>>
>> > My current project is a social application, and when i design
>> > (example) the tables to make an user follow the actions other user
>> > (twitter like) I find that many-to-many relationships in app-engine
>> > are not easily supported.
>>
>> > From my understanding using the tools present in web2py right i would
>> > need to do a lot of processing in memory, an that would hurt
>> > performance greatly.
>>
>> > The pattern proposed by app store developers uses lists and "parent"
>> > relationship:
>>
>> > class Message(db.Model):
>> >     sender = db.StringProperty()
>> >     body = db.TextProperty()
>>
>> > class MessageIndex(db.Model):
>> >     receivers = db.StringListProperty()
>>
>> > indexes = MessageIndex.all(keys_only = True).filter('receivers = ', 
>> > user_id)
>> > keys = [k.parent() for k in indexes)
>> > messages = db.get(keys)
>>
>> > For using that pattern in web2py I would need a method for specifying
>> > the parent of a model instance. Can I specify that relationship using
>> > any method I don't know? If not, would it be hard to implement?
>>
>> > Thanks in advance!


[web2py] Re: WordPressClone/PyPress GAE fix

2010-06-26 Thread mdmcginn
molhokwai, note that we have both filed issues at Google Code, but we
shouldn't have. The pp4gae project has moved to Github: 
http://github.com/zrenx/pp4gae

On Jun 22, 10:38 am, molhokwai  wrote:
> A reply to the message I saw while in a google search for "pypress"...
> Saw it on osdir.com (I'm sent in a redirection loop when I try to access the
> web2py-users group).
>
> Arghh... would have eventually saved me time if I had found out about the
> pypress for gae project...
> But we can merge and have an even better app (if there is anything
> interesting to merge, from my code)...
>
> Voilà.
> --
> *M*ayou *N*kensa *P*enda *N*gué -*H*ervé
> +32 489 33 71 
> 51,molhok...@gmail.com,skype:molhokwaihttp://www.google.com/profiles/molhokwai
>
>
>
> On Tue, Jun 15, 2010 at 11:12 AM, molhokwai  wrote:
> > Hello there...
>
> > Implemented fixes to run PyPress on GAE 
> > (Seehttp://www.molhokwai.net/blogforhow it's working...).
> > Code fixes attached, and complete .w2p app also.
>
> > Thanks all.


[web2py] Re: WordPressClone/PyPress GAE fix

2010-06-26 Thread mdmcginn
Correction: the owner of pp4gae has just contacted me, saying he has
"stopped working on this project since last update" and has given up
on further work. Too bad. I have cloned the project at
http://github.com/mdmcginn/pp4gae/ and have asked him if he could make
me the owner of his Google Code project. Not that I know what I'm
doing, but I could add competent coders as owners and could continue
the project that way. Unless someone plans to release the blog code
from KPAX soon...

On Jun 26, 5:32 am, mdmcginn  wrote:
> molhokwai, note that we have both filed issues at Google Code, but we
> shouldn't have. The pp4gae project has moved to 
> Github:http://github.com/zrenx/pp4gae
>
> On Jun 22, 10:38 am, molhokwai  wrote:
>
>
>
> > A reply to the message I saw while in a google search for "pypress"...
> > Saw it on osdir.com (I'm sent in a redirection loop when I try to access the
> > web2py-users group).
>
> > Arghh... would have eventually saved me time if I had found out about the
> >pypressfor gae project...
> > But we can merge and have an even better app (if there is anything
> > interesting to merge, from my code)...
>
> > Voilà.
> > --
> > *M*ayou *N*kensa *P*enda *N*gué -*H*ervé
> > +32 489 33 71 
> > 51,molhok...@gmail.com,skype:molhokwaihttp://www.google.com/profiles/molhokwai
>
> > On Tue, Jun 15, 2010 at 11:12 AM, molhokwai  wrote:
> > > Hello there...
>
> > > Implemented fixes to runPyPresson GAE 
> > > (Seehttp://www.molhokwai.net/blogforhowit's working...).
> > > Code fixes attached, and complete .w2p app also.
>
> > > Thanks all.


[web2py] the best place to define custom widgets + extra info for widget

2010-06-26 Thread Jurgis Pralgauskis
Hello,


I found an example http://www.web2py.com/AlterEgo/default/show/170
and also studiet widgets in gluon.sqlforms a bit

1)
now I make a separate file in /models
probably I could make it in /modules
but I need to make extra query to db in this widget



2)
 I want the options to be presented in hierarchical order
 like http://www.html-tags-guide.com/html-optgroup-tag.html
(as I have  tree structure for my topics in my system),
 the info about hierarchy is not present in "requires"
what   would be the best way to give this info to widget
coud I make custom requires instruction?


Thanks in advance :)
-- 
Jurgis


[web2py] Re: WordPressClone/PyPress GAE fix

2010-06-26 Thread mdmcginn
I deployed Pypress (based on Wordpress Clone) for Google App Engine at
http://writers-ear.appspot.com/earblog/ but it's still horribly slow:
06-26 06:27AM 23.966 /earblog 200 5275ms 661cpu_ms 467api_cpu_ms 2kb

Any suggestions, or should I try another GAE blog solution?

I'm now an owner of http://code.google.com/p/pypress4gae/ and
http://github.com/mdmcginn/pp4gae, so if anybody else wants to work on
this project, contact me. I've made it more compatible with the latest
Wordpress theme (http://2010dev.wordpress.com/) but I won't continue
if it can't be sped up.

On Jun 26, 6:47 am, mdmcginn  wrote:
> Correction: the owner of pp4gae has just contacted me, saying he has
> "stopped working on this project since last update" and has given up
> on further work. Too bad. I have cloned the project 
> athttp://github.com/mdmcginn/pp4gae/and have asked him if he could make
> me the owner of his Google Code project. Not that I know what I'm
> doing, but I could add competent coders as owners and could continue
> the project that way. Unless someone plans to release the blog code
> from KPAX soon...
>
> On Jun 26, 5:32 am, mdmcginn  wrote:
>
>
>
> > molhokwai, note that we have both filed issues at Google Code, but we
> > shouldn't have. The pp4gae project has moved to 
> > Github:http://github.com/zrenx/pp4gae
>
> > On Jun 22, 10:38 am, molhokwai  wrote:
>
> > > A reply to the message I saw while in a google search for "pypress"...
> > > Saw it on osdir.com (I'm sent in a redirection loop when I try to access 
> > > the
> > > web2py-users group).
>
> > > Arghh... would have eventually saved me time if I had found out about the
> > >pypressfor gae project...
> > > But we can merge and have an even better app (if there is anything
> > > interesting to merge, from my code)...
>
> > > Voilà.
> > > --
> > > *M*ayou *N*kensa *P*enda *N*gué -*H*ervé
> > > +32 489 33 71 
> > > 51,molhok...@gmail.com,skype:molhokwaihttp://www.google.com/profiles/molhokwai
>
> > > On Tue, Jun 15, 2010 at 11:12 AM, molhokwai  wrote:
> > > > Hello there...
>
> > > > Implemented fixes to runPyPresson GAE 
> > > > (Seehttp://www.molhokwai.net/blogforhowit'sworking...).
> > > > Code fixes attached, and complete .w2p app also.
>
> > > > Thanks all.


[web2py] Re: upload bug in filename

2010-06-26 Thread Swell
Yes i am using web2py 1.79.2 on windows 7 64b
Can someone try to save the web2py files in a very long directory name
( something like 200 characters ) and use the kind of filename i
provided ( long ) and see what is happening on mac/linux?

I am doing local tests only , it means that the file are on my local
drive with these names so the fs can handle them properly.
Python may have a pb or the admin interface code don t expect such a
long FILEPATHNAME (base dir + filename ) .


[web2py] Re: upload bug in filename

2010-06-26 Thread Yarko Tymciurak
On Jun 26, 12:46 pm, Swell  wrote:
> Yes i am using web2py 1.79.2 on windows 7 64b
> Can someone try to save the web2py files in a very long directory name
> ( something like 200 characters ) and use the kind of filename i
> provided ( long ) and see what is happening on mac/linux?

... well, this is annoying:   have you _read_ this thread?
I thought I posted pretty detailed results on mac - no problems.

>
> I am doing local tests only , it means that the file are on my local
> drive with these names so the fs can handle them properly.
> Python may have a pb or the admin interface code don t expect such a
> long FILEPATHNAME (base dir + filename ) .


[web2py] Re: upload bug in filename

2010-06-26 Thread Yarko Tymciurak
On Jun 26, 12:46 pm, Swell  wrote:
> Yes i am using web2py 1.79.2 on windows 7 64b
> Can someone try to save the web2py files in a very long directory name
> ( something like 200 characters ) and use the kind of filename i
> provided ( long ) and see what is happening on mac/linux?

Sorry - I replied a little too soon - I assume you _read_ this thread,
and
saw I tried your filename on mac, without problems.


>
> I am doing local tests only , it means that the file are on my local
> drive with these names so the fs can handle them properly.
> Python may have a pb or the admin interface code don t expect such a
> long FILEPATHNAME (base dir + filename ) .

The only thing I didn't post for you was the _file_ path name:

/Users/me-123/workspace/web2py/tmptst/applications/ajaxdemo/uploads

Add the filenames generated, as I put in previous posts, and you have
your answer for mac snow leopard, at least.

I do not think this has anything to do with admin interface code not
handling length of filename, although there might be something that
could be done about error detection (assuming the windows version
file / os utilities are sending up an exception).

Still - I question the IOError and generated filename you originally
posted (I don't see any way that filename could have been generated
from the web2py code, even if there were an error).

If someone has access to a Windows 7, and is willing to try to
reproduce this with a _clean_ web2py (I suggest the source
version),please report details.

Regards,
- Yarko


[web2py] Newsletter apply form in every page by include, how?

2010-06-26 Thread Giuseppe Luca Scrofani
Hi all, I have to {{include "sidebar.html"}} in every page of a site,
and one of the elements in this include is a little form (a text field
and a submit button) where user insert email address and apply for a
newsletter, effectively writing a record in db.newsletter. How can I
do this without a controller?

Also, there is a ready made example or appliance that can send a mail
to all email adresses present in a db table?

sorry for english


[web2py] Forms field spaced by option in db model?

2010-06-26 Thread Giuseppe Luca Scrofani
Hi, something like this is possible? Automatic generation of forms by
db is just too lazy and beautiful to make me manually construct them
just for some space in between fields...

db.define_table('example',
Field('one'),
Field('two'),
Field('three'),
(insert a br here),
Field('for'),
Field('five'),
Field('six'),
(inser another br here),
Field('seven'))

This or something like css trick...

gls


[web2py] Re: Newsletter apply form in every page by include, how?

2010-06-26 Thread Yarko Tymciurak
On Jun 26, 4:31 pm, Giuseppe Luca Scrofani 
wrote:
> Hi all, I have to {{include "sidebar.html"}} in every page of a site,

... you might want to then put this in your site's  views/layout.html
file;

> and one of the elements in this include is a little form (a text field
> and a submit button) where user insert email address and apply for a
> newsletter, effectively writing a record in db.newsletter. How can I
> do this without a controller?

... you will want to send the form contents by ajax to a controller
which will do the saving;  look at 
http://www.web2py.com/book/default/section/10/3
>
> Also, there is a ready made example or appliance that can send a mail
> to all email adresses present in a db table?
>
> sorry for english


[web2py] Re: Forms field spaced by option in db model?

2010-06-26 Thread Yarko Tymciurak


On Jun 26, 6:16 pm, Giuseppe Luca Scrofani 
wrote:
> Hi, something like this is possible? Automatic generation of forms by
> db is just too lazy and beautiful to make me manually construct them
> just for some space in between fields...
>
> db.define_table('example',
>     Field('one'),
>     Field('two'),
>     Field('three'),
>     (insert a br here),
>     Field('for'),
>     Field('five'),
>     Field('six'),
>     (inser another br here),
>     Field('seven'))
>
> This or something like css trick...


Look at http://www.web2py.com/book/default/section/7/2 for an example.

If you use something like:

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

this generates a form using css classes, and you can modify the css to
get the effects you want.

You can see what this looks like with the shell:

python web2py.py -S welcome
>>> db = DAL('sqlite:memory:')
>>> db.define_table( 'example', Field('one'), Field('two'))
>>> form = SQLFORM(db.example, formstyle = 'divs' )
>>> print form

Regards,
- Yarko
>
> gls


[web2py] bug in SQLFORM?

2010-06-26 Thread Jose


I have the following code:


if form.accepts(request.vars, session):
response.flash = int(form.vars.id)
#id = int(form.vars.id)
#doc = tb_documentos[id]
#doc.update_record(estado=1)
#redirect(url_expediente)
elif form.errors:



When you insert a record, the id should be about 30, but it returns
enough numbers higher, but that does not follow any logic. For example
262826 and are not correlated. The row is inserted correctly.

I do not know when it started to happen, I think that Thursday was
working well.

I regularly update web2py from the trunk. I was due to introduction of
a bug. But download the stable version 1.79.2 and the problem
continues.

The database, which I do not administer, is MSSQL Server. I'll talk to
the admin to see if there's something weird, but I doubt it.

In my development machine with a test application and a database this
works well.

Someone has something similar?


[web2py] Re: bug in SQLFORM?

2010-06-26 Thread Jose
The id returned in the testing are:
263226
263228
263230
263232
263234
...

It is seen that increase in twos. If I go from the admin, the IDs are
correct.

Jose


[web2py] validators with dependencies

2010-06-26 Thread Alastair Medford
Alright, I'm burned out on trying to solve this.

I'm trying to make a form that checks if two fields match, like
password + verify password. I noticed in the book that there's an
example of this, but I can't seem to get it working. The code given is
as follows (this is with a typo correction, a quote is missing in
IS_EXPR in the book):

def index():
match_it = IS_EXPR('value==repr(request.vars.password)',
 error_message='passwords do not match')
form = SQLFORM.factory(
Field('username', requires=IS_NOT_EMPTY()),
Field('password', requires=IS_NOT_EMPTY()),
Field('password_again', requires=match_it))
if form.accepts(request.vars, session):
pass # or take some action
return dict(form=form)

I run this code exactly, and while it works for displaying the page,
as soon as I submit the form I get the following error:

Traceback (most recent call last):
  File "gluon/restricted.py", line 178, in restricted
  File "E:/development/web2py/applications/informed/controllers/
users.py", line 23, in 
  File "gluon/globals.py", line 96, in 
  File "E:/development/web2py/applications/informed/controllers/
users.py", line 11, in index
  File "gluon/sqlhtml.py", line 857, in accepts
  File "gluon/html.py", line 1311, in accepts
  File "gluon/html.py", line 454, in _traverse
  File "gluon/html.py", line 454, in _traverse
  File "gluon/html.py", line 454, in _traverse
  File "gluon/html.py", line 454, in _traverse
  File "gluon/html.py", line 461, in _traverse
  File "gluon/html.py", line 1118, in _validate
  File "gluon/validators.py", line 156, in __call__
  File "", line 1, in 
NameError: name 'request' is not defined

Now I imagine this is happening because the IS_EXPR code doesn't have
access to the request global. If this is the case, then how can I
achieve the result I'm looking for, and why is this example in the
book?