gae-boilerplate Google App Engine Boilerplate

我要开发同款
匿名用户2021年12月10日
24阅读
开发技术Python
所属分类Web应用开发、Web框架
授权协议View license

作品详情

GoogleAppEngineBoilerplateLegacy

==============================

ThisProjectwasSponsoredbyPyCharm

NOTE:ThisProjectisLegacyandusesthefirsttechnologyusedbyGoogleAppEngine,likewebapp2asPythonFrameworkandDataStoreasDataBase.On2016thisprojectwaslegacyanditisrecommedabletousemodermtechnologieslikeFlaskorDjangoasFramework,MySQLasdatabase.Thankseverybodyfortheircontributions,Thecreatorofthisprojectishonoredthatithelpstobringwebtechnologytotheworld.

Intro

GoogleAppEngineBoilerplategetsyourprojectoffthegroundquicklyusingtheGoogleAppEngineplatform.CreatepowerfulapplicationsbyusingthelatesttechnologysupportedonGoogleAppEngine.ItwillintroducesnewdeveloperstoAppEngineandadvanceddeveloperstofollowbestpractices.

Tryaonlinedemo

What'saBoilerplate?

ABoilerplateisusedtodescribesectionsofcodethatcanbereusedoverandoverinnewcontextsorapplicationswhichprovidesgooddefaultvalues,reducingtheneedtospecifyprogramdetailsineveryproject.(wikipedia)

WhatmakesthisBoilerplateAmazing?

Itisfullyfeatured,activelymaintained,andusesthelatestandmostsupportedtechnologiesofGoogleAppEngine.

NewtoGoogleAppEngine?Learnaboutitbywatchingthisvideoof@bslatkinorreadingtheofficialdocumentation.

GetstartedinjustafeweasystepsDownloadthelastversionoftheAppEngineSDKforLinux,MacOSorWindows.DownloadorclonethecodeofthisBoilerplate(here)Runlocally(instructions).Setyour'application'nameinapp.yamlSetcustomconfigparametersinbp_content/themesconfig/localhost.py,config/testing.pyandconfig/production.pylikesecretkey,recaptchacode,saltandother.Boilerplatewillidentifywhichconfigfiletouseinlocal,unittestingandproduction.Togetstarted,lookthedefaultsettingsinbp_includes/config.py.Thosesettingswillbeoverwriteforyourconfigfiles.Mostofthedefaultsettingswillneedtobechangedtoyieldasecureandworkingapplication.

SetAuthenticationOptionsdropdowntoFederatedLoginintheGoogleAppEnginecontrolpanel(orifyoudonotwantfederatedlogin,setenable_federated_logintofalseinconfig.py)

Deployitonline(instructions-recommendedsetup:python2.7,highreplicationdatastore)

gcloudconfigsetprojectsandengine;gcloudappdeploy-qapp.yamlcron.yaml

Pleasenotethatyourcustomapplicationcodeshouldbelocatedinthebp_contentfolderwithinyourowntheme.Theintentionisthatseparatingtheboilerplatecodefromyourapplicationcodewillavoidmergeconflictsasyoukeepupwithfutureboilerplatechanges.

FunctionsandfeaturesAuthentication(SignIn,SignOut,SignUp)FederatedLogin-loginviayourfavoritesocialnetwork(Google,Twitter,etc...)poweredbyOpenIDandOAuthResetPasswordUpdateUserProfileContactFormClientsideandserversideformvalidationAutomaticdetectionofuserlanguageSupportformanyLanguages(English,Spanish,Italian,French,Chinese,Indonesian,German,Russian,etc)VisitorsLogNotificationsandConfirmationforuserswhentheychangetheiremailorpasswordResponsiveDesignforviewingonPCs,tablets,andmobilephones(synchronizedwithTwitter-Bootstrapproject)MobileidentificationUnitTestingErrorhandlingBasicusermanagementfeaturesavailableunder/admin/users/forGoogleApplicationAdministratorsResources

BoilerplatehasaGooglegroup(gae-boilerplate)fordiscussionsandaTwitteraccount(@gaeboilerplate)forsharingrelatedresources.

OpenSource

Ifyouwanttoadd,fixorimprovesomething,createanissueorsendaPullRequest.

Beforecommittingfixeswerecommendrunningtheunitests(intheboilerplatepackage).Thiswillhelpguardagainstchangesthataccidentlybreakothercode.Seethetestingsectionbelowforinstructions.

Feelfreetocommitimprovementsornewfeatures.Feedback,commentsandideasarewelcome.

Run

YoucanrunthisprojectdirectlyfromterminalwithFabric.

fabstart

Alsoyoucanrunitclearingdatastore.

fabstart:clearUnitTesting

Requirements

Installpipwithdistributeinordertoinstallnextpackages.

Beforerunningunittestsitisnecessarytoinstallwebtest,mock,andpyqueryinyourlocalpythoninstallation.

sudopipinstallwebtestsudopipinstallmocksudopipinstallpyquery

ThebestwaytorununittestsisthoughFabric.

sudopipinstallFabric

RunningUnitTests

TorununittestswithFabricrunfabtestcommandinterminal.AlsoUnittestscanberunviatestrunnerorinEclipsebyrightclickingonthewebfolderandselecting"runas..."->"Pythonunit-test".Youmayneedtoadd/boilerplate/externaltoyourpythonpath.

AddingyoursUnitTest

Pleaseaddunittestsforyourapplicationtoyourhandlerfolderinatest.pyfile.Yourownunittestscanbecreatedsimilarlytothoseintheboilerplate.Inheritingfromboilerplate.lib.test_helpers.HandlerHelperswillprovideaccesstoconvenienthandlertestingmethodsusedbytheboilerplate.Deploy

TodeployyourprojectwithFabric,justrunthiscommandinTerminal.

fabdeploy

Remembertochangeapplication,version,themeinapp.yamlaccordingtoyourproject.

TechnologiesusedPython2.7.5NDB1.0.10(ThebestdatastoreAPIfortheGoogleAppEnginePythonruntime).Jinja22.6(AfullyfeaturedtemplateengineforPython).WTForms-1.0.2(Formsvalidationframeworkkeepinguserinteractionsecureandflexiblewithorwithoutjavascript).Babel-0.9.6andgaepytz-2011h(Industystandardinternationalizationrendersthesiteinmultiplelanguages).webapp22.5.2(AlightweightPythonwebframework,themostcompatiblewithGoogleAppEngine).webapp2_extras.sessionswebapp2_extras.routeswebapp2_extras.authwebapp2_extras.i18nCodewrittenfollowingtheGooglePythonStyleGuideUnittestingwithunittest,webtest,pyqueryOpenIDlibraryprovidedbyGoogleAppEngineOAuth2forfederatedloginprovidersthatdonotsupportOpenIDFront-endTechnologiesHTML5BoilerplateModernizr2.6.1jQuery1.8.2TwitterBootstrap3.1.1upgradedfrom2.2.1.TemplateforDesktopVersion.Helptotranslatetonewlanguagesorimproveoldtranslations

Ineachlocale//LC_MESSAGESdirectorythereisafilemessages.po.Pleasehelpustranslatethetextinthesefiles.msgidisthetextinEnglish.msgstristhetranslationtothelanguageindicatedbythelocalecode.Forexample:

msgid"Changeyourpassword"

msgstr"Cambiartucontraseña"

Requirements

Installbeforepipwithdistribute_setup.py(Readtheenvironmentsetupdocument)

sudopipinstallbabelsudopipinstalljinja2

Translating

Toexecutethetranslation,runthesetwocommands.(beforethesecondone,gotolocalefoldertoincludeyourtranslation)

fablangfablang:compileWorkingwithInternationalization(i18n)

Thisboilerplatecomesbundledwithbabel,pytz,andautomaticlanguagedetectionwhichtogetherprovidepowerfulinternationalizationcapability.Texttobetranslatedneedstobeindicatedincodeandthentranslatedbyuserslikeyouafterwhichitiscompiledforspeed.

Addingorupdatingtexttobetranslatedoraddingnewlanguagesrequiresmoreworkasindicatedinthestepsbelow:

Texttobetranslatedshouldbeenclosedin_("texttotranslate")in*.pyfiles.

{{..._("texttotranslate")...}}{%..._("texttotranslate")...%}

Inhtmltemplatestranslatedtextisindicatedby:

{%trans%}texttotranslate{%endtrans%}

NOTE:Translationscanbeaddedtoothertypesoffilestoo.Seebabel.cfgandbabel.cfgdocumentation

Obtainpybabeltoperformthestepsbelow.Youwillneedtoinstallandcompilejinja2andbabel.Notethatyoumayneedtofirstinstallsetuptoolsandeasy_install.pybabel.execanberunfromtheScriptsdirectoryinyourpythoninstallation.

easy_installjinja2babel

Babelthenneedstofindalltranslationedtextblocksthroughoutcodeandtemplates.Afterinstallingpybablrunthiscommandtoextractmessages(assuming./isthelocationofthisboilerplate):pybabelextract-F./locale/babel.cfg-o./locale/messages.pot./--sort-output--no-location--omit-header

Updatetranslationsofexistinglanguagesoraddnewlanguages

Updatetranslationsofexistinglanguagesbyrunningthiscommandforeachlocale:pybabelupdate-les_ES-d./locale-i./locale/messages.pot--previous--ignore-obsoleteRunthiscommandforeachlocalebyreplacinges_ESinthecommand.Localenamesarethedirectorynamesin./locale.Addnewlanguages:Runthiscommandforeachnewlanguagetoadd.Youwillneedtoreplacees_ESinthecommandwiththelocalecodetoadd:pybabelinit-les_ES-d./locale-i./locale/messages.potAddthelocaletothelocalesarrayinyourthemes/<your_theme>/config/.Instructionsonhowtopickalocalecodeareprovidedinthecommentsabovethearray.

ProvidetranslationsforeachlanguageIneachlocale//LC_MESSAGESdirectorythereisafilemessages.po.Userstranslatethestringsinthesefiles.msgidisthetextinEnglish.msgstristhetranslationtothelanguageindicatedbythelocalecode.Forexample:

msgid"Changeyourpassword"msgstr"Cambiartucontraseña"

CompiletranslationsRun:pybabelcompile-f-d./locale

Seewebapp2'stutorialandpybabel'sdocsformoredetails.

Disablingi18n

i18ncanbedisabledandlanguageoptionshidden.Setlocalesinconfig.pytoNoneoremptyarray[]todothis.Thismaybeusefultoprovideaperformanceboostorsimplifysitesthatserveamarketwithonlyonelanguage.Thelocaledirectorycanbesafelyremovedtosavespaceifnotneededbutthebabelandpytzdirectoriescannotberemovedwithoutbreakingcode(importsandtransstatements)atthistime.

Security

SSL

SSLisenabledsitewidebyaddingsecure:alwaystothesection:-url:/.*inapp.yaml(removethislinetodisable)SSLeitherrequiresafreegoogleappengine*.appspot.comdomainoracustomdomainandcertificateAlternativelySSLcanbeenabledatacontrollerlevelviawebapp2schemes.Usethesecure_schemeprovidedinroutes.pyItisrecommendedtoenablesslsitewidetohelppreventsessionhijacking

Passwords

PasswordsarehashedandencryptedwithSHA512andPyCrypto.

CSRF

Cross-siterequestforgeryprotectionAcknowledgements

GoogleAppEngineBoilerplateisacollaborativeprojectcreatedbycotowhichisbringingtoyouthankstothehelpoftheseamazingpeople

Top10:Primarycontributors:

TmeryuPeta15Sergue1SabirmostofaPmanacascopycat91Mooosef1shearpresvevaSorced-Jim

FlaskBoilerplates

gae-initflask-boilerplateHerokuflask-appengine-template
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论