YouTube Icon

Interview Questions.

Top 100+ Turbogears Interview Questions And Answers - Jun 02, 2020

fluid

Top 100+ Turbogears Interview Questions And Answers

Question 1. What Is Turbogears?

Answer :

TurboGears is a rapid development “the front-to_back” internet meta-framework. Its purpose is to simplify and accelerate the improvement of current web programs written inside the Python programming language.

Question 2. How Is Turbogears Licensed? Can I Use It For Commercial Applications?

Answer :

TurboGears itself is certified beneath the MIT license. Its distinctive parts can be certified otherwise. Please examine the information on the license web page.

In trendy, all licenses permit business utilization or even closed-source distribution of your software if you encompass a replica of the resp. License, but if unsure, please consult your lawyer.

Python Interview Questions
Question three. How Does Turbogears Compare To Ruby On Rails/django/pylons/and so on.? Which Framework Should I Choose For My New Project?

Answer :

This is an ever popular subject matter at the mailing list. See,

as an example, those threads:

TurboGears vs Django (older) (2006-07-29)
TurboGears vs JSP vs PHP vs Ruby on Rails vs Webware (2006-08-15)
Who are the core TurboGears developers (2006-eleven-14)
Sharing between TurboGears/Django/Pylons/and many others. (2006-12_02)
TurboGears vs Django (2006-12-05)
Question four. What Books Are Available For Learning Turbogears?

Answer :

The “respectable” TurboGears e-book is Rapid Web Applications with TurboGears with the aid of Mark Ramm et al.

Python Tutorial
Question 5. When Can We Expect Python 2.5 Support?

Answer :

TurboGears supports Python 2.5 as of version 1.0.2.

MVC Framework Interview Questions
Question 6. When Can We Expect Python 2.6 Support?

Answer :

TurboGears formally helps Python 2.6 as of model 1.1.

Question 7. How Can I Do Non-root Installations?How Can I Install Turbogears On A Unix-like System Without Root User Privileges?

Answer :

An smooth and short way is to apply the virtualenv application to create a separate, easy Python environment and installation TurboGears in this surroundings. The basic steps are:

set up virtualenv with easy_install virtualenv.
Run virtualenv
source /bin/prompt
Download tgsetup.Py and run python tgsetup.Py.
Install additional eggs, like nose, pysqlite, SQLObject, SQLAlchemy, etc. With easy_install
is the name of a listing that virtualenv ought to create. It will comprise the brand new Python surroundings. Everytime you need to work with this environment, you need to perform step three. From above, so that the library modules and scripts from the surroundings are used.

MVC Framework Tutorial Microsoft Entity Framework Interview Questions
Question eight. Why Do I Get The Log Messages Twice?

Answer :

This is normal. The TurboGears application server, Cherrypy 2.X, runs two procedures when in improvement mode and it’s set to autoreload. Each system outputs logging messages and that is why they appear two times. This does no longer occur in manufacturing mode and additionally doesn’t manifest in more recent (i.E. CP3) CherryPy versions (which TurboGears does now not use yet), which concerned a rewrite of the reloading mechanism.

Question nine. What Causes "'stream' Object Has No Attribute 'tag'"?

Answer :

This is maximum probably caused by mixing Genshi and ToscaWidgets incorrectly.

In the beginning, there has been Kid and “traditional” widgets. Traditional widgets back an ElementTree item, which the Kid engine transformed into HTML. In Genshi, you can use conventional widgets, but you should use the "ET()" function to explicitly convert them to HTML. (If you get "<script elementat ASDFASDF>" in your output, that may be a signal which you are handing a traditional widget again to Genshi, and NOT wrapping it in ET().)

ToscaWidgets, alternatively, go back HTML natively. If you wrap a ToscaWidget reference in ET(), you'll get a stack hint saying "'Stream' objecthas no characteristic 'tag'".

Note that those problems do no longer exist any more in TurboGears 1.1 and 1.Five, they do all the vital wrapping and changing for you. TurboGears 1.5 even allows Genshi templates in TurboGears widgets and could convert among the Kid and Genshi templating structures beneath the hood.

HTTP Interview Questions
Question 10. Why Do I Sometimes Get 500 Internal Errors After My App Has Been Idle?

Answer :

Are you using a MySQL database? If so, this is probably the MySQL day out. Because CherryPy is a protracted strolling system it doesn’t make a new connection on each web page load. After a period of inactivity the MySQL server will timeout the relationship. This causes an error the subsequent time the utility attempts to apply the connection.

One solution some human beings use is to installation a cron task that occasionally wgets a web page from the software to be able to cause a database query. There is likewise apparently a MySQL wait_timeout putting that can be adjusted to forestall the relationship from timing out.

Microsoft Entity Framework Tutorial
Question 11. Why Do My Ajax-enabled Widgets Stop Working After Some Minutes?

Answer :

This might be due to the fact which you have enabled identity and the session has timed out and the AJAX-calls from your widget (e.G. LoadJSONDoc) encounter a 401 (“Unauthorized”) or 500 (“Internal Server Error”) mistakes.

A simple technique to deal with this would be to wrap the loadJSONDoc call and constantly upload a errback callback characteristic that catches this error:

function ljd_errhandler(end result) 
    if (result instanceof XMLHttpRequestError &&
        (result.Variety result.Wide variety == 500) 
        /* deal with error right here, as an instance certainly show an errors message */
    


feature do_loadjsondoc(url, cb_func) 
    d = loadJSONDoc(url);
    d.AddCallbacks(cb_func, ljd_erhandler);
    go back d;


Java collections framework Interview Questions
Question 12. Why Does Turbogears 1.0 Still Use Cherrypy 2.X Instead Of Cherrypy three?

Answer :

When TurboGears turned into created, CP3 didn’t exist and there in which most important changes between CP2 and CP3. Therefore the breaking changes required to support CP3 in have been made best in TG 1.Five.

Python Interview Questions
Question thirteen. Which Alternative Template Engines Can I Use With Turbogears?

Answer :

In principle, you may use any templating language that offers a Buffet plugin interface, both without delay or through a separate template engine pluginpackage. Template engines, that have been efficaciously used with TurboGears, consist of Genshi, Cheetah and Jinja. For general statistics the way to use non-standard template engines with TurboGears, see Using Alternate Templating Engines.

If you're using widgets, you want Kid to render the widgets, however you can nonetheless use a specific template engine to your page templates. With ToscaWidget you could use any Buffet-compliant template engine on your widgets.

HTTP Tutorial
Question 14. How Do I Deploy My Configuration And A Default Database?

Answer :

From TurboGears model 1.Zero.4b3 onwards it is simple to include a default configuration record on your software’s egg document, which then will be determined with the aid of the usual begin script automatically. You just must uncomment a section to your project’s setup.Py file, that's appropriatly commented. 

While, in principle, one could also consist of a default database in the egg, this would only make sense for unmarried-record databases, like those utilized by SQLite, however however, one wouldn’t generally want to write to documents contained in an egg.

One solution is to provide a custom tg-admin command in your software, that asks the person for the database connection parameters after which initializes the database the usage of the tg-admin sq. Create command followed by means of some custom code to fill the the dadabase with a few bootstrap information.

Question 15. How Can I Find The Filesystem Locations For My Project?

Answer :

Use the pkg_resources module which comes with setuptools

For instance, You can get the entire course to the templates listing in the wiki20 package by means of:

from pkg_resources import resource_filename
resource_filename('wiki20', 'templates')

You can then without problems flow up an down inside the filesystem with the aid of using the features form the usual os.Route module.

Please endure in thoughts, when you have established your utility as an egg, there may be no “venture listing” in line with se, in truth, the documents of your utility may not even reside directly inside the filesystem but in a ZIP archive. You can build an egg that contains additiional statistics document alongside your application’s package deal directory. See the setuptools documentation for extra facts.

Microsoft Solutions Framework (MSF) Interview Questions
Question 16. How Can I Use Special Characters In My Urls?

Answer :

You can’t due to the fact method names need to agree to the policies for Python identifiers. But you may work around this by way of managing URL dispatching yourself in an exposed default method of your controller, ex: setattr(class, irregular, method) to effectively alias the web page.

Unittest Framework Tutorial
Question 17. How Do I Change The Name Of A Project?

Answer :

To exchange the name of a project called “foo” created via tg-admin quickstart, you need to manually go through all of the documents of the venture and replace all occurences of “foo” with “matrix”, in which “matrix” is the brand new call of the venture. If you're under Linux/Mac, you can automate this tedious paintings with this shell snippet:

locate . -name
    while read f; do
        sed -e 's#foo#matrix#g' < "$f" > /tmp/x
        mv /tmp/x "$f"
    finished

Unittest Framework Interview Questions
Question 18. How Can I Output Html Passed By The Controller In My Kid Templates?

Answer :

Use $XML(mytemplatevar) or refactor by using defining and using a kid template function, as an instance:

<a py:def="link(url, text)" href='$url'>$textual content</a>

Then on your template you operate:

$hyperlink('http://foo.Com/', 'Foo.Com')

Which will render to this output:

<a href='http://foo.Com/'>Foo.Com</a>

MVC Framework Interview Questions
Question 19. How Can I Organize My Templates Hierarchically?

Answer :

templates are regarded up through the template engines thru the ordinary Python module bundle mechanisms and the templates directory is therefore a Python package deal. Subdirectories have to be sub-packages as well and you may attain that by means of putting an __init__.Py report in them. The__init__.Py can incorporate Python code, but an empty record will do simply as nicely.

WxPython Tutorial
Question 20. How To I Specify An Alternate Template To Use In My Controller Method?

Answer :

Put tg_template set to the call of the template you need to use into the dictionary you return out of your controller approach

e.G.:

@disclose('.Templates.Index')
def index(self, **kw):
    d = dict(message='Hello World!')
    if some_condition:
        d['tg_template'] = '.Templates.Different'
    return d

wxPython Interview Questions
Question 21. How Do I Pre-fill (a few) Fields When I Display A Widgets-primarily based Form?

Answer :

You offer a dictionary to the cost parameter while you display the widget within the template. The dictionary have to contain the the sector names as keys and their preset value as values. You skip both the widget form item and the values dictionary to the template from your controller method.

Example:

# widgets.Py
myform = TableForm(
    fields = [
        widgets.TextField('name'),
        widgets.TextField('electronic mail')
)
# controllers.Py
from widgets import myform

magnificence MyController(controllers.Controller):
    ...
    @divulge('.Templates.Form_template')
    def showform(sefl, **kw):
        form_values = dict(
            name = "Joe Doe",
            e mail = "joe@doe.Com"
        )
        go back dict(form=myform, form_values=form_values)
<!-- form_template.Kid -->
...
$form(value=form_values)
...

Question 22. How Do I Validate Two Forms On The Same Page?

Answer :

Just set the movement characteristic of every shape to a exclusive price making them post to two different controller methods.

You can then use a @validate decorator with a one of a kind shape argument on each approach.

Spring MVC Framework Tutorial
Question 23. How Can I Write A Widget Which Displays An Image?

Answer :

That’s smooth. Just include an picture tag within the template of the widget:

magnificence ImageWidget(widgets.Widget):

template = '<img xmlns:py="http://purl.Org/kid/ns#" src="$value" />'

and offer the image URL whilst you display the widget:

$myimagewidget(tg.Url('myimage.Png'))

If you need to serve a dynamically generated image, you need to offer a controller method for this, and use the URL to this controller technique as the fee for the widget.

Spring MVC Framework Interview Questions




CFG