Richard | 22 Jul 13:05 2014
Picon

Can not import copy_reg

Hi,

I have an issue with adjusting the auth tables resulting in a custom import and an error that copy_reg can not be imported.

The error trace is:
Traceback (most recent call last):
File "/home4/mamplcom/public_html/cgi-bin/gluon/restricted.py", line 220, in restricted
exec ccode in environment
File "/home4/mamplcom/public_html/cgi-bin/applications/im/models/db.py", line 74, in <module>
auth.define_tables(username=False, signature=False)
File "/home4/mamplcom/public_html/cgi-bin/gluon/tools.py", line 1784, in define_tables
format='%(first_name)s %(last_name)s (%(id)s)'))
File "/home4/mamplcom/public_html/cgi-bin/gluon/dal.py", line 8226, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
File "/home4/mamplcom/public_html/cgi-bin/gluon/dal.py", line 8263, in lazy_define_table
polymodel=polymodel)
File "/home4/mamplcom/public_html/cgi-bin/gluon/dal.py", line 1125, in create_table
sql_fields_old = pickle.load(tfile)
File "/home4/mamplcom/public_html/cgi-bin/gluon/custom_import.py", line 92, in custom_importer
return base_importer(pname, globals, locals, fromlist, level)
ImportError: No module named copy_regI can import copy_reg from the python prompt and adding the import copy reg from Dal.py (suggested in a thread by Massimo) has no effect.I use Python 2.7.8.Any clu would be helpfull.Richard

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Ruud Schroen | 22 Jul 11:21 2014
Picon

Tables defined in module not showing up

Hi guys,

I'm building a Blog module, which I will post here as soon as it's done.
But there's something wrong, I've defined a couple of tables in the module.

def define_tables(self):
        category_tablename = self.settings.category_tablename
        post_tablename = self.settings.post_tablename
        link_tablename = self.settings.link_tablename
        comment_tablename = self.settings.comment_tablename

        self.blog_category = self.db.define_table(category_tablename,
                Field("name", label=self.T("Name of the category")),
                Field("slug", compute=lambda r: IS_SLUG()("%s" % (r["name"]))[0]),
                Field("description", 'text', label=self.T('Describe what will be inside this category'))
        )

        self.blog_post = self.db.define_table(post_tablename,
                Field("title", label=self.T("Name the title of this post")),
                Field("slug", compute=lambda r: IS_SLUG()("%s" % (r["title"]))[0]),
                Field('body', 'text', label=self.T('The content of this post')),
                self.auth.signature
        )

        self.post_category_link = self.db.define_table(link_tablename,
                Field('post_id', 'reference %s' % post_tablename),
                Field('category_id', 'reference %s' % category_tablename),
                Field('is_active', 'boolean', default=True)
        )

        self.blog_comment = self.db.define_table(comment_tablename,
                Field('post_id', 'reference %s' % post_tablename),
                Field('parent_comment', 'reference %s' % comment_tablename),
                Field('author', label=self.T('Your name')),
                Field('body', 'text', label=self.T('Your comment')),
        )

        #Creates an admin role if there is none
        if self.db(self.db.auth_group.role == 'admin').count() == 0:
            self.db.auth_group.insert(role='admin')

        #Virtual field which keeps track of the category links of each post
        #Allows for an easy way of showing the post's categories in the views
        self.blog_post.categories = Field.Virtual('categories', lambda row: self.category_field(row))

The tables ARE created because when I do "self.db.tables()", this is my output:
auth_user
auth_group
auth_membership
auth_permission
auth_event
auth_cas
blog_category
blog_post
post_to_category
blog_comment

However.. the tables do not show up in appadmin, why?

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Nicola Barbieri | 21 Jul 15:51 2014
Picon

web2py - show data from a MongoDB Document as a grid


Hi everyone,

I'm a web2py newbie and I'm having some hard time with the following simple task:

I would like to show in a page all the records stored in the following MongoDB document (called requests):

{
  "request": {
    "slice": [
      {
        "origin": "SFO",
        "destination": "MIA",
"date": "2014-08-21"
      }
    ]
  }
}

My approach would be define a table with a json field and then parse it:

db.py:

db.define_table('requests',
Field('request','json'))

default.py:

def all_records():
    grid = SQLFORM.grid(db.requests, fields=[db.requests.request.slice[0].origin,db.requests.request.slice[0].destination,db.requests.request.slice[0].date)
    return locals()


all_records.html:

{{extend 'layout.html'}}
{{=BEAUTIFY(response._vars)}}


Though, I get this error:

<type 'exceptions.AttributeError'> 'Field' object has no attribute 'slice'


so I guess I'm parsing the JSON file in the wrong way.


Any help is more than welcome,

thanks

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
jaiprakash.singh | 21 Jul 13:29 2014
Picon

Web2py Rocket server is too slow

web2py rocket server is too slow for my application.
Can somebody share step by step instruction to install Apache or nginx web server?
 
I want to install nginx server on Ubuntu.
 
Kindly help.
 
Regards,
Jaiprakash

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
David Jobes | 21 Jul 15:58 2014
Picon

urllib2 and web2py not showing page

I am trying to call a web page from within a function it works fine, except for the fact that it only shows the raw html page and not a the rendered page i need, have tried all the urllib2 methods and still not luck, here is code, any ideas or sugggestions.

def vrt():
    fup_form = FORM(INPUT(_name='title',_type='text'),INPUT(_name='file',_type='file'))
    idx_page= urllib2.urlopen('http://xxx.xxx.xxx.xxx:9090/').read()
    grid = SQLFORM.smartgrid(db.files,onupdate=auth.archive)
    return dict(idx_page=idx_page,grid=grid)


the index page

{{extend 'layout.html'}}
<h2>
    Import and Convert VRT/ET Rules (Beta Conversion)
</h2>
<br />
<p>
    {{=idx_page}}
</p>
<br />
{{=grid}}

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
chuan137 | 21 Jul 23:02 2014
Picon

simplify parse_as_rest pattern?

Example of parse_as_rest function, there define tables

db.define_table('person',Field('name'),Field('info'))
db
.define_table('pet',Field('ownedby',db.person),Field('name'),Field('info'))

which are served with the pattern

 "/{person.name}/pets[pet.ownedby]/{pet.name}".


That means a valid URL is for instance
/Tom/pets/BlackCat 

Is it possible to simplify the pattern, so that
/Tom/BlackCat
is also valid?

I am aware that url routing does the trick, but I just wonder if there is a more direct way to set up the pattern?

Thanks

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Thiago Duarte | 21 Jul 18:23 2014
Picon

Getting more rows from a table without jQuery, PHP, etc

Hi there,

I tweaked a couple of codes of a pagination demo, but it doesn't worked for me because the page is refreshed, I'm wanting add a button which always gets the next 10 rows from a table when clicked, so that contents is loaded always below, like an infinite scroll. I've seen a lot of examples on how to implement it in a webpage and it seems the easiest way to managed it is using PHP, jQuery, JSON, etc, associated with the database.
I would to know if there is a way to achieve this only using the web2py features, or there is no way and I should to use these languages above.
(I took a quick look in chapters 6 and 7 of the manual, is SQLFORMS.grid what I'm looking for?)

Thanks in advance

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Mark Li | 21 Jul 21:07 2014
Picon

Display registration error for auth.register_bare()

Is it possible to return the registration error msg from auth.register_bare(), similar to how auth.register() would display the error msg after submit? From what I can gather in the source, seems like it only returns False on fail, and the user object on success. I would like to display more information to the user (password too short, username already taken, etc.), if registration fails.

I am implementing an ajax registration, where I do not want the page to reload on submit unless registration is successful.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Yebach | 21 Jul 12:43 2014
Picon

SQLFORM grid process not working

Hello

I have a SQLForm.grid. 

I want to create a response.flash message but on my if evaluation I get an error when my edit view is done

<type 'exceptions.AttributeError'> 'DIV' object has no attribute 'process'

even on my sqlform.grid view

this is my controller function

         form = SQLFORM.grid(query=query, 
left=db.status.on(db.worker.w_status == db.status.id),
fields=fields,  searchable=True, orderby=default_sort_order,create=True,
deletable=True, editable=True, paginate=25, buttons_placement = 'right')
if form.process().accepted:
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill the form'
    # Note: no form instance is passed to the view
return dict(form=form)

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
ceriox | 21 Jul 09:24 2014
Picon

Create table from a row

Hi all,

it is possible to create a table from a recordset?

something like this for example:
db.define_table('t_log', log_results)

thanks

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Simon Ashley | 21 Jul 06:19 2014
Picon

rname and reserved names


Haven't used rname before but the way I read it it should work with reserved names. Have changed a given example to read:

db.define_table('easy_name',
Field('position', rname='"this_is_the_field_name"'),
rname='"this_is_the_easy_name_table"')but it returns an error as follows:Traceback (most recent call last):
File "C:\w2p_5\gluon\restricted.py", line 220, in restricted
exec ccode in environment
File "C:/w2p_5/applications/test_1/models/db_1.py", line 11, in <module>
rname='"this_is_the_easy_name_table"')
File "C:\w2p_5\gluon\dal.py", line 8223, in define_table
table = self.lazy_define_table(tablename,*fields,**args)
File "C:\w2p_5\gluon\dal.py", line 8240, in lazy_define_table
table = table_class(self, tablename, *fields, **args)
File "C:\w2p_5\gluon\dal.py", line 8754, in __init__
check_reserved(field_name)
File "C:\w2p_5\gluon\dal.py", line 7931, in check_reserved_keyword
'invalid table/column name "%s" is a "%s" reserved SQL/NOSQL keyword' % (name, backend.upper()))
SyntaxError: invalid table/column name "position" is a "ALL" reserved SQL/NOSQL keywordRunning 2.9.5There there something I've overlooked? TIA


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Gmane