[google-appengine] HowTo extend base Entity class and query it's subclasses?

2008-11-23 Thread Serega.Sheypak

For example I have an entity:
AbstractRecord, it has fields:
String name, Date publishDate, Author recordAuthor, List tagList.

And I have several subclasses:
BlogRecord, CommentRecord, AdvertiseRecord.

They extend AbstractRecord, they have their own specific fields.

Can I make a query: "Select * from AbstractRecord where tagList =
'google' "
And get all AbstractRecord entites, also its subclasses which have tag
'google' in List field.

I've read
http://groups.google.com/group/google-appengine/browse_thread/thread/cadc90001d575217/1d0f86ab618f292a?lnk=gst&q=extend+entity#1d0f86ab618f292a

Seems like I can't do it?




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Please, tell where to read about imports

2009-03-14 Thread Serega.Sheypak

Hi, I'm new to Python and have problems with import script files.
Please help me to overcome it.
Here is structure of my application:

#
\
\main.py
\app.yaml
\controller
\controller\index.py (has class IndexPage)
\controller\portfolio.py (has class PortfolioPage)
\html\some_views_for_controllers
\img\some_images
\css\some_css

Here is my app.yaml:
#
application: supercoolapp
version: 1
runtime: python
api_version: 1

handlers:
- url: /css
  static_dir: css
- url: /img
  static_dir: img
- url: /.*
  script: main.py

here is main.py code:
#
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from controller import *


# MAIN CONFIGURATION #
# Register the URL with the responsible classes
application = webapp.WSGIApplication([ ('/', IndexPage), ('/
portfolio', PortfolioPage) ], debug=True)

# Register the wsgi application to run
def main():
run_wsgi_app(application)

if __name__ == "__main__":
main()

And I get exception whilr trying to see first page of my app:

 2 from google.appengine.ext.webapp.util import run_wsgi_app
3 from controller import *
4
5
6 # MAIN CONFIGURATION #
controller undefined

: No module named controller
  args = ('No module named controller',)
  message = 'No module named controller'

So it tells me that there is no module.
I've read this thing:
http://docs.python.org/tutorial/modules.html#importing-from-a-package

What do I do wrong? Please tell me.

Sorry for stupid question.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Forward request or webapp.RequestHandler chaining (like Actions framework in java)

2009-03-15 Thread Serega.Sheypak

Hello, I would like to know is it possible to forward request?

For example in Java I can forward request from one servlet (like
webapp.RequestHandler) to another or from servlet to jsp (like Django
template).
self.redirect("/someUrl") clears response and doesn't "transfer"
request object. That is why I need redirect.

The task is:
I have a view (Django template)
Person can perform silmpe crud: Create something, delete something,
update something.

Here is a code:

#prepare view data, show news
class AdminPage(webapp.RequestHandler):
def get(self):
message = self.request.get('message')
if not message:
message = 'You are in admin console.'
logging.debug("Did message came -> " + message);
offset = self.request.get('offset')
limit = self.request.get('limit')
news = get_news(offset, limit, False)
values = {
'page': 'admin',
'news': news,
'count': get_news_count(),
'message': message
}
path = os.path.join(os.path.dirname(__file__),'html/admin.html')
self.response.out.write( template.render(path, values) )

#Hide news from user and send to view preparation
class HideNews(webapp.RequestHandler):
def get(self):
key = self.request.get('key')
logging.debug("hide news with key["+key+"]")
hide_news( key )
values = {
'message':'News was hidden'
}
self.redirect("/admin")

As you can see "HideNews" performs an action and wants to send message
to the news requestHandler.
But it can't do it.

Is there any opportunity to forward request processing in GAE?

P.S
I've tried to do this:
class HideNews(webapp.RequestHandler):
def get(self):
key = self.request.get('key')
logging.debug("hide news with key["+key+"]")
hide_news( key )
message = "Some str with russian chars".decode('utf-8')
url = "/admin?message=".decode('utf-8')+message
self.redirect(url)

And I get:
self.response.headers['Location'] = str(absolute_url)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
36-42: ordinal not in range(128)

It doesn't accept utf-8 chars?
What to try next?

Thanks in advance.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Chartle.net - application based on Google App Engine

2009-03-17 Thread Serega.Sheypak

Hi, nice work!
Please, tell me how did you configure your application to have address
chartie.net not (something.appspot.com?) Is there any possibility to
make DNS records for that?

On Mar 17, 4:59 pm, Amr Ellafi  wrote:
> what do you use for charting by the way ?
>
> On Tue, Mar 17, 2009 at 2:39 PM, Dieter Krachtus
>
>  wrote:
>
> > Thanks!
>
> > Actually it is an early alpha (incomplete and buggy Undo/Redo, etc.),
> > but I was bored running it locally so I put it online. I hope I will
> > find time to improve it on the weekends.
>
> > Cheers,
> > Dieter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: how to config gwt to work in app engine effective and productive

2009-03-17 Thread Serega.Sheypak

Of course not.
You can *present* datastore object in JSON (JavaScript Object
Notation).
Use POJO (Plain Old Java Object) concept while creating data Model of
your application.
You can easilly present list of Model objects in JSON, you can easilly
convert them from JSON to POJO on GWT (Java, client-side). The same
thing happens on server-side. Parse incomming JSON and construct Model
objects (in Python) using parsed data.

GWT+GAE can work together. Ofcourse, this way won't be productive
comparing to Java backend. But anyway, if you want to make good stable
complicated UI, don't use JS - it's paiful. Use OO Java and be happy
like I am ^)

On Mar 17, 4:57 pm, Amr Ellafi  wrote:
> Pavel,
> that's a good idea, you mean you can pass objects from the datastore
> to GWT via JSON ?
>
> On Tue, Mar 17, 2009 at 3:50 PM, Pavel Byles  wrote:
>
> > Coonay,
> > I use GWT and GAE together and I think it's a pretty good setup.
> > First, instead of using servlets you will use the request builder and
> > pass data using JSON instead. 2nd I effectively just send my HTML
> > output of my GWT project to my GAE project and configure my app.yaml
> > accordingly.
>
> > Using this method you will lose a really big part of GWT, which is the
> > debugging feature since you will be running dev_appserver. Unless you
> > can fix it such that u can get JSON responses from it.
>
> > But I like my setup. I have pydev and cypal both in eclipse. I just
> > wish i had debugging somehow.
>
> > On Mar 17, 5:36 am, Coonay  wrote:
> >> Gwt featurs really attractive:quickly build and maintain complex yet
> >> highly performant JavaScript front-end applications in the Java
> >> programming language,and Test your code with JUnit.The example mail
> >> page is really awesome.
>
> >> As a many years java progammmer,it's not hard to get into gwt,but the
> >> app engine is a different web environment,the static page can be
> >> served to browser directly,
> >> the hype link in the geranated html are needed to change accordingly.
>
> >> could you give me some idea how to make they 2 work together
> >> effective and productive?thanks so much
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Forward request or webapp.RequestHandler chaining (like Actions framework in java)

2009-03-17 Thread Serega.Sheypak

Yes, Java made my mind tooo complicated. You've  written clear
solution: invoke one handler from another.
That is why I've immediately started to learn Python+ GAE (wow), Ruby
+RoR (awesome! cool!) and Lisp(brain blast) .

Java made my mind Javable... :(

On Mar 16, 12:44 am, Jarek Zgoda  wrote:
> It would be easier if you do not use WebApp but follow Django way of
> request handling (easy to achieve even without Django, ie. using
> Werkzeug to lay out application in model-view-template style):
>
> def handler_a(request):
>   return response('a')
>
> def handler_b(request):
>   return handler_a(request)
>
> In handler_b you just called handler_a with a request object from
> handler_b. You can modify request object before passing it to another
> view function as you please.
>
> On 15 Mar, 12:06, "Serega.Sheypak"  wrote:
>
> > Hello, I would like to know is it possible to forward request?
>
> > For example in Java I can forward request from one servlet (like
> > webapp.RequestHandler) to another or from servlet to jsp (like Django
> > template).
> > self.redirect("/someUrl") clears response and doesn't "transfer"
> > request object. That is why I need redirect.
>
> > The task is:
> > I have a view (Django template)
> > Person can perform silmpe crud: Create something, delete something,
> > update something.
>
> > Here is a code:
>
> > #prepare view data, show news
> > class AdminPage(webapp.RequestHandler):
> >         def get(self):
> >                 message = self.request.get('message')
> >                 if not message:
> >                         message = 'You are in admin console.'
> >                 logging.debug("Did message came -> " + message);
> >                 offset = self.request.get('offset')
> >                 limit = self.request.get('limit')
> >                 news = get_news(offset, limit, False)
> >                 values = {
> >                         'page': 'admin',
> >                         'news': news,
> >                         'count': get_news_count(),
> >                         'message': message
> >                 }
> >                 path = 
> > os.path.join(os.path.dirname(__file__),'html/admin.html')
> >                 self.response.out.write( template.render(path, values) )
>
> > #Hide news from user and send to view preparation
> > class HideNews(webapp.RequestHandler):
> >         def get(self):
> >                 key = self.request.get('key')
> >                 logging.debug("hide news with key["+key+"]")
> >                 hide_news( key )
> >                 values = {
> >                         'message':'News was hidden'
> >                 }
> >                 self.redirect("/admin")
>
> > As you can see "HideNews" performs an action and wants to send message
> > to the news requestHandler.
> > But it can't do it.
>
> > Is there any opportunity to forward request processing in GAE?
>
> > P.S
> > I've tried to do this:
> > class HideNews(webapp.RequestHandler):
> >         def get(self):
> >                 key = self.request.get('key')
> >                 logging.debug("hide news with key["+key+"]")
> >                 hide_news( key )
> >                 message = "Some str with russian chars".decode('utf-8')
> >                 url = "/admin?message=".decode('utf-8')+message
> >                 self.redirect(url)
>
> > And I get:
> > self.response.headers['Location'] = str(absolute_url)
> > UnicodeEncodeError: 'ascii' codec can't encode characters in position
> > 36-42: ordinal not in range(128)
>
> > It doesn't accept utf-8 chars?
> > What to try next?
>
> > Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: Datastore API and Flex Applications

2009-03-26 Thread Serega.Sheypak

As I understood, you have to use web-layer.
Flex can send requests to your appengine application and get response
in JSON format. For example, it's possible to work using GWT the same
way.

On Mar 26, 4:45 am, Doug  wrote:
> Good Evening Everyone,
>
> Is there an API for accessing the datastore from an Adobe Flex
> application?
>
> I was thinking that I had read about one, but now I can't find it.
>
> Thanks,
> Doug
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] howTo write tag with EL support?

2009-06-21 Thread Serega.Sheypak

Hello. I have a problem writing custom jsp-tag with attr which accepts
EL (ExpressionLanguage).

Here is the LTD:

http://java.sun.com/xml/ns/j2ee";
  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-
jsptaglibrary_2_0.xsd">

1.0
PrizeTags
PrizeTags


error
ru.develbureau.server.tag.OutTag
empty
Prints if something exists

value
true
true



Here is the Tag code:
public class OutTag extends SimpleTagSupport{
private static final long serialVersionUID = 1L;
String val = null;

public void doTag() throws JspException {
try{
PageContext pageContext = (PageContext) getJspContext();
JspWriter out = pageContext.getOut();
if(val!=null){
out.println(val);
System.out.println("val -> ["+val+"]");
}
}catch (Exception e) {
System.out.println("doStartTag -> 
["+e.getMessage()+"]");
}
}

public void setValue(Object value){
System.out.println("setValue -> ["+value+"]");
if(value!=null && value instanceof String){
String t = (String)value;
if(t.trim().length()>3){
val = t;
}
}
}
}

Here is the putput:
setValue -> [${pageScope.clientRequest.name}]
val -> [${pageScope.clientRequest.name}]

setValue -> [${clientRequest.name}]
val -> [${clientRequest.name}]


So it doesn't want to EVAL incomming EL

Here is the usage:
  

  


"/>
OR
"/>

NOTHING HELPS.

It just prints ${clientRequest.name}. It doesn't want to EVAL expr.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: howTo write tag with EL support?

2009-06-22 Thread Serega.Sheypak

I can't do it, because appengine web.xml tells that it has 2.3 dtd
version.
And it's impossible to use 2.4 version in java appengine env.
I will try these solutions http://forums.sun.com/thread.jspa?threadID=625802
found on forum.sun.com

P.S.
Configuration is bad. Convention is better...(

On Jun 21, 7:44 pm, "Serega.Sheypak"  wrote:
> Hello. I have a problem writing custom jsp-tag with attr which accepts
> EL (ExpressionLanguage).
>
> Here is the LTD:
> 
> http://java.sun.com/xml/ns/j2ee";
>                                           
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>                                           
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2eeweb-
> jsptaglibrary_2_0.xsd">
>
>         1.0
>         PrizeTags
>         PrizeTags
>
>         
>                 error
>                 ru.develbureau.server.tag.OutTag
>                 empty
>                 Prints if something exists
>                 
>                         value
>                         true
>                         true
>                 
>         
>
> Here is the Tag code:
> public class OutTag extends SimpleTagSupport{
>         private static final long serialVersionUID = 1L;
>         String val = null;
>
>         public void doTag() throws JspException {
>                 try{
>                         PageContext pageContext = (PageContext) 
> getJspContext();
>                     JspWriter out = pageContext.getOut();
>                         if(val!=null){
>                                 out.println(val);
>                                 System.out.println("val -> ["+val+"]");
>                         }
>                 }catch (Exception e) {
>                         System.out.println("doStartTag -> 
> ["+e.getMessage()+"]");
>                 }
>         }
>
>         public void setValue(Object value){
>                 System.out.println("setValue -> ["+value+"]");
>                 if(value!=null && value instanceof String){
>                         String t = (String)value;
>                         if(t.trim().length()>3){
>                                 val = t;
>                         }
>                 }
>         }
>
> }
>
> Here is the putput:
> setValue -> [${pageScope.clientRequest.name}]
> val -> [${pageScope.clientRequest.name}]
>
> setValue -> [${clientRequest.name}]
> val -> [${clientRequest.name}]
>
> So it doesn't want to EVAL incomming EL
>
> Here is the usage:
>                               scope="page"
>                            type="ru.develbureau.client.model.ClientRequestTO"
>                            
> class="ru.develbureau.client.model.ClientRequestTO">
>         
>   
>
> 
> "/>
> OR
> "/>
>
> NOTHING HELPS.
>
> It just prints ${clientRequest.name}. It doesn't want to EVAL expr.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Problem with ReferenceProperty

2010-12-05 Thread Serega.Sheypak
Hi, please help me to find sillt mistake, I'm trying to create many-to-
one relation using this guide:
http://code.google.com/intl/en/appengine/articles/modeling.html

Please, see my code:

#BlogPost.py
from google.appengine.ext import db
#Keeps Posts
class BlogPost(db.Model):
author = db.UserProperty(required=True)

title = db.StringProperty(required=True)
short_title = db.StringProperty(required=True)
short_description = db.StringProperty(required=True)
content = db.TextProperty(required=True)

tags = db.StringListProperty()

created = db.DateTimeProperty()
updated = db.DateTimeProperty()
finished = db.BooleanProperty(default=True)

#Comment.py
from google.appengine.ext import db
from blog.model import BlogPost

#Keeps comments
class Comment(db.Model):
author = db.UserProperty(required=True)
author_name = db.StringProperty
content = db.TextProperty(required=True)

created = db.DateTimeProperty(auto_now_add=True)
updated = db.DateTimeProperty(auto_now=True)
visible = db.BooleanProperty(default=True)
post = db.ReferenceProperty(BlogPost, collection_name="comments")
#***ERROR HERE***

And I get:
File "D:\google_appengine\google\appengine\ext\db\__init__.py", line
3118, in __init__
raise KindError('reference_class must be Model or
_SELF_REFERENCE')
KindError: reference_class must be Model or _SELF_REFERENCE
on the line marked: ***ERROR HERE***

What does it mean? BlogPost is a db.Model. What's wrong, I don't get
it.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Re: Problem with ReferenceProperty

2010-12-05 Thread Serega.Sheypak
 from blog.model.BlogPost import BlogPost

The first BlogPost is for .py file name, the second is for class name.
I thought, that python would understand that in need to import class
because it has the file and the class name are the same.

I'm bad in python. :(

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Re: Problem with ReferenceProperty

2010-12-19 Thread Serega.Sheypak
Please give me sample, I would like to see it. I don't know how to
google topic you've described (don't understand which  key words use
for search).

On Dec 6, 10:43 pm, Robert Smart 
wrote:
> Normally one should avoid using ReferenceProperty. Best to build a
> key_name from data in the record, or allocate_ids and keep the
> allocated ids in the database (in its parent or in the some other
> record you're bound to use like the record of user data). Then you can
> build the key whenever you need and (importantly) you can build the
> key before the record is stored and use that for various purposes
> (like parenting) without having to have special cases for when the
> record has/hasn't been written yet.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.